@tiaanduplessis/freezo
v1.0.0
Published
Deeply freeze/thaw a array or object
Downloads
1
Readme
Install
$ npm install freezo
# OR
$ yarn add freezo
Usage
import { freeze, thaw } from '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
Contributing
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.
License
Licensed under the MIT License.