workerama
Version:
Run sync/async function across Worker Threads
25 lines (21 loc) • 602 B
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.asyncIterableFinally = void 0;
const asyncIterableFinally = (iterable, onFinally) => ({
async *[Symbol.asyncIterator]() {
try {
for await (const result of iterable) {
yield result;
}
} finally {
const finallyIterable = onFinally();
const iterator = finallyIterable[Symbol.asyncIterator]();
let result = await iterator.next();
while (result.done !== true) {
result = await iterator.next();
}
}
}
});
exports.asyncIterableFinally = asyncIterableFinally;