1.0.1 • Published 6 years ago

@stamp/instanceof v1.0.1

Weekly downloads
8
License
MIT
Repository
github
Last release
6 years ago

@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.