Skip to content

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.

License

Notifications You must be signed in to change notification settings

jonschlinkert/static-extend

Repository files navigation

static-extend NPM version Build Status

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.

Install

Install with npm:

$ npm install static-extend --save

Usage

var extend = require('static-extend');

API

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 = cu.extend(Parent);
Parent.extend(Child);

// optional methods
Parent.extend(Child, {
  foo: function() {},
  bar: function() {}
});

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Building docs

Generate readme and API documentation with verb:

$ npm install verb && npm run docs

Or, if verb is installed globally:

$ verb

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

Jon Schlinkert

License

Copyright © 2016 Jon Schlinkert Released under the MIT license.


This file was generated by verb, v0.9.0, on March 11, 2016.

About

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.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published