mirror of
https://github.com/Instadapp/Swap-Aggregator-Subgraph.git
synced 2024-07-29 21:57:12 +00:00
21 lines
524 B
JavaScript
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));
|
|
}
|
|
});
|
|
};
|