1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.bind = bind;
|
7 |
|
8 | function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
9 |
|
10 | var assign = Object.assign;
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | function bind(instance) {
|
21 | var reduceBoundMethods = function reduceBoundMethods(accumulator, name) {
|
22 | return assign(accumulator, _defineProperty({}, name, instance[name].bind(instance)));
|
23 | };
|
24 |
|
25 | for (var _len = arguments.length, methods = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
26 | methods[_key - 1] = arguments[_key];
|
27 | }
|
28 |
|
29 | var boundMethods = methods.reduce(reduceBoundMethods, {});
|
30 | assign(instance, boundMethods);
|
31 | } |
\ | No newline at end of file |