An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          




freezo



Deeply freeze/thaw a array or object





npm package version


Codecov


npm downloads


standard JS linter


prettier code formatting


travis ci build status


project license


make a pull request






Github Watch Badge


Github Star Badge


Tweet





Built with ❤︎ by tiaanduplessis and contributors

Table of Contents

Table of Contents

  • Install

  • Usage

  • Contribute

  • License
  • ## 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.