Promises, ES6, Examples and more
- You can return Promises (aka Thenables) from the
init()
functions. If any of the composedinit()
functions returns a promise then the stamp (and everything it is composed with) will always return a promise. Example:
const promisedStamp = stampit.init(() => { return Promise.resolve(); });
const regularStamp = stampit.refs({ data: 1 });
const regularStamp2 = stampit.methods({ foo() { console.log('foo'); } });
var promisedStamp2 = regularStamp.compose(promisedStamp).compose(regularStamp2);
promisedStamp2.create(); // returns a Promise!
More examples are in the tests.
- When converting a constructor it's "static" properties are now converted to stampit statics.
function OldFashionedConstructor() {}
OldFashionedConstructor.prototype.regularMethod = function() {};
OldFashionedConstructor.staticMethod = function() {};
const stamp = stampit.converConstructor(OldFashionedConstructor);
stamp.staticMethod(); // It exist!
- Stampit was converted to ES6. But, it trasplies to ES5 for obvious reasons. All tests are ES6 too. ESLint is used now instead of JSHint.
- An internal
mixer.js
module was split out to a separate npm modulesupermixer
. - Many useful examples were added. See ADVANCED_EXAMPLES.md.
- Stampit tests coverage can be checked with
npm run cov
. It's 100% now. - Node Security Project and dependency checks are applied to each build now.
- Few corner cases were improved for better stability.