Stampit Versions Save

OOP is better with stamps: Composable object factories.

v3.1.1

7 years ago

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

v3.1.0

7 years ago

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

v3.0.6

7 years ago

Previous release accidentally published few unnecessary development files.

v3.0.5

7 years ago

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

v3.0.4

7 years ago

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

7 years ago

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

v3.0.2

7 years ago

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

v3.0.1

7 years ago

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

v3.0.0

7 years ago

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

v2.1.2

7 years ago

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