redis-smq-common
Version:
RedisSMQ Common Library provides many components that are mainly used by RedisSMQ and RedisSMQ Monitor.
29 lines • 890 B
JavaScript
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