dashboardjavacloudcoapiotiot-analyticsiot-platformiot-solutionskafkalwm2mmicroservicesmiddlewaremqttnettyplatformsnmpthingsboardvisualizationwebsocketswidgets
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
1.0 KiB
27 lines
1.0 KiB
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var constants;
|
|
(function (constants) {
|
|
constants.typeOfFunction = 'function';
|
|
constants.boolTrue = true;
|
|
})(constants || (constants = {}));
|
|
function bind(target, propertyKey, descriptor) {
|
|
if (!descriptor || (typeof descriptor.value !== constants.typeOfFunction)) {
|
|
throw new TypeError("Only methods can be decorated with @bind. <" + propertyKey + "> is not a method!");
|
|
}
|
|
return {
|
|
configurable: constants.boolTrue,
|
|
get: function () {
|
|
var bound = descriptor.value.bind(this);
|
|
// Credits to https://github.com/andreypopp/autobind-decorator for memoizing the result of bind against a symbol on the instance.
|
|
Object.defineProperty(this, propertyKey, {
|
|
value: bound,
|
|
configurable: constants.boolTrue,
|
|
writable: constants.boolTrue
|
|
});
|
|
return bound;
|
|
}
|
|
};
|
|
}
|
|
exports.bind = bind;
|
|
exports.default = bind;
|
|
|