UNPKG

1.1 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var partial = require("lodash/partial");
4var factory_1 = require("./factory");
5var applicators_1 = require("./applicators");
6var decorator = factory_1.DecoratorFactory.createInstanceDecorator(new factory_1.DecoratorConfig(partial, new applicators_1.PartialApplicator(), { property: true, method: false }));
7/**
8 * Partially applies arguments to a function.
9 * @export
10 * @param {...any[]} partials
11 * @returns {PropertyDecorator}
12 * @example
13 * class MyClass {
14 * lastName: string = 'Schmo';
15 *
16 * @Partial('fn', 'Joe')
17 * fn2: () => string;
18 *
19 * fn(name: string): string {
20 * return `${name} ${this.lastName}`;
21 * }
22 * }
23 *
24 * const myClass = new MyClass();
25 *
26 * myClass.fn2(); //=> 'Joe Schmo'
27 */
28function Partial() {
29 var partials = [];
30 for (var _i = 0; _i < arguments.length; _i++) {
31 partials[_i] = arguments[_i];
32 }
33 return decorator.apply(void 0, partials);
34}
35exports.Partial = Partial;
36exports.partial = Partial;
37exports.default = decorator;
38//# sourceMappingURL=partial.js.map
\No newline at end of file