Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return true;
};
/*
* Main execute code path
*/
try {
// Queue the leaf nodes that have no dependencies
plan.leaves.forEach(queueRun);
// Then wait for all promises to resolve
let pIdle = queue.onIdle();
if (opts.timeoutMs && opts.timeoutTime) {
const msg = `Deploy operation timed out after ${opts.timeoutMs / 1000} seconds`;
const timeLeft = opts.timeoutTime - Date.now();
if (timeLeft <= 0) throw new pTimeout.TimeoutError(msg);
pIdle = pTimeout(pIdle, timeLeft, msg);
}
await pIdle;
} catch (err) {
stopExecuting = true;
throw err;
}
}
import EventEmitter = require('eventemitter3');
import {default as pTimeout, TimeoutError} from 'p-timeout';
import {Queue} from './queue';
import PriorityQueue from './priority-queue';
import {QueueAddOptions, DefaultAddOptions, Options} from './options';
type ResolveFunction = (value?: T | PromiseLike) => void;
type Task =
| (() => PromiseLike)
| (() => TaskResultType);
const empty = (): void => {};
const timeoutError = new TimeoutError();
/**
Promise queue with concurrency control.
*/
export default class PQueue = PriorityQueue, EnqueueOptionsType extends QueueAddOptions = DefaultAddOptions> extends EventEmitter<'active'> {
private readonly _carryoverConcurrencyCount: boolean;
private readonly _isIntervalIgnored: boolean;
private _intervalCount = 0;
private readonly _intervalCap: number;
private readonly _interval: number;
private _intervalEnd = 0;