-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feature request: include reference to IPFS inside node instance #3053
Comments
This doesn't sound like a great idea, an instance should not have a reference to its factory.
Could you expand a little more on why you would do that? It's bundled with IPFS as a top-level export, why not just require it? const {
CID
} = require('ipfs') |
Pardon my ignorance on this but it seems like Class instances in javascript all have references to their factories via
I believe I just wished to inject CID with the IPFS instance. OrbitDB and my package that uses OrbitDB take an ipfs instance as a parameter to keep things simple for users. I was probably specifically looking to eliminate an older version of whats happening here, which is actually not that bad because I have to create those preceding CID instances anyway. |
They have a reference to their constructor, but a factory function might not be the constructor: class Foo {
constructor () {
}
}
function createFoo () {
return new Foo()
} IPFS is a class, but you get instances of it via the
In this project I would declare This also says to the user 'my project is compatible with this version of ipfs` and the user will get a warning if they don't declare a dep on ipfs at the right version. |
Hi, I'd like to be able to access classes like CID from just an 'instance' of ipfs made from the .create method on the IPFS factory object.
My use case is that I have a package that exports a class that takes an instance of ipfs as a parameter. I want to use the CID class included with the IPFS package instead of having to require it. Adding a reference to the IPFS factory object from the ipfs node instance object is one way to enable this.
The text was updated successfully, but these errors were encountered: