@saulx/utils
Advanced tools
Comparing version 1.4.2 to 1.4.3
@@ -1,4 +0,49 @@ | ||
export default function queued<A, B, C, D, E, F, G, H>(promiseFn: (a?: A, b?: B, c?: C, d?: D, e?: E, f?: F, g?: G, h?: H) => Promise<H>, opts?: { | ||
declare function queued<K>(promiseFn: () => Promise<K>, opts?: { | ||
concurrency?: number; | ||
dedup?: (...args: any[]) => number | string; | ||
}): (a?: A, b?: B, c?: C, d?: D, e?: E, f?: F, g?: G, h?: H) => Promise<H>; | ||
}): () => Promise<K>; | ||
declare function queued<A, K>(promiseFn: (a?: A) => Promise<K>, opts?: { | ||
concurrency?: number; | ||
dedup?: (...args: any[]) => number | string; | ||
}): (a?: A) => Promise<K>; | ||
declare function queued<A, B, K>(promiseFn: (a?: A, b?: B) => Promise<K>, opts?: { | ||
concurrency?: number; | ||
dedup?: (...args: any[]) => number | string; | ||
}): (a?: A, b?: B) => Promise<K>; | ||
declare function queued<A, B, C, K>(promiseFn: (a?: A, b?: B, c?: C) => Promise<K>, opts?: { | ||
concurrency?: number; | ||
dedup?: (...args: any[]) => number | string; | ||
}): (a?: A, b?: B, c?: C) => Promise<K>; | ||
declare function queued<A, B, C, D, K>(promiseFn: (a?: A, b?: B, c?: C, d?: D) => Promise<K>, opts?: { | ||
concurrency?: number; | ||
dedup?: (...args: any[]) => number | string; | ||
}): (a?: A, b?: B, c?: C, d?: D) => Promise<K>; | ||
declare function queued<A, B, C, D, E, K>(promiseFn: (a?: A, b?: B, c?: C, d?: D, e?: E) => Promise<K>, opts?: { | ||
concurrency?: number; | ||
dedup?: (...args: any[]) => number | string; | ||
}): (a?: A, b?: B, c?: C, d?: D, e?: E) => Promise<K>; | ||
declare function queued<A, B, C, D, E, F, G, K>(promiseFn: (a?: A, b?: B, c?: C, d?: D, e?: E) => Promise<K>, opts?: { | ||
concurrency?: number; | ||
dedup?: (...args: any[]) => number | string; | ||
}): (a?: A, b?: B, c?: C, d?: D, e?: E, f?: F, g?: G) => Promise<K>; | ||
declare function queued<A, B, C, D, E, F, K>(promiseFn: (a?: A, b?: B, c?: C, d?: D, e?: E, f?: F) => Promise<K>, opts?: { | ||
concurrency?: number; | ||
dedup?: (...args: any[]) => number | string; | ||
}): (a?: A, b?: B, c?: C, d?: D, e?: E, f?: F) => Promise<K>; | ||
declare function queued<A, B, C, D, E, F, G, K>(promiseFn: (a?: A, b?: B, c?: C, d?: D, e?: E, f?: F, g?: G) => Promise<K>, opts?: { | ||
concurrency?: number; | ||
dedup?: (...args: any[]) => number | string; | ||
}): (a?: A, b?: B, c?: C, d?: D, e?: E, f?: F, g?: G) => Promise<K>; | ||
declare function queued<A, B, C, D, E, F, G, H, K>(promiseFn: (a?: A, b?: B, c?: C, d?: D, e?: E, f?: F, g?: G, h?: H) => Promise<K>, opts?: { | ||
concurrency?: number; | ||
dedup?: (...args: any[]) => number | string; | ||
}): (a?: A, b?: B, c?: C, d?: D, e?: E, f?: F, g?: G, h?: H) => Promise<K>; | ||
declare function queued<A, B, C, D, E, F, G, H, I, K>(promiseFn: (a?: A, b?: B, c?: C, d?: D, e?: E, f?: F, g?: G, h?: H, i?: I) => Promise<K>, opts?: { | ||
concurrency?: number; | ||
dedup?: (...args: any[]) => number | string; | ||
}): (a?: A, b?: B, c?: C, d?: D, e?: E, f?: F, g?: G, h?: H, i?: I) => Promise<K>; | ||
declare function queued<A, B, C, D, E, F, G, H, I, J, K>(promiseFn: (a?: A, b?: B, c?: C, d?: D, e?: E, f?: F, g?: G, h?: H, i?: I, j?: J) => Promise<K>, opts?: { | ||
concurrency?: number; | ||
dedup?: (...args: any[]) => number | string; | ||
}): (a?: A, b?: B, c?: C, d?: D, e?: E, f?: F, g?: G, h?: H, i?: I, j?: J) => Promise<K>; | ||
export default queued; |
@@ -73,34 +73,4 @@ "use strict"; | ||
}; | ||
return (a, b, c, d, e, f, g, h) => { | ||
return (...args) => { | ||
return new Promise((resolve, reject) => { | ||
let args; | ||
// this beauty is there for type script so args.length will still be correct | ||
// (typescript does not support inheriting types from args directly...) | ||
if (h !== undefined) { | ||
args = [a, b, c, d, e, f, g, h]; | ||
} | ||
else if (g !== undefined) { | ||
args = [a, b, c, d, e, f, g]; | ||
} | ||
else if (f !== undefined) { | ||
args = [a, b, c, d, e, f]; | ||
} | ||
else if (e !== undefined) { | ||
args = [a, b, c, d, e]; | ||
} | ||
else if (d !== undefined) { | ||
args = [a, b, c, d]; | ||
} | ||
else if (c !== undefined) { | ||
args = [a, b, c]; | ||
} | ||
else if (b !== undefined) { | ||
args = [a, b]; | ||
} | ||
else if (a !== undefined) { | ||
args = [a]; | ||
} | ||
else { | ||
args = []; | ||
} | ||
const id = opts.dedup(...args); | ||
@@ -107,0 +77,0 @@ if (!listeners[id]) { |
{ | ||
"name": "@saulx/utils", | ||
"main": "./dist/index.js", | ||
"version": "1.4.2", | ||
"version": "1.4.3", | ||
"scripts": { | ||
@@ -6,0 +6,0 @@ "build": "tsc", |
Sorry, the diff of this file is not supported yet
49429
705