Skip to content
Myr

Collection#any() now uses V8s #some()

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by visionmedia · committed by visionmedia · parent 123b981 · Browse files · 2 files+7 added−14 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+7 added−14 removed

  • tests:+5 added−14 removed
  • other:+2 added−0 removed

2 files+7 added−14 removed

modified:lib/express/collection.js+2 added
202 unmodified lines
203 * @api public204 */205 206 any: function(fn) {207 if (this.arr.some)208 return this.arr.some(fn)209 return !! this.find(fn)210 },211 212 /**
84 unmodified lines
modified:spec/spec.collection.js+5 added-14 removed
119 unmodified lines
120 121 it 'should return false when not found'122 $(['foo', 'bar']).any(function(val){ return val.charAt(0) == 'r' }).should.be_false123 end124 125 it 'should work with objects'126 $({ foo: 'bar' }).any(function(val){ return val.charAt(0) == 'b' }).should.be_true127 $({ foo: 'bar' }).any(function(val){ return val.charAt(0) == 'c' }).should.be_false128 end129 end130 131 describe '#select()'132 it 'should return values which evaluate to true'
57 unmodified lines
190 $({ foo: 'bar', baz: 'raz' }).keys().at(1).should.eql 'baz'191 end192 end193 189 describe '#sort()'190 it 'should sort using a function'191 var result = $([4,2,3,1]).sort(function(n, other){192 return n < other ? -1 :193 n > other ? 1 :194 0195 })196 result.at(0).should.eql 1197 result.at(1).should.eql 2198 result.at(2).should.eql 3199 result.at(3).should.eql 4200 end201 end202 194 describe '#toArray()'195 it 'should return an array'196 $(['foo', 'bar']).keys().toArray().should.eql [0, 1]197 end
16 unmodified lines