1 | # Installation
|
2 | > `npm install --save @types/rewire`
|
3 |
|
4 | # Summary
|
5 | This package contains type definitions for rewire (https://github.com/jhnns/rewire).
|
6 |
|
7 | # Details
|
8 | Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/rewire.
|
9 | ## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/rewire/index.d.ts)
|
10 | ````ts
|
11 | declare namespace RewireInterfaces {
|
12 | interface RewiredModule {
|
13 | /**
|
14 | * Takes all enumerable keys of obj as variable names and sets the values respectively. Returns a function which can be called to revert the change.
|
15 | */
|
16 | __set__(obj: { [variable: string]: any }): () => void;
|
17 | /**
|
18 | * Sets the internal variable name to the given value. Returns a function which can be called to revert the change.
|
19 | */
|
20 | __set__(name: string, value: any): () => void;
|
21 | /**
|
22 | * Returns the private variable with the given name.
|
23 | */
|
24 | __get__<T = any>(name: string): T;
|
25 | /**
|
26 | * Returns a function which - when being called - sets obj, executes the given callback and reverts obj. If callback returns a promise, obj is only reverted after
|
27 | * the promise has been resolved or rejected. For your convenience the returned function passes the received promise through.
|
28 | */
|
29 | __with__(obj: { [variable: string]: any }): (callback: () => any) => any;
|
30 | }
|
31 | }
|
32 |
|
33 | /**
|
34 | * Returns a rewired version of the module found at filename. Use rewire() exactly like require().
|
35 | */
|
36 | declare function rewire<T = { [key: string]: any }>(filename: string): RewireInterfaces.RewiredModule & T;
|
37 | export = rewire;
|
38 |
|
39 | ````
|
40 |
|
41 | ### Additional Details
|
42 | * Last updated: Tue, 07 Nov 2023 15:11:36 GMT
|
43 | * Dependencies: none
|
44 |
|
45 | # Credits
|
46 | These definitions were written by [Borislav Zhivkov](https://github.com/borislavjivkov), and [Federico Caselli](https://github.com/CaselIT).
|
47 |
|
\ | No newline at end of file |