unclechu / node-deep-extend

Recursive extend module
MIT License
202 stars 53 forks source link

Add support for Buffer values, and unit tests to prove it works #7

Closed rprieto closed 10 years ago

rprieto commented 10 years ago

This adds support for objects with Buffer values, for example:

var a = { hello: 1 };
var b = { value: new Buffer('world') };
extend(a, b);

I also added unit tests to show it works:

$ npm install
$ npm test

    ✓ can extend on 1 level
    ✓ can extend on 2 levels
    ✓ can extend with Buffer values
unclechu commented 10 years ago

Thanks a lot for contributing!

rprieto commented 10 years ago

No problem!

unclechu commented 10 years ago

I found an issue with Buffer. I added test for demonstrate this:

  it('Buffer is cloned', function () {
    var a = { };
    var b = { value: new Buffer('foo') };
    extend(a, b);
    a.value.write('bar');
    b.value.toString().should.eql('foo');
  });

https://github.com/unclechu/node-deep-extend/blob/master/test/index.spec.js

unclechu commented 10 years ago

This issue is fixed now: https://github.com/unclechu/node-deep-extend/commit/d8f59706d9a8a8d12493797d65ee37d12e9f662c