Merge pull request #5 from matthewrfindley/handle-null-values

Handle freezing with null values
This commit is contained in:
Aaron Jensen 2015-08-03 10:39:20 -07:00
commit cd0f588bdb
2 changed files with 8 additions and 0 deletions

View File

@ -1,4 +1,6 @@
function isFreezable(obj) {
if (obj === null) return false;
return Array.isArray(obj) ||
typeof obj === 'object';
}

View File

@ -50,4 +50,10 @@ describe('freeze', () => {
expect(Object.isFrozen(obj)).to.be.false;
});
it('handles null objects', () => {
const obj = { foo: null };
freeze(obj);
expect(Object.isFrozen(obj)).to.be.true;
});
});