mirror of
https://github.com/barkeser2002/anonfilestr.git
synced 2026-09-25 03:49:56 +03:00
16 lines
414 B
JavaScript
16 lines
414 B
JavaScript
import { Transform } from "stream";
|
|
|
|
// https://github.com/forscht/ddrive/blob/3.x/src/utils/asyncStreamProcessor.js
|
|
export class AsyncStreamProcessor extends Transform {
|
|
constructor(chunkProcessor) {
|
|
super();
|
|
this.chunkProcessor = chunkProcessor;
|
|
}
|
|
|
|
_transform(chunk, encoding, callback) {
|
|
this.chunkProcessor(chunk)
|
|
.then(() => callback(null))
|
|
.catch((err) => callback(err));
|
|
}
|
|
}
|