Add u.freeze

Fixes #7
This commit is contained in:
Aaron Jensen 2015-08-04 21:56:01 -07:00
parent 731c43e507
commit 7a84944f99
4 changed files with 19 additions and 5 deletions

View File

@ -1,6 +1,7 @@
# Change Log
## [unreleased]
* Add `u.freeze` to freeze an object deeply. (https://github.com/substantial/updeep/issues/7)
## [0.2.3]
* Fix cannot update value to null (https://github.com/substantial/updeep/issues/8)

View File

@ -9,10 +9,11 @@ function updateAndFreeze(updates, obj) {
return freeze(update(updates, obj));
}
const curried = curry(updateAndFreeze);
const updeep = curry(updateAndFreeze);
curried.omit = omit;
curried.reject = reject;
curried.withDefault = withDefault;
updeep.omit = omit;
updeep.reject = reject;
updeep.withDefault = withDefault;
updeep.freeze = freeze;
export default curried;
export default updeep;

View File

@ -56,4 +56,10 @@ describe('freeze', () => {
freeze(obj);
expect(Object.isFrozen(obj)).to.be.true;
});
it('returns the same object', () => {
const obj = {};
const result = freeze(obj);
expect(result).to.equal(obj);
});
});

View File

@ -113,4 +113,10 @@ describe('updeep', () => {
it('assigns null values', () => {
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');
});
});