1 | ;
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var before = require("lodash/before");
|
4 | var factory_1 = require("./factory");
|
5 | var applicators_1 = require("./applicators");
|
6 | var 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 | */
|
31 | function Before(n) {
|
32 | return decorator(n);
|
33 | }
|
34 | exports.Before = Before;
|
35 | exports.before = Before;
|
36 | exports.default = decorator;
|
37 | //# sourceMappingURL=before.js.map |
\ | No newline at end of file |