Skip to content
Myr

Misc refactoring

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

authored by visionmedia · committed by visionmedia · parent 4101e4a · Browse files · 1 file+9 added−7 removed
This commit

State

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

Diff stats

1 file+9 added−7 removed

  • other:+9 added−7 removed

1 file+9 added−7 removed

modified:lib/express/collection.js+9 added-7 removed
12// Express - Collection - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)34// TODO: isArray()5// TODO: toArray() alias values() alias vals()5// TODO: v8 native merge?6// TODO: benchmarks78/**
144 unmodified lines
153 * @api public154 */155 156 first: function(n) {158 return n ? this.slice(0, n) : this.at(0)157 return n ? 158 this.slice(0, n) :159 this.at(0)160 },161 162 /**163 * Return the last _n_ value(s), defaults to -1.
4 unmodified lines
168 */169 170 last: function(n) {171 var len = this.length()171 return n ? this.slice(len-n, len) : this.at(--len)172 return n ? 173 this.slice(len - n, len) :174 this.at(--len)175 },176 177 /**178 * Drop the first _n_ values, returning the others.
119 unmodified lines
298 */299 300 toArray: function() {301 return this.reduce([], function(array, val){299 if (val instanceof Collection)300 array.push(val.toArray())301 else302 array.push(val)302 val instanceof Collection ?303 array.push(val.toArray()) :304 array.push(val)305 return array306 })307 },308
142 unmodified lines