parent
731c43e507
commit
7a84944f99
@ -1,6 +1,7 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
## [unreleased]
|
## [unreleased]
|
||||||
|
* Add `u.freeze` to freeze an object deeply. (https://github.com/substantial/updeep/issues/7)
|
||||||
|
|
||||||
## [0.2.3]
|
## [0.2.3]
|
||||||
* Fix cannot update value to null (https://github.com/substantial/updeep/issues/8)
|
* Fix cannot update value to null (https://github.com/substantial/updeep/issues/8)
|
||||||
|
11
lib/index.js
11
lib/index.js
@ -9,10 +9,11 @@ function updateAndFreeze(updates, obj) {
|
|||||||
return freeze(update(updates, obj));
|
return freeze(update(updates, obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
const curried = curry(updateAndFreeze);
|
const updeep = curry(updateAndFreeze);
|
||||||
|
|
||||||
curried.omit = omit;
|
updeep.omit = omit;
|
||||||
curried.reject = reject;
|
updeep.reject = reject;
|
||||||
curried.withDefault = withDefault;
|
updeep.withDefault = withDefault;
|
||||||
|
updeep.freeze = freeze;
|
||||||
|
|
||||||
export default curried;
|
export default updeep;
|
||||||
|
@ -56,4 +56,10 @@ describe('freeze', () => {
|
|||||||
freeze(obj);
|
freeze(obj);
|
||||||
expect(Object.isFrozen(obj)).to.be.true;
|
expect(Object.isFrozen(obj)).to.be.true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('returns the same object', () => {
|
||||||
|
const obj = {};
|
||||||
|
const result = freeze(obj);
|
||||||
|
expect(result).to.equal(obj);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -113,4 +113,10 @@ describe('updeep', () => {
|
|||||||
it('assigns null values', () => {
|
it('assigns null values', () => {
|
||||||
expect(u({isNull: null}, {})).to.eql({isNull: null});
|
expect(u({isNull: null}, {})).to.eql({isNull: null});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('has additional functions', () => {
|
||||||
|
expect(u.freeze).to.be.a('function');
|
||||||
|
expect(u.omit).to.be.a('function');
|
||||||
|
expect(u.withDefault).to.be.a('function');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user