How to use the p-timeout.default function in p-timeout

To help you get started, we’ve selected a few p-timeout examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sindresorhus / p-queue / source / index.ts View on Github external
const run = async (): Promise => {
				this._pendingCount++;
				this._intervalCount++;

				try {
					const operation = (this._timeout === undefined && options.timeout === undefined) ? fn() : pTimeout(
						Promise.resolve(fn()),
						(options.timeout === undefined ? this._timeout : options.timeout) as number,
						() => {
							if (options.throwOnTimeout === undefined ? this._throwOnTimeout : options.throwOnTimeout) {
								reject(timeoutError);
							}

							return undefined;
						}
					);
					resolve(await operation);
				} catch (error) {
					reject(error);
				}

				this._next();

p-timeout

Timeout a promise after a specified amount of time

MIT
Latest version published 2 months ago

Package Health Score

80 / 100
Full package analysis