Skip to content

Commit

Permalink
fixed assignemt error (handle function type)
Browse files Browse the repository at this point in the history
  • Loading branch information
alykoshin committed Mar 24, 2016
1 parent 0c103ef commit 7eb1254
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
5 changes: 4 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ var _assign = function(target, source) {
) {
target[nextKey] = s;

} else if (typeof s === 'function') {
target[nextKey] = s;

} else if (s instanceof Date) {
target[nextKey] = new Date(s.getTime());

Expand Down Expand Up @@ -58,7 +61,7 @@ var _assign = function(target, source) {
//}

} else { // unknown type....
throw new Error('Assignment error: source: \''+JSON.stringify(s)+', typeof source: \''+(typeof source)+'\'');
throw new Error('Assignment error, nextKey: '+nextKey+', typeof source[ nextKey ]: '+(typeof source[ nextKey ]));
}
}
}
Expand Down
16 changes: 0 additions & 16 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,6 @@ var deepCopy = require('../');

describe('mini-deep-assign', function () {

before('before', function () {

});

beforeEach('beforeEach', function () {

});

afterEach('afterEach', function () {

});

after('after', function () {

});

it('should keep type for top-level properties', function () {
var source = {
null: null,
Expand Down

0 comments on commit 7eb1254

Please sign in to comment.