UNPKG

redis-smq-common

Version:

RedisSMQ Common Library provides many components that are mainly used by RedisSMQ and RedisSMQ Monitor.

33 lines 995 B
export function parallel(operations, callback) { if (operations.length === 0) { return callback(null, []); } let completed = 0; let failed = false; const results = new Array(operations.length); operations.forEach((operation, index) => { try { operation((err, result) => { if (failed) return; if (err) { failed = true; return callback(err); } results[index] = result; completed++; if (completed === operations.length) { return callback(null, results); } }); } catch (error) { if (failed) return; failed = true; const err = error instanceof Error ? error : new Error(String(error)); return callback(err); } }); } //# sourceMappingURL=parallel.js.map