UNPKG

memstreams

Version:

Memory Streams library for JavaScript based on readable-stream

28 lines 919 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BufferReader = void 0; const readable_stream_1 = require("readable-stream"); const utils_1 = require("./utils"); class BufferReader extends readable_stream_1.Readable { constructor(source, options = {}) { options.objectMode = false; super(options); this.init(source, options); } init(source, options = {}) { this.it = source === null || source === void 0 ? void 0 : source[Symbol.iterator](); } _read() { if (this.it) { const next = this.it.next(); if (next.done) { this.push(null); } else { return this.push((0, utils_1.any2buf)(next.value, this._readableState.encoding || 'utf8')); } } } } exports.BufferReader = BufferReader; //# sourceMappingURL=buffer-reader.js.map