UNPKG

1.09 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var before = require("lodash/before");
4var factory_1 = require("./factory");
5var applicators_1 = require("./applicators");
6var decorator = factory_1.DecoratorFactory.createInstanceDecorator(new factory_1.DecoratorConfig(before, new applicators_1.PostValueApplicator(), { setter: true }));
7/**
8 * Creates a function that invokes func, with the this binding and arguments of the created function, while it's called less than n times.
9 * Subsequent calls to the created function return the result of the last func invocation.
10 * @param {number} n The number of calls at whichc func is no longer invoked.
11 * @example
12 *
13 * let calls = 0;
14 *
15 * class MyClass {
16 * @Before(3)
17 * fn() {
18 * calls++;
19 * }
20 * }
21 *
22 * const myClass = new MyClass();
23 *
24 * myClass.fn();
25 * myClass.fn();
26 * myClass.fn();
27 * myClass.fn();
28 *
29 * calls === 2; // => true
30 */
31function Before(n) {
32 return decorator(n);
33}
34exports.Before = Before;
35exports.before = Before;
36exports.default = decorator;
37//# sourceMappingURL=before.js.map
\No newline at end of file