parent
0d0c56bb61
commit
d2d0703ef1
@ -1,6 +1,7 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
## [unreleased]
|
## [unreleased]
|
||||||
|
* Fix support for Date objects and other non-plain objects (https://github.com/substantial/updeep/issues/36)
|
||||||
|
|
||||||
## [0.10.0]
|
## [0.10.0]
|
||||||
* Add support for wildcards (`*`) to `u.updateIn`. (https://github.com/substantial/updeep/issues/27)
|
* Add support for wildcards (`*`) to `u.updateIn`. (https://github.com/substantial/updeep/issues/27)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import wrap from './wrap';
|
import wrap from './wrap';
|
||||||
import isEmpty from './util/isEmpty';
|
import isEmpty from './util/isEmpty';
|
||||||
import defaultObject from './util/defaultObject';
|
import defaultObject from './util/defaultObject';
|
||||||
|
import isPlainObject from 'lodash/lang/isPlainObject';
|
||||||
|
|
||||||
function reduce(object, callback, initialValue) {
|
function reduce(object, callback, initialValue) {
|
||||||
return Object.keys(object).reduce((acc, key) => {
|
return Object.keys(object).reduce((acc, key) => {
|
||||||
@ -58,7 +59,7 @@ function update(updates, object, ...args) {
|
|||||||
return updates(object, ...args);
|
return updates(object, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updates === null || typeof updates !== 'object') {
|
if (!isPlainObject(updates)) {
|
||||||
return updates;
|
return updates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,4 +146,10 @@ describe('updeep', () => {
|
|||||||
const result = u({ a: {} }, {});
|
const result = u({ a: {} }, {});
|
||||||
expect(result).to.eql({ a: {} });
|
expect(result).to.eql({ a: {} });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('works with date objects', () => {
|
||||||
|
const date = new Date();
|
||||||
|
const result = u({ created: date }, {});
|
||||||
|
expect(result).to.eql({ created: date });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user