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

Comparing version 0.1.0 to 0.1.1

15

index.js

@@ -19,6 +19,17 @@ /*!

* ```js
* var extend = cu.extend(Parent);
* 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;
* };
* });
* ```
*
* // extend "child" constructors
* Parent.extend(Child);
*
* // optional methods
* // optionally define prototype methods as the second arg
* Parent.extend(Child, {

@@ -25,0 +36,0 @@ * foo: function() {},

2

package.json
{
"name": "static-extend",
"description": "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": "0.1.0",
"version": "0.1.1",
"homepage": "https://github.com/jonschlinkert/static-extend",

@@ -6,0 +6,0 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

@@ -21,13 +21,22 @@ # static-extend [![NPM version](https://img.shields.io/npm/v/static-extend.svg)](https://www.npmjs.com/package/static-extend) [![Build Status](https://img.shields.io/travis/jonschlinkert/static-extend.svg)](https://travis-ci.org/jonschlinkert/static-extend)

### [extend](index.js#L36)
### [extend](index.js#L47)
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}**
* `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}**

@@ -37,9 +46,10 @@ **Example**

```js
var extend = cu.extend(Parent);
Parent.extend(Child);
var extend = require('static-extend');
Parent.extend = extend(Parent);
// optional methods
Parent.extend(Child, {
foo: function() {},
bar: function() {}
// 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;
};
});

@@ -46,0 +56,0 @@ ```

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