object-loops
Advanced tools
Comparing version 0.3.0 to 0.3.1
{ | ||
"name": "object-loops", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Functional methods like forEach, map, filter, and other ES5 Array methods for Objects in javascript", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -20,3 +20,5 @@ 'use strict'; | ||
if (Array.isArray(obj)) { | ||
return obj.reduce(callback, initialValue); | ||
return (arguments.length > 2) ? | ||
obj.reduce(callback, initialValue) : | ||
obj.reduce(callback); | ||
} | ||
@@ -23,0 +25,0 @@ if (!isObject(obj)) { |
@@ -148,9 +148,17 @@ var Code = require('code'); | ||
var callback = sum; | ||
expect(reduce(arr, callback, arr)) | ||
.to.equal(arr.reduce(callback, arr)); | ||
sinon.assert.calledWith(Array.prototype.reduce, callback, arr); | ||
expect(reduce(arr, callback, 20)) | ||
.to.equal(arr.reduce(callback, 20)); | ||
sinon.assert.calledWith(Array.prototype.reduce, callback, 20); | ||
done(); | ||
}); | ||
it('should use array reduce w/out initialValue', function (done) { | ||
var arr = [1,2,3]; | ||
var callback = sum; | ||
expect(reduce(arr, callback)) | ||
.to.equal(arr.reduce(callback)); | ||
sinon.assert.calledWith(Array.prototype.reduce, callback); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42188
1067