montagejs / collections

This package contains JavaScript implementations of common data structures with idiomatic interfaces.
http://www.collectionsjs.com
Other
2.09k stars 185 forks source link

.some and .every return last value of callback, instead of true or false #96

Open Stuk opened 10 years ago

Stuk commented 10 years ago
new List([1]).some(function () { return "hello" });

should return true, but returns "hello"

kriskowal commented 10 years ago

This may be a valid behavior. The returned value will always be truthy, and may incidentally be useful.

On Tue, Sep 16, 2014 at 9:19 PM, Stuart Knightley notifications@github.com wrote:

new List([1]).some(function () { return "hello" });

should return true, but returns "hello"

— Reply to this email directly or view it on GitHub https://github.com/montagejs/collections/issues/96.

Stuk commented 10 years ago

While true (heh), it's not the behaviour of [].some and [].every

kriskowal commented 10 years ago

Ah, precedent trumps. Good point.

On Wed, Sep 17, 2014 at 9:04 AM, Stuart Knightley notifications@github.com wrote:

While true (heh), it's not the behaviour of [].some and [].every

— Reply to this email directly or view it on GitHub https://github.com/montagejs/collections/issues/96#issuecomment-55917048 .