Skip to content

Releases: stampit-org/stampit

Republish a malformed package

18 Dec 12:08
Compare
Choose a tag to compare

The v3.1.0 tarball was uploaded to NPM registry somewhat wrongly. This v3.1.1 just fixes the issue.

New feature - composers

18 Dec 12:06
Compare
Choose a tag to compare

"Composers" is an experimental proposal to the Stamp Specification.

Composers are sort-of-a hooks where you can alter composition with your own logic. See this article.

Simplest example:

const Tracked = stampit()
  .composers(({composables, stamp}) => { // declaring a composer
    console.log(`Composed a stamp "${stamp}" from the following:
      "${composable.join()}"`);
  });

The list of composers is stored in the stamp.compose.configuration.composers array. This means that stamps are still specification compatible.

Fix npm distro size

01 Nov 08:03
Compare
Choose a tag to compare

Previous release accidentally published few unnecessary development files.

Performance fix

30 Oct 07:31
Compare
Choose a tag to compare

Object instance property access performance was 100 times lower than for plain objects. Fixed.
Also, improved IDE support with some additional JSDoc.

Remove .babelrc and package.json-babel

19 Oct 08:09
Compare
Choose a tag to compare

By removing .babelrc file, and the babel property in the package.json we improve compatibility with react-native and other packages which traverse the node_modules for babel stuff.

Instead, we are using buble for transpilation. It's faster, and generates a tiny bit smaller bundle file (1.52KB vs 1.56KB).

v3.0.3

14 Oct 00:48
Compare
Choose a tag to compare

Remove "browser" property from package.json as not needed and wrongly used

Incorrect `export {compose}`

02 Oct 00:06
Compare
Choose a tag to compare

Stampit was exporting the original pure compose function. Although, by design it should have exported the infected compose (aka stampit).

NPM tarball size decrease

25 Sep 12:28
Compare
Choose a tag to compare

Reduced the NPM distributed tarball from 60KB to 43KB.

Major leap forward

23 Sep 04:50
Compare
Choose a tag to compare

Differences with Stampit v2.

  • node.js <= v0.12 and IE <= v10 maintenance period has ended (node, IE). WARNING! If running in node.js <= v0.12 or IE <= 11 then you'd need to polyfill the Object.assign. Like this, or that (autodetected).
  • Stamps from stampit v2 and stampit v3 are not compatible. You should not compose them together.
  • Initializers now receive two arguments instead of just one.
    First is the factory first argument (i.e. arguments[0]), second is the same options object as before - { instance, stamp, args }.

Stampit v2:

const Stamp = stampit({ init({instance, stamp, args}) {
  // ...
}});

Stampit v3:

const Stamp = stampit({ init(arg, {instance, stamp, args}) {
  console.log(arg); // 42
}});
Stamp(42);
  • The factory first argument properties are no longer automatically assigned to the instance.

Stampit v2:

const Stamp = stampit({ init({instance, stamp, args}) {
  console.log(this); // {foo: "bar"}
}});
Stamp({foo: 'bar'});

Stampit v3:

const Stamp = stampit({init(arg, {instance, stamp, args}) {
  console.log(this); // {}
}});
Stamp({foo: 'bar'});

A workaround can be implemented as a separate behavior (stamp).

const AssignFirstArgument = stampit({ init(opts) {
  Object.assign(this, opts);
}});
Stamp = AssignFirstArgument.compose(Stamp);
Stamp({foo: 'bar'}); // {foo: "bar"}
  • A stamp's metadata is now stored in the stamp.compose object. Previously it was stored in stamp.fixed object.
  • Removed convertConstructor(). We plan to revive it and support the ES6 classes.
  • The .props() does not deeply merge objects any more, but shallow assigns properties. Just like .properties() and .refs().
    Use .deepProps() instead.
  • Removed state(). Use props() instead.
  • stampit.mixin(), .extend(), .mixIn(), .assign() are all gone too. Use ES6 Object.assign()
  • static() got renamed to statics()
  • The stampit.isStamp was moved. You should import it separately now: require('stampit/isStamp').
  • Initializers do not support Promises anymore. Meaning that "thenables" are not automatically unwrapped by initializers.
  • The stamp.init() and stampit.init() do not support objects as incoming arguments anymore. Use ES6 .init(Object.values(obj)) instead.

New features

  • Stampit is compatible with the Stamp Specification.
  • You can import shortcuts and utility functions in various ways:
    • import {statics} from 'stampit'
    • const {statics} = require('stampit')
  • New utility function isComposable. Can be imported separately: require('stampit/isComposable').
  • New utility function compose. It is the pure standard compose function implementation. Can be imported separately: require('stampit/compose').
  • New methods on stamps (stamp.METHOD), as well as new shortcut methods on stampit (stampit.METHOD), as well as new options to stampit (stampit({OPTION: *})). They are: initializers, init, props, properties, deepProps, deepProperties, statics, staticProperties, deepStatics, staticDeepProperties, conf, configuration, deepConf, deepConfiguration, propertyDescriptors, staticPropertyDescriptors

Respect generators as methods

29 Jul 06:01
Compare
Choose a tag to compare

Generators were not considered as methods. Now they are. :)