From 7a84944f99261d7d3ebda92f858cd31074a88ecc Mon Sep 17 00:00:00 2001 From: Aaron Jensen Date: Tue, 4 Aug 2015 21:56:01 -0700 Subject: [PATCH] Add u.freeze Fixes #7 --- CHANGELOG.md | 1 + lib/index.js | 11 ++++++----- test/freeze.js | 6 ++++++ test/index.js | 6 ++++++ 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa3bc72..419bf18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/lib/index.js b/lib/index.js index b824fbb..2db718f 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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; diff --git a/test/freeze.js b/test/freeze.js index 91c4d5f..6c89d22 100644 --- a/test/freeze.js +++ b/test/freeze.js @@ -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); + }); }); diff --git a/test/index.js b/test/index.js index 37e2bb9..c8a4619 100644 --- a/test/index.js +++ b/test/index.js @@ -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'); + }); });