Deeply freeze/thaw a array or object
Built with ❤︎ by tiaanduplessis and contributors
$ 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!
- Fork it.
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Or open up a issue.
Licensed under the MIT License.