Skip to content

Releases: stampit-org/stampit

Promises, ES6, Examples and more

28 Jun 05:21
Compare
Choose a tag to compare
  • You can return Promises (aka Thenables) from the init() functions. If any of the composed init() 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 module supermixer.
  • 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.

v2.0.0

12 Jun 02:02
Compare
Choose a tag to compare

Breaking changes:

  • stampit() now receives options object ({methods,refs,init,props, static}) instead of multiple arguments.
  • All chaining methods return new stamps instead of self-mutating this stamp.
  • state() always shallow merge properties. It was not doing so in a single rare case.
  • Instead of factory arguments the enclose() functions now receive the following object { instance, stamp, args }.

New features:

  • stampit() now receives options object ({methods,refs,init,props,static}) instead of multiple arguments.
  • Instead of factory arguments the enclose() functions now receive the following object { instance, stamp, args }.
  • New stamp.props() method for deeply merged state.
  • New stamp.static() method which add properties to stamp, not an object.
  • state deprecated. refs must be used instead.
  • enclose deprecated. init must be used instead.
  • All API functions have shortcuts now. I.e. you can write stampit.init() instead of stampit().init(). Same for methods, refs, props, static.
  • All unit tests are now on tape instead of mocha+should.

v1.2.0

12 Jun 02:02
Compare
Choose a tag to compare

Added .static() to stamp API. Now each stamp can have its own properties more easily.

var stampWithStatic = stampit({ method: function() {} }).static({ staticMethod: function () {} });
stampWithStatic.staticMethod(); // works!
var instance = stampWithStatic();
instance.method(); // should work too