UNPKG

stream-mock

Version:
27 lines 898 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const stream_1 = require("stream"); const constant_1 = require("../constant"); const any2Buffer_1 = require("../helpers/converters/any2Buffer"); const warnOnce_1 = require("../helpers/warnOnce"); class ReadableMock extends stream_1.Readable { constructor(source, options = {}) { warnOnce_1.default(constant_1.WARNINGS.DEP_READABLE_MOCK); super(options); this.it = source[Symbol.iterator](); } _read(_size) { const next = this.it.next(); if (next.done) { this.push(null); } else if (this._readableState.objectMode) { this.push(next.value); } else { this.push(any2Buffer_1.any2Buffer(next.value, this.encoding)); } } } exports.default = ReadableMock; //# sourceMappingURL=ReadableMock.js.map