tar
Version:
tar for JavaScript
22 lines • 694 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.toStream = void 0;
/**
* Make a stream of the chunks of an iterator. It asks the iterator
* for a chunk only when a consumer reads the stream. A cancel of the
* stream calls `return()` of the iterator.
*/
const toStream = (chunks) => new ReadableStream({
pull: async (controller) => {
const res = await chunks.next();
if (res.done)
controller.close();
else
controller.enqueue(res.value);
},
cancel: async () => {
await chunks.return?.();
},
}, { highWaterMark: 0 });
exports.toStream = toStream;
//# sourceMappingURL=to-stream.js.map