mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-12 03:46:07 +08:00
14 lines
317 B
TypeScript
14 lines
317 B
TypeScript
import pLimit = require('p-limit');
|
|
|
|
const limit = pLimit<string | undefined>(1);
|
|
|
|
const input = [
|
|
limit(() => Promise.resolve('foo')),
|
|
limit(() => Promise.resolve('bar')),
|
|
limit(() => Promise.resolve(undefined)),
|
|
];
|
|
|
|
Promise.all(input).then(result => {
|
|
const str: string | undefined = result[0];
|
|
});
|