_(keys) .map(service => data) .map((service, index) => _.set({}, keys[index], service)) .thru(services => _.reduce(services, (sum, service) => _.merge(sum, service), {})) .value()
const mapper = function mapper(rows) { const filter = function filter() { return _.reduce(rows, (prev, curr) => Math.max(prev, curr.eventLoop.high), 0); }; const maxDelay = filter(); return _.map(rows, (row) => ({ delay: Number(row.eventLoop.delay.toFixed(1)), high: Number(maxDelay.toFixed(1)) })); }
/* * Helper to determine files exists in an array of files */ const srcExists = (files = []) => _.reduce(files, (exists, file) => fs.existsSync(file) || exists, false)
_.reduce(timeElements, (prev, curr, index) => { switch (curr.units) { case "s": return `:${_.padStart(curr.value, DIGITS_PER_UNIT, "0")}`; case "m": case "h": if (index < timeElements.length - 1) { return (curr.units === "m" ? ":" : " ") + _.padStart(curr.value, DIGITS_PER_UNIT, "0") + prev; } return curr.value + prev; default: return curr.value + curr.units + prev; } }, "")
_.reduce(TIME_SCALES, (prev, timeScale, index) => { // the divisor grows with each time scale factor divisor *= timeScale.divisor; // if the time element is represented, multiply by current divisor if (timeElements[timeScale.units]) { // if there are more time scales to go, make sure the current value // does not exceed its limits (ex: 90s should be 1:30 instead) if (index < TIME_SCALES.length - 1) { if (timeElements[timeScale.units] >= TIME_SCALES[index + 1].divisor) { throw new Error("Enter a valid time value"); } } // continue to accumulate the time prev += timeElements[timeScale.units] * divisor; } return prev; }, 0)
= function setupAggregation() { this._aggregation = _.reduce(AGGREGATE_TIME_LEVELS, (prev, timeLevel) => { prev[timeLevel] = { data: [],
]; const updates = _.reduce( templates, (res, template) => {
_.reduce(data, (prev, detail) => Math.max(prev, detail.label.length), 0)
/** * Given a metric data object, construct an initialized average. * * @param {Object} data * The metric data received. * * @returns {Object} * The initialized average object is returned. */ const getInitializedAverage = function getInitializedAverage(data) { return _.reduce(data, (prev, a, dataKey) => { // create a first-level object of the key prev[dataKey] = {}; _.each(data[dataKey], (b, dataMetricKey) => { // the metrics are properties inside this object prev[dataKey][dataMetricKey] = 0; }); return prev; }, {}); }
return true; return _.reduce(filter, function(prev, value, prop) { if (!value) { return prev && _.has(component, prop);
function generateJunit(modules) { const xml = builder.create('testsuite', { headless: true }); xml.att('name', 'citgm'); _.reduce(modules, generateTest, xml); return xml.end({ pretty: true }); }
const getSmallestBoxartUrl = movie => _.reduce(movie.boxarts, (prev, curr) => { if (prev.width * prev.height < curr.width * curr.height) { return prev } else { return curr } }).url
_.reduce(this.pathObjects, function (newMatches, pathObject, index) { var isMatch = _.isArray(pathObject.regexp.exec(url)); if (isMatch) { newMatches.push({ index: index, segments: pathObject.path.split('/') }) } return newMatches; }, [])
get(key, defaultResponse) { let getObject; try { getObject = _.reduce(_.split(key, '.'), (o, i) => o[i], Cache.get('config')); } catch (ex) { _.noop(); } if (!_.isUndefined(getObject)) { return getObject; } return (!_.isUndefined(defaultResponse)) ? defaultResponse : undefined; }
function toPaths(arr) { return _.reduce( arr, function (memo, v) { memo[v] = true; return memo; }, {} ); }