carcass
Version:
A toolbox for Node.js.
27 lines (22 loc) • 427 B
JavaScript
var isObject, mixable;
isObject = require('es5-ext/object/is-object');
/**
* Add a mixin() function to a target object.
*
* @param {Object}
*
* @return {Object}
*/
module.exports = mixable = function(obj) {
if (obj == null) {
obj = {};
}
if (!isObject(obj) || obj.mixin) {
return obj;
}
if (obj.prototype) {
mixable(obj.prototype);
}
obj.mixin = require('./helpers/mixin');
return obj;
};