UNPKG

1.18 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var bind = require("lodash/bind");
4var factory_1 = require("./factory");
5var applicators_1 = require("./applicators");
6/**
7 * Creates a function that invokes func with the this binding of thisArg and partials prepended to the arguments it receives.
8 *
9 * The _.bind.placeholder value, which defaults to _ in monolithic builds, may be used as a placeholder for partially applied arguments.
10 *
11 * Note: Unlike native Function#bind, this method doesn't set the "length" property of bound functions.
12 * @param {...*} [partials] The argument to be partially applied.
13 * @example
14 *
15 * class MyClass {
16 * @Bind()
17 * bound() {
18 * return this;
19 * }
20 *
21 * unbound() {
22 * return this;
23 * }
24 * }
25 *
26 * const myClass = new MyClass();
27 *
28 * myClass.bound.call(null); // => myClass {}
29 * myClass.unbound.call(null); // => null
30 */
31exports.Bind = factory_1.DecoratorFactory.createInstanceDecorator(new factory_1.DecoratorConfig(bind, new applicators_1.BindApplicator(), {
32 optionalParams: true
33}));
34exports.bind = exports.Bind;
35exports.default = exports.Bind;
36//# sourceMappingURL=bind.js.map
\No newline at end of file