项目作者: tiaanduplessis

项目描述 :
Deeply freeze/thaw a array or object
高级语言: JavaScript
项目地址: git://github.com/tiaanduplessis/freezo.git
创建时间: 2017-07-12T11:31:10Z
项目社区:https://github.com/tiaanduplessis/freezo

开源协议:MIT License

下载





freezo



Deeply freeze/thaw a array or object










Built with ❤︎ by tiaanduplessis and contributors

Table of Contents


Table of Contents
  • Install

  • Usage

  • Contribute

  • License

  • Install

    1. $ npm install @tiaanduplessis/freezo
    2. # OR
    3. $ yarn add @tiaanduplessis/freezo

    Usage

    1. import { freeze, thaw } from '@tiaanduplessis/freezo'
    2. const frozenArr = freeze([1, 2, 3, { foo: 1, bar: 2 }, 5])
    3. const frozenObj = freeze({ foo: 1, bar: 2, baz: { foo: 1, bar: 2 } })
    4. console.log(Object.isFrozen(frozenArr)) // true
    5. console.log(Object.isFrozen(frozenArr[3])) // true
    6. console.log(Object.isFrozen(frozenObj)) // true
    7. console.log(Object.isFrozen(frozenObj.baz)) // true
    8. const unfrozenArr = thaw(frozenArr)
    9. const unfrozenObj = thaw(frozenObj)
    10. console.log(Object.isFrozen(unfrozenArr)) // false
    11. console.log(Object.isFrozen(unfrozenArr[3])) // false
    12. console.log(Object.isFrozen(unfrozenObj)) // false
    13. 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.

    License

    Licensed under the MIT License.