Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove reduce error throwing #1961

Merged
merged 1 commit into from
Dec 11, 2014

Conversation

jridgewell
Copy link
Collaborator

Closes #1858.

@@ -122,9 +122,6 @@
ok(_.reduce(null, _.noop, 138) === 138, 'handles a null (with initial value) properly');
equal(_.reduce([], _.noop, undefined), undefined, 'undefined can be passed as a special case');
equal(_.reduce([_], _.noop), _, 'collection of length one with no initial value returns the first item');

throws(function() { _.reduce([], _.noop); }, TypeError, 'throws an error for empty arrays with no initial value');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you update these tests to prove they don't throw

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, updated.

@jridgewell jridgewell force-pushed the remove-reduce-errors branch from 94b2961 to f1428a9 Compare December 4, 2014 19:35
@megawac megawac added this to the v2.0 milestone Dec 4, 2014
memo = obj[keys ? keys[--index] : --index];
}
while (index--) {
while (index-- > 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to never use the result of a postfix increment/decrement (or use them at all). Let's do while(--index >= 0).

@jashkenas jashkenas removed this from the v2.0 milestone Dec 11, 2014
@jridgewell jridgewell removed this from the v2.0 milestone Dec 11, 2014
jashkenas added a commit that referenced this pull request Dec 11, 2014
@jashkenas jashkenas merged commit 0160d00 into jashkenas:master Dec 11, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove error throwing in _.reduce & _.reduceRight.
4 participants