UNPKG

azurite

Version:

An open source Azure Storage API compatible server

29 lines 868 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const stream_1 = require("stream"); class BufferStream extends stream_1.Readable { constructor(buffer, options) { super(options); this.buffer = buffer; this.offset = 0; this.chunkSize = 64 * 1024; this.bufferSize = buffer.length; } _read() { while (this.push(this._readNextChunk())) { continue; } } _readNextChunk() { let data = null; if (this.offset < this.bufferSize) { let end = this.offset + this.chunkSize; end = end > this.bufferSize ? this.bufferSize : end; data = this.buffer.slice(this.offset, end); this.offset = end; } return data; } } exports.default = BufferStream; //# sourceMappingURL=BufferStream.js.map