1
객체 스트림 (objectMode: true
)을 가지고 있으며 같은 크기의 배열로 청크하여 배열을 수용하는 다른 함수로 파이프 할 수 있습니다. 개체 스트림을 청크하는 방법?
- https://www.npmjs.com/package/block-stream
- https://www.npmjs.com/package/chunkit
- https://www.npmjs.com/package/chunking-streams
- https://www.npmjs.com/package/fixed-chunk-stream
- https://www.npmjs.com/package/chunk-stream 당신은 알고 계십니까 : 나는 개체에 대한 다음과 같은 버퍼 동안 그 작업을 수행하는 것 모듈,하지만 발견 객체 스트림에 대해이 작업을 수행 할 수있는 모듈 거기에는 분명히 간단한 DIY 솔루션이 있습니까?
objectStream.pipe(new ItemCollector(10)).pipe(otherFunction)
:
function ItemCollector (chunkSize) {
this._buffer = [];
this._chunkSize = chunkSize;
stream.Transform.call(this, { objectMode: true });
}
util.inherits(ItemCollector, stream.Transform);
ItemCollector.prototype._transform = function (chunk, encoding, done) {
if (this._buffer.length == this._chunkSize) {
this.push(this._buffer);
this._buffer = [];
}
this._buffer.push(chunk);
done();
};
ItemCollector.prototype._flush = function() {
this.push(this._buffer);
};
을 사용하여 다음과 같이 :