Adds a static `extend` method to a class, to simplify inheritance. Extends the static properties, prototype properties, and descriptors from a `Parent` constructor onto `Child` constructors.
Adds a static extend method to a class, to simplify inheritance. Extends the static properties, prototype properties, and descriptors from a Parent constructor onto Child constructors.
Returns a function for extending the static properties, prototype properties, and descriptors from the Parent constructor onto Child constructors.
Params
Parent{Function}: Parent ctor
extendFn{Function}: Optional extend function for handling any necessary custom merging. Useful when updating methods that require a specific prototype.
Child{Function}: Child ctor
proto{Object}: Optionally pass additional prototype properties to inherit.
returns{Object}
Example
var extend = require('static-extend');Parent.extend = extend(Parent);// optionally pass a custom merge function as the second argParent.extend = extend(Parent, function(Child) { Child.prototype.mixin = function(key, val) { Child.prototype[key] = val; };});// extend "child" constructorsParent.extend(Child);// optionally define prototype methods as the second argParent.extend(Child, { foo: function() {}, bar: function() {}});
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue. Or visit the verb-readme-generator project to submit bug reports or pull requests for the readme layout template.