Releases: stampit-org/stampit
Republish a malformed package
The v3.1.0
tarball was uploaded to NPM registry somewhat wrongly. This v3.1.1
just fixes the issue.
New feature - composers
"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
Previous release accidentally published few unnecessary development files.
Performance fix
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
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
Incorrect `export {compose}`
Stampit was exporting the original pure compose
function. Although, by design it should have exported the infected compose (aka stampit).
NPM tarball size decrease
Reduced the NPM distributed tarball from 60KB to 43KB.
Major leap forward
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 instamp.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()
. Useprops()
instead. stampit.mixin()
,.extend()
,.mixIn()
,.assign()
are all gone too. Use ES6Object.assign()
static()
got renamed tostatics()
- 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()
andstampit.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 standardcompose
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
Generators were not considered as methods. Now they are. :)