UNPKG

react-financial-charts

Version:
39 lines 1.15 kB
import { identity, merge, slidingWindow } from "../utils"; export default function () { let windowSize = 1; let accumulator = identity; let mergeAs = identity; const algorithm = (data) => { const defaultAlgorithm = slidingWindow() .windowSize(windowSize) .accumulator(accumulator); const calculator = merge() .algorithm(defaultAlgorithm) .merge(mergeAs); const newData = calculator(data); return newData; }; algorithm.accumulator = (newAccumulator) => { if (newAccumulator === undefined) { return accumulator; } accumulator = newAccumulator; return algorithm; }; algorithm.merge = (newMerge) => { if (merge === undefined) { return mergeAs; } mergeAs = newMerge; return algorithm; }; algorithm.windowSize = (newWindowSize) => { if (newWindowSize === undefined) { return windowSize; } windowSize = newWindowSize; return algorithm; }; return algorithm; } //# sourceMappingURL=index.js.map