graceful-instanceof
The instanceof mechanism cross package versions.
Why?
{ if this instanceof MyClass return options // do something with options }
We intend to do something like this:
const instance = options instance === instance // true
But what happens if the instance
is came from another version of the module?
abc.js
node_modules
|-- foo # version 1.0.0
|-- index.js # which export default MyClass
|-- bar
|-- node_modules # version 1.1.0
| |-- foo
| |-- index.js # also exports MyClass
|-- index.js # which exports default the instance of MyClass
And in abc.js
bar === bar // FALSE!! // Something BOOOOOOOOOOM !!!
Install
$ npm install graceful-instanceof
Usage
const type = { if type return options type } const instace = options instance === instance // true
And it also works cross versions.
License
MIT