UNPKG

stream-mock

Version:
25 lines 880 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const stream_1 = require("stream"); const constant_1 = require("../constant"); const helpers_1 = require("../helpers"); const warnOnce_1 = require("../helpers/warnOnce"); class WritableMock extends stream_1.Writable { constructor(options = {}) { warnOnce_1.default(constant_1.WARNINGS.DEP_WRITABLE_MOCK); super(options); this.data = []; } _write(chunk, encoding, callback) { this.data.push(this._writableState.objectMode ? chunk : helpers_1.chunk2Buffer({ chunk, encoding })); callback(); } _final(callback) { this.flatData = this._writableState.objectMode ? [].concat(...this.data) : Buffer.concat(this.data); callback(); } } exports.default = WritableMock; //# sourceMappingURL=WritableMock.js.map