UNPKG

988 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var flip = require("lodash/flip");
4var factory_1 = require("./factory");
5var applicators_1 = require("./applicators");
6var decorator = factory_1.DecoratorFactory.createInstanceDecorator(new factory_1.DecoratorConfig(flip, new applicators_1.PartialValueApplicator(), { property: true }));
7/**
8 * Creates a function that invokes func with arguments reversed. Honestly, there is probably not much
9 * use for this decorator but maybe you will find one?
10 *
11 * @example
12 *
13 * class MyClass {
14 * value = 100;
15 *
16 * @Flip('fn')
17 * fn2: (b: number, a: string) => [ number, string ];
18 *
19 * fn(a: string, b: number): [ string, number ] {
20 * return [ a, b ];
21 * }
22 * }
23 *
24 * const myClass = new MyClass();
25 *
26 * myClass.fn2(10, '20'); // => [ '20', 10 ]
27 */
28function Flip(fn) {
29 return decorator(fn);
30}
31exports.Flip = Flip;
32exports.flip = Flip;
33exports.default = decorator;
34//# sourceMappingURL=flip.js.map
\No newline at end of file