Add sliding, rolling functions with tests

This commit is contained in:
Jerry Kurian
2019-08-09 17:13:48 -04:00
parent c1ef5fec4b
commit fdcc5bafc6
4 changed files with 222 additions and 151 deletions

View File

@@ -3,8 +3,6 @@ import { ChildProcess } from "child_process";
import * as baseFunctions from "./functions";
import {
AccumulatorOptions,
FlushStrategy,
ThroughOptions,
TransformOptions,
WithEncoding,
@@ -248,9 +246,16 @@ export function parallelMap<T, R>(
return baseFunctions.parallelMap(mapper, parallel, sleepTime);
}
export function accumulator<T, R, S extends FlushStrategy>(
flushStrategy: S,
options: AccumulatorOptions<T, R, S>,
export function accumulator(
batchSize: number,
batchRate: number,
flushStrategy: "sliding" | "rolling",
keyBy?: string,
) {
return baseFunctions.accumulator(flushStrategy, options);
return baseFunctions.accumulator(
batchSize,
batchRate,
flushStrategy,
keyBy,
);
}