Handle freezing with null values
This commit is contained in:
parent
6d3c4ae04a
commit
2f110e5a23
@ -1,4 +1,6 @@
|
||||
function isFreezable(obj) {
|
||||
if (obj === null) return false;
|
||||
|
||||
return Array.isArray(obj) ||
|
||||
typeof obj === 'object';
|
||||
}
|
||||
|
@ -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;
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user