Package Exports
- mix-into
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mix-into) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
mix-into
Mix objects into other objects.
By adopting the "mix into" methodology, your code avoids the mess of "add this mixin; add this mixin; add this mixin". Istead, you can dynamically nest and defer the the mixin process.
Install
npm isntall mix-into --save
Usage
Basic
var mix = require('mix-into');
var baseMixin = {
baseValue: 'some value',
baseMethod: function () {
return baseValue;
}
};
var obj = {};
mix(baseMixin).into(obj);
obj.baseMethod(); // OUTPUTS: 'some value'
Partial Applied Mixin
var mix = require('mix-into');
var baseMixin = mix({
baseValue: 'some value',
baseMethod: function () {
return baseValue;
}
});
var obj = {};
baseMixin.mixInto(obj);
obj.baseMethod() // OUTPUS: 'some value'
Nested Mixins
var mix = require('mix-into');
var baseMixin = mix({
baseValue: 'some value',
baseMethod: function () {
return baseValue;
}
});
var obj = {
objMethod: function () {
return this.baseValue;
}
};
var obj2 = {};
baseMixin.mixInto(obj);
obj.mixInto(obj2); // mixInto method added to each object that's mixed into
obj2.objMethod() // OUTPUS: 'some value'
Create New Object from Mixin
var mix = require('mix-into');
var baseMixin = mix({
value1: 'value1'
});
var obj = baseMixin.create();
console.log(obj.value1); // OUTPUTS: 'value1'
Run Tests
npm install
npm test