[Pkg-javascript-commits] [backbone] 27/173: Allow to make reduce without initial value
Jonas Smedegaard
dr at jones.dk
Wed Aug 31 07:43:58 UTC 2016
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository backbone.
commit 345dd7b12828bfd12dbc8c3b3d062742ccbafa44
Author: just-boris <just-boris at hotmail.com>
Date: Tue Sep 29 01:42:15 2015 +0300
Allow to make reduce without initial value
---
backbone.js | 3 +++
test/collection.js | 4 +++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/backbone.js b/backbone.js
index bbc63fd..99e5a15 100644
--- a/backbone.js
+++ b/backbone.js
@@ -87,6 +87,9 @@
return _[method](this[attribute], cb(iteratee, this), context);
};
case 4: return function(iteratee, defaultVal, context) {
+ if(arguments.length < 2) {
+ return _[method](this[attribute], cb(iteratee, this));
+ }
return _[method](this[attribute], cb(iteratee, this), defaultVal, context);
};
default: return function() {
diff --git a/test/collection.js b/test/collection.js
index eb00fe1..36c0056 100644
--- a/test/collection.js
+++ b/test/collection.js
@@ -670,10 +670,12 @@
});
QUnit.test("Underscore methods", function(assert) {
- assert.expect(19);
+ assert.expect(21);
assert.equal(col.map(function(model){ return model.get('label'); }).join(' '), 'a b c d');
assert.equal(col.some(function(model){ return model.id === 100; }), false);
assert.equal(col.some(function(model){ return model.id === 0; }), true);
+ assert.equal(col.reduce(function(a, b) {return a.id > b.id ? a : b}).id, 3);
+ assert.equal(col.reduceRight(function(a, b) {return a.id > b.id ? a : b}).id, 3);
assert.equal(col.indexOf(b), 1);
assert.equal(col.size(), 4);
assert.equal(col.rest().length, 3);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/backbone.git
More information about the Pkg-javascript-commits
mailing list