@stamp/instanceof
v1.0.1
Published
Enables `obj instanceof MyStamp` in ES6 environments
Downloads
6
Readme
@stamp/instanceof
Enables obj instanceof MyStamp
in ES6 environments
const InstanceOf = require('@stamp/InstanceOf');
// or
import InstanceOf from '@stamp/InstanceOf';
Example
Create a stamp:
let MyStamp = compose({
properties: { ... },
initializers: [function () { ... }]
});
The following doesn't work:
const obj = MyStamp();
obj instanceof MyStamp === false;
Compose the InstanceOf
to your stamp:
MyStamp = MyStamp.compose(InstanceOf);
Now it works:
const myObject = MyStamp();
obj instanceof MyStamp === true;
Notes
- We do not recommend to use
instanceof
in JavaScript in general.