Swap-Aggregator-Subgraph/node_modules/iso-random-stream/src/index.js
Richa-iitr d211083153 Revert "Revert "added handler""
This reverts commit c36ee8c5ca.
2022-07-03 07:30:05 +05:30

21 lines
524 B
JavaScript

'use strict';
const { Readable } = require('readable-stream');
const randomBytes = require('./random');
module.exports = (size = Infinity) => {
let currentSize = 0;
return new Readable({
read(readSize) {
if (currentSize >= size) {
return this.push(null);
} else if (currentSize + readSize >= size) {
readSize = size - currentSize;
}
currentSize += readSize;
this.push(randomBytes(readSize));
}
});
};