Adds a static
extend
method to a class, to simplify inheritance. Extends the static properties, prototype properties, and descriptors from aParent
constructor ontoChild
constructors.
Install with npm:
$ npm install static-extend --save
var extend = require('static-extend');
Returns a function for extending the static properties, prototype properties, and descriptors from the Parent
constructor onto Child
constructors.
Params
Parent
{Function}: Parent ctorextendFn
{Function}: Optional extend function for handling any necessary custom merging. Useful when updating methods that require a specific prototype.Child
{Function}: Child ctorproto
{Object}: Optionally pass additional prototype properties to inherit.returns
{Object}
Example
var extend = cu.extend(Parent);
Parent.extend(Child);
// optional methods
Parent.extend(Child, {
foo: function() {},
bar: function() {}
});
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Generate readme and API documentation with verb:
$ npm install verb && npm run docs
Or, if verb is installed globally:
$ verb
Install dev dependencies:
$ npm install -d && npm test
Jon Schlinkert
Copyright © 2016 Jon Schlinkert Released under the MIT license.
This file was generated by verb, v0.9.0, on March 11, 2016.