Socket
Socket
Sign inDemoInstall

static-extend

Package Overview
Dependencies
6
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    static-extend

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.


Version published
Weekly downloads
12M
decreased by-1.57%
Maintainers
1
Install size
91.0 kB
Created
Weekly downloads
 

Readme

Source

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

extend

Returns a function for extending the static properties, prototype properties, and descriptors from the Parent constructor onto Child constructors.

// extend "child" constructors Parent.extend(Child); // optionally define prototype methods as the second arg Parent.extend(Child, { foo: function() {}, bar: function() {} });

**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**

```js
var extend = require('static-extend');
Parent.extend = extend(Parent);

// optionally pass a custom merge function as the second arg
Parent.extend = extend(Parent, function(Child) {
  Child.prototype.mixin = function(key, val) {
    Child.prototype[key] = val;
  };
});

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.

Keywords

FAQs

Last updated on 11 Mar 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc