azurite
Version:
An open source Azure Storage API compatible server
29 lines • 886 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const stream_1 = require("stream");
const zeroBytesRangeUnit = 512;
const zeroBytesChunk = Buffer.alloc(zeroBytesRangeUnit);
class ZeroBytesStream extends stream_1.Readable {
constructor(length, options) {
super(options);
this.length = length;
this.leftBytes = length;
}
_read(size) {
if (this.leftBytes === 0) {
this.push(null);
}
else if (this.leftBytes >= zeroBytesRangeUnit) {
this.leftBytes -= zeroBytesRangeUnit;
this.push(zeroBytesChunk);
}
else {
process.nextTick(() => {
this.push(Buffer.alloc(this.leftBytes));
this.leftBytes = 0;
});
}
}
}
exports.default = ZeroBytesStream;
//# sourceMappingURL=ZeroBytesStream.js.map
;