-
-
Notifications
You must be signed in to change notification settings - Fork 280
/
utils.d.ts
41 lines (41 loc) · 1.25 KB
/
utils.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
export type InputFileSystem = import("webpack").Compilation["inputFileSystem"];
export type Stats = import("fs").Stats;
export type Task<T> = () => Promise<T>;
/** @typedef {import("webpack").Compilation["inputFileSystem"] } InputFileSystem */
/** @typedef {import("fs").Stats } Stats */
/**
* @param {InputFileSystem} inputFileSystem
* @param {string} path
* @return {Promise<undefined | Stats>}
*/
export function stat(
inputFileSystem: InputFileSystem,
path: string,
): Promise<undefined | Stats>;
/**
* @param {InputFileSystem} inputFileSystem
* @param {string} path
* @return {Promise<string | Buffer>}
*/
export function readFile(
inputFileSystem: InputFileSystem,
path: string,
): Promise<string | Buffer>;
/**
* @template T
* @typedef {() => Promise<T>} Task
*/
/**
* Run tasks with limited concurrency.
* @template T
* @param {number} limit - Limit of tasks that run at once.
* @param {Task<T>[]} tasks - List of tasks to run.
* @returns {Promise<T[]>} A promise that fulfills to an array of the results
*/
export function throttleAll<T>(limit: number, tasks: Task<T>[]): Promise<T[]>;
/**
* @template T
* @param fn {(function(): any) | undefined}
* @returns {function(): T}
*/
export function memoize<T>(fn: (() => any) | undefined): () => T;