object-array-utils
Advanced tools
+1
-1
| { | ||
| "name": "object-array-utils", | ||
| "version": "1.1.1", | ||
| "version": "1.1.2", | ||
| "description": "Utilities for working with arrays and objects", | ||
@@ -5,0 +5,0 @@ "scripts": { |
+3
-3
@@ -245,8 +245,8 @@ function isNullOrUndefined(v) { | ||
| function deepFreeze(o) { | ||
| if (!isObject(o)) { | ||
| throw new Error('expected object'); | ||
| if (!isObject(o) && !isArray(o)) { | ||
| throw new Error('expected object or array'); | ||
| } | ||
| Object.keys(o).forEach(prop => { | ||
| if (typeof o[prop] === 'object' && !Object.isFrozen(o[prop])) { | ||
| if ((!isObject(o[prop]) || !isArray(o[prop])) && !Object.isFrozen(o[prop])) { | ||
| deepFreeze(o[prop]); | ||
@@ -253,0 +253,0 @@ } |
@@ -1,2 +0,2 @@ | ||
| import { areArraysEqual, areObjectsEqual } from './index'; | ||
| import { areArraysEqual, areObjectsEqual, deepFreeze } from './index'; | ||
@@ -58,2 +58,4 @@ test('object equality', () => { | ||
| ).toBeTruthy(); | ||
| deepFreeze([1, { b: null, c: { d: [2, 5, 1, 0, {c: 3, d: 4}], e: "world" }, a: "foo" }]); | ||
| }); |
22646
0.64%253
0.4%