UNPKG

1.12 kBTypeScriptView Raw
1export type InputFileSystem = import("webpack").Compilation["inputFileSystem"];
2export type Stats = import("fs").Stats;
3export type Task<T> = () => Promise<T>;
4/** @typedef {import("webpack").Compilation["inputFileSystem"] } InputFileSystem */
5/** @typedef {import("fs").Stats } Stats */
6/**
7 * @param {InputFileSystem} inputFileSystem
8 * @param {string} path
9 * @return {Promise<undefined | Stats>}
10 */
11export function stat(
12 inputFileSystem: InputFileSystem,
13 path: string
14): Promise<undefined | Stats>;
15/**
16 * @param {InputFileSystem} inputFileSystem
17 * @param {string} path
18 * @return {Promise<string | Buffer>}
19 */
20export function readFile(
21 inputFileSystem: InputFileSystem,
22 path: string
23): Promise<string | Buffer>;
24/**
25 * @template T
26 * @typedef {() => Promise<T>} Task
27 */
28/**
29 * Run tasks with limited concurency.
30 * @template T
31 * @param {number} limit - Limit of tasks that run at once.
32 * @param {Task<T>[]} tasks - List of tasks to run.
33 * @returns {Promise<T[]>} A promise that fulfills to an array of the results
34 */
35export function throttleAll<T>(limit: number, tasks: Task<T>[]): Promise<T[]>;