mirror of
https://github.com/arnaucube/circom.git
synced 2026-02-07 11:16:42 +01:00
22 lines
449 B
JavaScript
22 lines
449 B
JavaScript
|
|
const Readable = require("stream").Readable;
|
|
|
|
module.exports = function streamFromArrayBin(a) {
|
|
const rs = Readable();
|
|
|
|
let curIndex = 0;
|
|
|
|
rs._read = function(size) {
|
|
if (curIndex >= a.length) {
|
|
rs.push(null);
|
|
return;
|
|
}
|
|
const start = curIndex;
|
|
const end = Math.min(a.length, curIndex+size);
|
|
curIndex = end;
|
|
rs.push(a.slice(start, end));
|
|
};
|
|
|
|
return rs;
|
|
};
|