UNPKG

@tidyjs/tidy

Version:

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

15 lines (12 loc) 447 B
import { fsum } from 'd3-array'; function sum(key, options) { let keyFn = typeof key === "function" ? key : (d) => d[key]; if (options == null ? void 0 : options.predicate) { const originalKeyFn = keyFn; const predicate = options.predicate; keyFn = (d, index, array) => predicate(d, index, array) ? originalKeyFn(d, index, array) : 0; } return (items) => fsum(items, keyFn); } export { sum }; //# sourceMappingURL=sum.js.map