-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
index.d.ts
26 lines (21 loc) · 630 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
/**
Import a module lazily.
@example
```
// Pass in `require` or a custom import function
import importLazy = require('import-lazy');
const _ = importLazy(require)('lodash');
// Instead of referring to its exported properties directly…
_.isNumber(2);
// …it's cached on consecutive calls
_.isNumber('unicorn');
// Works out of the box for functions and regular properties
const stuff = importLazy(require)('./math-lib');
console.log(stuff.sum(1, 2)); // => 3
console.log(stuff.PHI); // => 1.618033
```
*/
declare function importLazy<T>(
importFn: (moduleId: string) => T
): (moduleId: string) => T;
export = importLazy;