@tidyjs/tidy
Version:
Tidy up your data with JavaScript, inspired by dplyr and the tidyverse
19 lines (14 loc) • 539 B
JavaScript
Object.defineProperty(exports, '__esModule', { value: true });
var d3Array = require('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) => d3Array.fsum(items, keyFn);
}
exports.sum = sum;
//# sourceMappingURL=sum.js.map
;