Don't freeze regexps (#65)
This commit is contained in:
parent
5bccf497ea
commit
cea10920cd
@ -1,5 +1,6 @@
|
||||
function isFreezable(object) {
|
||||
if (object === null) return false;
|
||||
if (object instanceof RegExp) return false;
|
||||
|
||||
return Array.isArray(object) ||
|
||||
typeof object === 'object';
|
||||
|
@ -35,6 +35,13 @@ describe('u.freeze', () => {
|
||||
expect(Object.isFrozen(object.foo)).to.be.false;
|
||||
});
|
||||
|
||||
it('ignores regexps', () => {
|
||||
const object = { foo: /\d/ };
|
||||
u.freeze(object);
|
||||
|
||||
expect(Object.isFrozen(object.foo)).to.be.false;
|
||||
});
|
||||
|
||||
it('does not freeze children if the parent is already frozen', () => {
|
||||
const object = { foo: {} };
|
||||
Object.freeze(object);
|
||||
|
Loading…
Reference in New Issue
Block a user