source: trip-planner-front/node_modules/mimic-fn/index.d.ts@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.2 KB
Line 
1declare const mimicFn: {
2 /**
3 Make a function mimic another one. It will copy over the properties `name`, `length`, `displayName`, and any custom properties you may have set.
4
5 @param to - Mimicking function.
6 @param from - Function to mimic.
7 @returns The modified `to` function.
8
9 @example
10 ```
11 import mimicFn = require('mimic-fn');
12
13 function foo() {}
14 foo.unicorn = '🦄';
15
16 function wrapper() {
17 return foo();
18 }
19
20 console.log(wrapper.name);
21 //=> 'wrapper'
22
23 mimicFn(wrapper, foo);
24
25 console.log(wrapper.name);
26 //=> 'foo'
27
28 console.log(wrapper.unicorn);
29 //=> '🦄'
30 ```
31 */
32 <
33 ArgumentsType extends unknown[],
34 ReturnType,
35 FunctionType extends (...arguments: ArgumentsType) => ReturnType
36 >(
37 to: (...arguments: ArgumentsType) => ReturnType,
38 from: FunctionType
39 ): FunctionType;
40
41 // TODO: Remove this for the next major release, refactor the whole definition to:
42 // declare function mimicFn<
43 // ArgumentsType extends unknown[],
44 // ReturnType,
45 // FunctionType extends (...arguments: ArgumentsType) => ReturnType
46 // >(
47 // to: (...arguments: ArgumentsType) => ReturnType,
48 // from: FunctionType
49 // ): FunctionType;
50 // export = mimicFn;
51 default: typeof mimicFn;
52};
53
54export = mimicFn;
Note: See TracBrowser for help on using the repository browser.