1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var constants;
|
4 | (function (constants) {
|
5 | constants.typeOfFunction = 'function';
|
6 | constants.boolTrue = true;
|
7 | })(constants || (constants = {}));
|
8 | function bind(target, propertyKey, descriptor) {
|
9 | if (!descriptor || (typeof descriptor.value !== constants.typeOfFunction)) {
|
10 | throw new TypeError("Only methods can be decorated with @bind. <" + propertyKey + "> is not a method!");
|
11 | }
|
12 | return {
|
13 | configurable: constants.boolTrue,
|
14 | get: function () {
|
15 | var bound = descriptor.value.bind(this);
|
16 |
|
17 | Object.defineProperty(this, propertyKey, {
|
18 | value: bound,
|
19 | configurable: constants.boolTrue,
|
20 | writable: constants.boolTrue
|
21 | });
|
22 | return bound;
|
23 | }
|
24 | };
|
25 | }
|
26 | exports.bind = bind;
|
27 | exports.default = bind;
|