Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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();