nm_.reduce(nm_.keys(this._changes), function(memo, column) { if (self._changes[column].op['$set']) { memo.push(column); } return memo; }, [])
var unifyType = function (value) { if (_.isArray (value)) { return _.nonempty ([_.reduce (value.slice (1), function (a, b) { return _.undiff (a, b) }, _.first (value) || undefined)]) } else if (_.isStrictlyObject (value)) { var pairs = _.pairs (value) var unite = _.map ( _.reduce (pairs.slice (1), function (a, b) { return _.undiff (a, b) }, _.first (pairs) || [undefined, undefined]), _.nonempty) return (_.isEmpty (unite) || _.isEmpty (unite[1])) ? value : _.fromPairs ([[unite[0] || '*', unite[1]]]) } else { return value } }
/** * Filter frames that need an update * @returns {Promise} */ syncInit() { this.sync.frames = new FrameCollection(this.config); // filter out frames, that don't need an update this.sync.frames.filter(frame => !(Math.ceil(frame.duration) === _.reduce(frame.notes, (n, m) => (n + m.time), 0))); return new Promise(r => r()); }
ChildView.extend({ tagName: 'tr', render: function() { var tr = _.reduce(this.model.toJSON(), function(tr, attr){ return tr += '<td>' + attr + '</td>' }, '') this.el.innerHTML = tr } })
test("functions", function() { var obj = {a : 'dash', b : _.map, c : (/yo/), d : _.reduce}; ok(_.isEqual(['b', 'd'], _.functions(obj)), 'can grab the function names of any passed-in object'); var Animal = function(){}; Animal.prototype.run = function(){}; equal(_.functions(new Animal).join(''), 'run', 'also looks up functions on the prototype'); });
syncUpdate(callback) { return this.sync.frames.forEach((frame, done) => { let time = frame.duration, project = frame.project, type = frame.resource.type, id = frame.resource.id; if (frame.notes.length > 0) time = Math.ceil(frame.duration) - parseInt(_.reduce(frame.notes, (n, m) => (n + m.time), 0)); this._addTime(frame, time) .then(() => { if (callback) callback(); done(); }) .catch(error => done(`Could not update ${type} ${id} on ${project}`)) }); }
var arrayAverage = (arr) => { return _.reduce(arr, (num1, num2) => { return num1 + num2; }, 0) / (arr.length === 0 ? 1 : arr.length); }
$static (function (arr) { return _.reduce ((_.isArray (arr) && arr) || _.asArray (arguments), function (memo, v) { return memo.add (v || Vec2.zero) }, Vec2.zero) })
_.reduce (rows.slice (1), (memo, row) => _.times (Math.max ((memo && memo.length) || 0, (row && row.length) || 0), i => zippo (memo && memo[i], row && row[i])), rows[0])
Backbone.View.extend({ tagName: 'tr', initialize: function() { this.render({}) }, render: function(data) { var tr = _.reduce(data, function(tr, attr){ return tr += '<th>' + attr + '</th>' }, '') this.el.innerHTML = tr } })
let childrenState = _.reduce(this.childrenById, (memo, child) => { memo[child.getId()] = child.getState() == 'ready';
nm_.reduce(validators, function(memo, validator) { if (!validator.validator.call(self, value, instance)) { memo.push(validator); } return memo; }, [])
test('reduce', function() { var sum = _.reduce([1, 2, 3], function(sum, num){ return sum + num; }, 0); equal(sum, 6, 'can sum up an array'); sum = _.reduce([1, 2, 3], function(sum, num){ return sum + num * this.multiplier; }, 0, context); equal(sum, 18, 'can reduce with a context object'); equal(sum, 6, 'aliased as "inject"'); sum = _([1, 2, 3]).reduce(function(sum, num){ return sum + num; }, 0); equal(sum, 6, 'OO-style reduce'); var sum = _.reduce([1, 2, 3], function(sum, num){ return sum + num; }); equal(sum, 6, 'default initial value'); var prod = _.reduce([1, 2, 3, 4], function(prod, num){ return prod * num; }); equal(prod, 24, 'can reduce via multiplication'); _.reduce(null, function(){}); } catch (ex) { ifnull = ex; ok(_.reduce(null, function(){}, 138) === 138, 'handles a null (with initial value) properly'); equal(_.reduce([], function(){}, undefined), undefined, 'undefined can be passed as a special case'); raises(function() { _.reduce([], function(){}); }, TypeError, 'throws an error for empty arrays with no initial value'); });
_.reduce(pairs, function(o, pair) { return f.merge(pair, o); }, {})
nm_.reduce(sanitizers, function(value, sanitizer) { return sanitizer(value, instance); }, value)