https://github.com/tiaanduplessis/freezo
Deeply freeze/thaw a array or object
https://github.com/tiaanduplessis/freezo
array deep-freeze freeze object thaw unfreeze
Last synced: 2 months ago
JSON representation
Deeply freeze/thaw a array or object
- Host: GitHub
- URL: https://github.com/tiaanduplessis/freezo
- Owner: tiaanduplessis
- License: mit
- Created: 2017-07-12T11:31:10.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-06-02T22:39:32.000Z (over 6 years ago)
- Last Synced: 2025-07-28T17:52:02.113Z (3 months ago)
- Topics: array, deep-freeze, freeze, object, thaw, unfreeze
- Language: JavaScript
- Size: 42 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
freezo
Deeply freeze/thaw a array or object
Table of Contents
Table of Contents
## Install
```sh
$ npm install @tiaanduplessis/freezo
# OR
$ yarn add @tiaanduplessis/freezo
```
## Usage
```js
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
```
## Contributing
Contributions are welcome!
1. Fork it.
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D
Or open up [a issue](https://github.com/tiaanduplessis/freezo/issues).
## License
Licensed under the MIT License.