baseDefinitions

This commit is contained in:
Jerry Kurian
2019-08-15 15:54:53 -04:00
parent 5a9fcc94a6
commit d6d974ee0d
16 changed files with 20 additions and 23 deletions

View File

@@ -1,15 +1,19 @@
import { Transform } from "stream";
import { AccumulatorByIteratee, FlushStrategy } from "./definitions";
import { TransformOptions } from "../baseDefinitions";
import { batch } from "../../index";
function _accumulator<T>(
accumulateBy: (data: T, buffer: T[], stream: Transform) => void,
shouldFlush: boolean = true,
options: TransformOptions = {
readableObjectMode: true,
writableObjectMode: true,
},
) {
const buffer: T[] = [];
return new Transform({
readableObjectMode: true,
writableObjectMode: true,
...options,
transform(data: any, encoding, callback) {
try {
accumulateBy(data, buffer, this);