Deeply freeze/thaw a array or object
$ npm install @tiaanduplessis/freezo
# OR
$ yarn add @tiaanduplessis/freezo
import { freeze, thaw } from '@tiaanduplessis/freezo'
const frozenArr = freeze([1, 2, 3, { foo: 1, bar: 2 }, 5])
const frozenObj = freeze({ foo: 1, bar: 2, baz: { foo: 1, bar: 2 } })
console.log(Object.isFrozen(frozenArr)) // true
console.log(Object.isFrozen(frozenArr[3])) // true
console.log(Object.isFrozen(frozenObj)) // true
console.log(Object.isFrozen(frozenObj.baz)) // true
const unfrozenArr = thaw(frozenArr)
const unfrozenObj = thaw(frozenObj)
console.log(Object.isFrozen(unfrozenArr)) // false
console.log(Object.isFrozen(unfrozenArr[3])) // false
console.log(Object.isFrozen(unfrozenObj)) // false
console.log(Object.isFrozen(unfrozenObj.baz)) // false
Contributions are welcome!
git checkout -b my-new-feature
git commit -am 'Add some feature'
git push origin my-new-feature
Or open up a issue.
Licensed under the MIT License.