mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 15:27:05 +00:00
p-limit: upgrade typings for v2.0
This commit is contained in:
Vendored
+12
-4
@@ -1,10 +1,18 @@
|
||||
// Type definitions for p-limit 1.1
|
||||
// Type definitions for p-limit 2.0
|
||||
// Project: https://github.com/sindresorhus/p-limit#readme
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Linus Unnebäck <https://github.com/LinusU>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace pLimit {}
|
||||
|
||||
export = pLimit;
|
||||
|
||||
declare function pLimit(concurrency: number): <T>(fn: () => PromiseLike<T>) => Promise<T>;
|
||||
declare function limit<T, A, B, C, D, E, F>(cb: (a: A, b: B, c: C, d: D, e: E, f: F, ...args: any[]) => PromiseLike<T> | T, a: A, b: B, c: C, d: D, e: E, f: F, ...args: any[]): Promise<T>;
|
||||
declare function limit<T, A, B, C, D, E, F>(cb: (a: A, b: B, c: C, d: D, e: E, f: F) => PromiseLike<T> | T, a: A, b: B, c: C, d: D, e: E, f: F): Promise<T>;
|
||||
declare function limit<T, A, B, C, D, E>(cb: (a: A, b: B, c: C, d: D, e: E) => PromiseLike<T> | T, a: A, b: B, c: C, d: D, e: E): Promise<T>;
|
||||
declare function limit<T, A, B, C, D>(cb: (a: A, b: B, c: C, d: D) => PromiseLike<T> | T, a: A, b: B, c: C, d: D): Promise<T>;
|
||||
declare function limit<T, A, B, C>(cb: (a: A, b: B, c: C) => PromiseLike<T> | T, a: A, b: B, c: C): Promise<T>;
|
||||
declare function limit<T, A, B>(cb: (a: A, b: B) => PromiseLike<T> | T, a: A, b: B): Promise<T>;
|
||||
declare function limit<T, A>(cb: (a: A) => PromiseLike<T> | T, a: A): Promise<T>;
|
||||
declare function limit<T>(cb: () => PromiseLike<T> | T): Promise<T>;
|
||||
|
||||
declare function pLimit(concurrency: number): typeof limit;
|
||||
|
||||
@@ -11,3 +11,25 @@ const input = [
|
||||
Promise.all(input).then(result => {
|
||||
const str: string | undefined = result[0];
|
||||
});
|
||||
|
||||
let str: string;
|
||||
|
||||
declare function a(a: string): string;
|
||||
declare function b(a: string, b: number): string;
|
||||
declare function c(a: string, b: number, c: boolean): string;
|
||||
declare function d(a: string, b: number, c: boolean, d: symbol): string;
|
||||
declare function e(a: string, b: number, c: boolean, d: symbol, e: 'yes' | 'no'): string;
|
||||
declare function f(a: string, b: number, c: boolean, d: symbol, e: 'yes' | 'no', f: 1 | 2): string;
|
||||
declare function g(a: string, b: number, c: boolean, d: symbol, e: 'yes' | 'no', f: 1 | 2, g: true): string;
|
||||
|
||||
limit(a, 'test').then(v => { str = v; });
|
||||
limit(b, 'test', 1).then(v => { str = v; });
|
||||
limit(c, 'test', 1, false).then(v => { str = v; });
|
||||
limit(d, 'test', 1, false, Symbol('test')).then(v => { str = v; });
|
||||
limit(e, 'test', 1, false, Symbol('test'), 'no').then(v => { str = v; });
|
||||
limit(f, 'test', 1, false, Symbol('test'), 'no', 2).then(v => { str = v; });
|
||||
limit(g, 'test', 1, false, Symbol('test'), 'no', 2, true).then(v => { str = v; });
|
||||
|
||||
declare function add(...args: number[]): number;
|
||||
|
||||
limit(add, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13).then(v => (v === 91));
|
||||
|
||||
Reference in New Issue
Block a user