Refactoring

This commit is contained in:
Jerry Kurian
2019-08-16 09:02:54 -04:00
parent 505fefeeb5
commit faac6134af
48 changed files with 84 additions and 72 deletions

21
src/functions/unbatch.ts Normal file
View File

@@ -0,0 +1,21 @@
import { Transform } from "stream";
import { TransformOptions } from "./baseDefinitions";
/**
* Unbatches and sends individual chunks of data
*/
export function unbatch(
options: TransformOptions = {
readableObjectMode: true,
writableObjectMode: true,
},
) {
return new Transform({
...options,
transform(data, encoding, callback) {
for (const d of data) {
this.push(d);
}
callback();
},
});
}