Debian Codegraph @

README.md

raw
1 # static-extend [![NPM version](https://img.shields.io/npm/v/static-extend.svg?style=flat)](https://www.npmjs.com/package/static-extend) [![NPM downloads](https://img.shields.io/npm/dm/static-extend.svg?style=flat)](https://npmjs.org/package/static-extend) [![Build Status](https://img.shields.io/travis/jonschlinkert/static-extend.svg?style=flat)](https://travis-ci.org/jonschlinkert/static-extend)
2
3 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.
4
5 ## Install
6
7 Install with [npm](https://www.npmjs.com/):
8
9 ```sh
10 $ npm install static-extend --save
11 ```
12
13 ## Usage
14
15 ```js
16 var extend = require('static-extend');
17 ```
18
19 ## API
20
21 ### [extend](index.js#L47)
22
23 Returns a function for extending the static properties, prototype properties, and descriptors from the `Parent` constructor onto `Child` constructors.
24
25 **Params**
26
27 * `Parent` **{Function}**: Parent ctor
28 * `extendFn` **{Function}**: Optional extend function for handling any necessary custom merging. Useful when updating methods that require a specific prototype.
29 * `Child` **{Function}**: Child ctor
30 * `proto` **{Object}**: Optionally pass additional prototype properties to inherit.
31 * `returns` **{Object}**
32
33 **Example**
34
35 ```js
36 var extend = require('static-extend');
37 Parent.extend = extend(Parent);
38
39 // optionally pass a custom merge function as the second arg
40 Parent.extend = extend(Parent, function(Child) {
41 Child.prototype.mixin = function(key, val) {
42 Child.prototype[key] = val;
43 };
44 });
45
46 // extend "child" constructors
47 Parent.extend(Child);
48
49 // optionally define prototype methods as the second arg
50 Parent.extend(Child, {
51 foo: function() {},
52 bar: function() {}
53 });
54 ```
55
56 ## Contributing
57
58 This document was generated by [verb-readme-generator](https://github.com/verbose/verb-readme-generator) (a [verb](https://github.com/verbose/verb) generator), please don't edit directly. Any changes to the readme must be made in [.verb.md](.verb.md). See [Building Docs](#building-docs).
59
60 Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). Or visit the [verb-readme-generator](https://github.com/verbose/verb-readme-generator) project to submit bug reports or pull requests for the readme layout template.
61
62 ## Building docs
63
64 Generate readme and API documentation with [verb](https://github.com/verbose/verb):
65
66 ```sh
67 $ npm install -g verb verb-readme-generator && verb
68 ```
69
70 ## Running tests
71
72 Install dev dependencies:
73
74 ```sh
75 $ npm install -d && npm test
76 ```
77
78 ## Author
79
80 **Jon Schlinkert**
81
82 * [github/jonschlinkert](https://github.com/jonschlinkert)
83 * [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
84
85 ## License
86
87 Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
88 Released under the [MIT license](https://github.com/jonschlinkert/static-extend/blob/master/LICENSE).
89
90 ***
91
92 _This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on June 09, 2016._