forked from sindresorhus/clear-module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
52 lines (38 loc) · 1005 Bytes
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
declare const clear: {
/**
Clear a module from the [cache](https://nodejs.org/api/modules.html#modules_caching).
@param moduleId - What you would use with `require()`.
@example
```
// foo.ts
let i = 0;
module.exports = () => ++i;
// test.ts
import clearModule = require('clear-module');
require('./foo')();
//=> 1
require('./foo')();
//=> 2
clearModule('./foo');
require('./foo')();
//=> 1
```
*/
(moduleId: string): void;
/**
Clear all modules from the cache.
*/
all(): void;
/**
Clear all matching modules from the cache.
@param regex - Regex to match against the module IDs.
*/
match(regex: RegExp): void;
/**
Clear a single module from the cache non-recursively. No parent or children modules will be affected.
This is mostly only useful if you use singletons, where you would want to clear a specific module without causing any side effects.
@param moduleId - What you would use with `require()`.
*/
single(moduleId: string): void;
};
export = clear;