UNPKG

1.16 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.createDecorator(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 * @BeforeAll(3)
17 * fn() {
18 * calls++;
19 * }
20 * }
21 *
22 * const myClass = new MyClass();
23 * const myClass2 = new MyClass();
24 *
25 * myClass.fn();
26 * myClass.fn();
27 * myClass.fn();
28 * myClass.fn();
29 *
30 * myClass2.fn();
31 *
32 * calls === 3; // => true
33 */
34function BeforeAll(n) {
35 return decorator(n);
36}
37exports.BeforeAll = BeforeAll;
38exports.beforeAll = BeforeAll;
39exports.default = decorator;
40//# sourceMappingURL=beforeAll.js.map
\No newline at end of file