Skip to content
Myr

Added Collection#avg()

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

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

  • tests:+6 added−0 removed
  • other:+11 added−0 removed

2 files+17 added−0 removed

modified:lib/express/collection.js+11 added
383 unmodified lines
384 })385 },386 387 /**388 * Return the average of numeric values in this collection.389 *390 * @return {number}391 * @api public392 */393 394 avg: function() {395 return this.sum() / this.length()396 },397 398 /**399 * Merge _other_ with this collection.400 *401 * @param {mixed} other402 * @return {Collection}
59 unmodified lines
modified:spec/spec.collection.js+6 added
275 unmodified lines
276 $([1,2,3]).sum().should.eql 6277 end278 end279 280 describe '#avg()'281 it 'should return the average of numeric values'282 $([3,1]).avg().should.eql 2283 end284 end285 286 describe '#merge()'287 it 'should merge two array collections'288 var a = $([1,2,3])289 var b = $([4,5,6])
78 unmodified lines