Skip to content
Myr

Added Collection#length()

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

authored by visionmedia · committed by visionmedia · parent 4eee822 · Browse files · 2 files+23 added−0 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+23 added−0 removed

  • tests:+10 added−0 removed
  • other:+13 added−0 removed

2 files+23 added−0 removed

modified:lib/express/collection.js+13 added
321 unmodified lines
322 chunks.push($(chunk)),323 chunk = []324 })325 return $(chunks)326 },327 328 /**329 * Return the length of this collection.330 *331 * @return {int}332 * @api public333 */334 335 length: function() {336 return this.reduce(0, function(len){337 return ++len338 })339 }340})341342/**
11 unmodified lines
modified:spec/spec.collection.js+10 added
229 unmodified lines
230 $([3,5,2,3,43,2]).max().should.eql 43231 end232 end233 234 describe '#length()'235 it 'should work with arrays'236 $([1,2,3]).length().should.eql 3237 end238 239 it 'should work with objects'240 $({ a: 'b', c: 'd', e: 'f' }).length().should.eql 3241 end242 end243 244 describe '#chunk()'245 it 'should group into chunks of the given size'246 $([1,1,2,2,3,3]).chunk(2).toArray().should.eql [[1,1],[2,2],[3,3]]247 $([1,1,2,2,3,3]).chunk(4).toArray().should.eql [[1,1,2,2],[3,3]]
5 unmodified lines