UNPKG

@tidyjs/tidy

Version:

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

26 lines (21 loc) 934 B
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var math = require('../math/math.js'); function rate(numerator, denominator, options) { const numeratorFn = typeof numerator === "function" ? numerator : (d) => d[numerator]; const denominatorFn = typeof denominator === "function" ? denominator : (d) => d[denominator]; const {predicate, allowDivideByZero} = options != null ? options : {}; return predicate == null ? (d, index, array) => { const denom = denominatorFn(d, index, array); const numer = numeratorFn(d, index, array); return math.rate(numer, denom, allowDivideByZero); } : (d, index, array) => { if (!predicate(d, index, array)) return void 0; const denom = denominatorFn(d, index, array); const numer = numeratorFn(d, index, array); return math.rate(numer, denom, allowDivideByZero); }; } exports.rate = rate; //# sourceMappingURL=rate.js.map