UNPKG

node-web-mvc

Version:
24 lines (23 loc) 656 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const stream_1 = require("stream"); class ByteArrayInputStream extends stream_1.Readable { constructor(bytesArray, options) { super(options); this.bytesArray = bytesArray; this.pos = 0; } close() { this.bytesArray = null; } _read(size) { if (this.pos >= this.bytesArray.length) { this.push(null); return; } const chunk = this.bytesArray.slice(this.pos, this.pos + size); this.pos += chunk.length; this.push(chunk); } } exports.default = ByteArrayInputStream;