UNPKG

lara-bind

Version:

simple bind function

21 lines (20 loc) 653 B
export var DecoratorKind; (function (DecoratorKind) { DecoratorKind["CLASS"] = "class"; DecoratorKind["METHOD"] = "method"; DecoratorKind["GETTER"] = "getter"; DecoratorKind["SETTER"] = "setter"; DecoratorKind["FIELD"] = "field"; DecoratorKind["ACCESSOR"] = "accessor"; })(DecoratorKind || (DecoratorKind = {})); export default function bind() { return (target, context) => { if (context.kind !== DecoratorKind.METHOD) return; context.addInitializer(function () { Object.defineProperty(this, target.name, { value: target.bind(this) }); }); }; }