extend-with-super
v2.0.0
Published
Extend object literals with function properties to have a _super method that references the original function, instead of overwriting it. (No dependencies, but borrowed methods from underscore.js.)
Downloads
601
Maintainers
Readme
extend-with-super
Quickstart Example & Description
// Extend object literals with function properties to have a
// _super method that references the original function, instead
// of overwriting it.
// (No dependencies, but borrowed methods from underscore.js.)
var sampleObj = {
funcProp: function(){
return 'Hello';
}
};
var sampleObj2 = {
funcProp: function(){
var originalMethod = this._super();
return originalMethod + ' World';
}
};
// Note just like _.extend, only the first argument is modified
var sampleObj3 = extendWithSuper({}, sampleObj, sampleObj2);
sampleObj3.funcProp(); // Hello World
Usage / Support
On the server/browserify:
CommonJS in npm.
Supported in all versions of node.js/iojs.
With RequireJS or as Global in browser:
Bower in UMD ~ Global is extendWithSuper
.
Tests pass in IE9+ - Does not break IE8.
In browser weight
< 1kb
gzip: 606 bytes
Contributing
Commands:
npm run build
npm test
Open a github issue for the bug/enhancement discussion.
Any contributions must be accompanied with tests.
Make a pull request to the develop branch referencing the issue.
Please do not introduce any external dependencies.
Main functionality influenced by underscore.js.
License MIT