UNPKG

@tidyjs/tidy

Version:

Tidy up your data with JavaScript, inspired by dplyr and the tidyverse

20 lines (17 loc) 508 B
import { Adder, fsum } from 'd3-array'; function fcumsum(items, accessor) { let sum = new Adder(), i = 0; return Float64Array.from(items, (value) => sum.add(+(accessor(value, i++, items) || 0))); } function mean(items, accessor) { let n = 0; for (let i = 0; i < items.length; ++i) { const value = accessor(items[i], i, items); if (+value === value) { n += 1; } } return n ? fsum(items, accessor) / n : void 0; } export { fcumsum, mean }; //# sourceMappingURL=summation.js.map