Skip to content

Conversation

@melnikov-s
Copy link
Contributor

before:

_.size(0) //undefined
_.size(1) //0

after:

_.size(0) //0
_.size(1) //0

There are probably other methods that are broken for the value 0 but _.size is how I discovered the bug.

@jridgewell
Copy link
Collaborator

The only other affected method is _.shuffle:

_.shuffle(0) == [undefined];
_.shuffle(1) == [];

Do you mind adding a test for _.size(1) and the two shuffles as well?

@megawac
Copy link
Collaborator

megawac commented Feb 23, 2015

This test is sufficient and a good catch. Thanks @smelnikov!

megawac added a commit that referenced this pull request Feb 23, 2015
fixed isArrayLike returning true for 0
@megawac megawac merged commit 9ac45c6 into jashkenas:master Feb 23, 2015
@jridgewell
Copy link
Collaborator

Also found _.sample is affected:

_.sample(0, 1) == [undefined];
_.sample(1, 1) == []

@jashkenas: Mind cutting a 1.8.3 bugfix release?

@jashkenas
Copy link
Owner

Sure — but let's wait for a medium period of time before doing it. (Like, end of the week?) I'd imagine there are a number of minor things that can go in...

@jridgewell
Copy link
Collaborator

👍

@jridgewell jridgewell mentioned this pull request Mar 13, 2015
4 tasks
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.

4 participants