UNPKG

redis-smq-common

Version:

Provides essential components and utilities shared across RedisSMQ packages.

29 lines 890 B
export function series(operations, callback) { if (operations.length === 0) { return callback(null, []); } let currentIndex = 0; const results = new Array(operations.length); const executeNext = () => { if (currentIndex >= operations.length) { return callback(null, results); } const operation = operations[currentIndex]; try { operation((err, result) => { if (err) { return callback(err); } results[currentIndex] = result; currentIndex++; setImmediate(executeNext); }); } catch (error) { const err = error instanceof Error ? error : new Error(String(error)); return callback(err); } }; executeNext(); } //# sourceMappingURL=series.js.map