1 | 'use strict';
|
2 |
|
3 | var _lodash = require('lodash');
|
4 |
|
5 |
|
6 | module.exports = function extend(protoProps, staticProps) {
|
7 | var Parent = this;
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | var Child = protoProps && protoProps.hasOwnProperty('constructor') ? protoProps.constructor : function () {
|
13 | return Parent.apply(this, arguments);
|
14 | };
|
15 |
|
16 | (0, _lodash.assign)(Child, Parent, staticProps);
|
17 |
|
18 |
|
19 | Child.prototype = Object.create(Parent.prototype, {
|
20 | constructor: {
|
21 | value: Child,
|
22 | enumerable: false,
|
23 | writable: true,
|
24 | configurable: true
|
25 | }
|
26 | });
|
27 |
|
28 | if (protoProps) {
|
29 | (0, _lodash.assign)(Child.prototype, protoProps);
|
30 | }
|
31 |
|
32 |
|
33 | Child.__super__ = Parent.prototype;
|
34 |
|
35 |
|
36 |
|
37 | if ((0, _lodash.isFunction)(Parent.extended)) Parent.extended(Child);
|
38 |
|
39 | return Child;
|
40 | }; |
\ | No newline at end of file |