Skip to content
Myr

Added Collection#clone()

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

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

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

2 files+27 added−0 removed

modified:lib/express/collection.js+11 added
375 unmodified lines
376 return $(process.mixin(this.arr, $(other).arr))377 },378 379 /**380 * Clone the collection.381 *382 * @return {Collection}383 * @api public384 */385 386 clone: function() {387 return this.merge({})388 },389 390 /**391 * Convert collection to a string.392 *393 * @return {string}394 * @api public
19 unmodified lines
modified:spec/spec.collection.js+16 added
294 unmodified lines
295 a.merge(b).arr.should.eql { a: 'b', c: 'd', 0: 1, 1: 2 }296 end297 end298 299 describe '#clone()'300 it 'should clone an array collection'301 var a = $([1,2,3])302 var b = a.clone()303 a.should.not.equal b304 b.arr.should.eql [1,2,3]305 end306 307 it 'should clone an object collection'308 var a = $({ foo: 'bar' })309 var b = a.clone()310 a.should.not.equal b311 b.arr.should.eql { foo: 'bar' }312 end313 end314 315 describe '#toString()'316 it 'should output [Collection ...] for array'317 $([1,2,3]).toString().should.eql '[Collection 1,2,3]'318 end
12 unmodified lines