Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/suissa/iammutable
But not.
https://github.com/suissa/iammutable
Last synced: about 1 month ago
JSON representation
But not.
- Host: GitHub
- URL: https://github.com/suissa/iammutable
- Owner: suissa
- Created: 2016-07-18T15:00:05.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-08-07T16:41:49.000Z (over 8 years ago)
- Last Synced: 2024-10-30T01:46:36.688Z (3 months ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# I am mutable
But not.
![](https://abhirockzz.files.wordpress.com/2014/01/immutable-defined.png)
```js
const immutable = {}
const RealImmutable = require('iammutable')(immutable)
console.log(Object.isFrozen(RealImmutable))
```If you want to use as a `GLOBAL`, **CAUTION!!!**:
```js
'use strict'
// Not a good practice
require('./iammutable.global')const immutable = {
name: 'Webschool',
sayName: (name) => 'Nome: ' + name
}
const RealImmutable = Immutable(immutable)
console.log(Object.isFrozen(RealImmutable))RealImmutable.test = true
```Now you have `Immutable()` as a **global function**!
```js
// iammutable.global.js
'use strict'global.Immutable = (obj) => {
if(Object.isFrozen(obj)) return obj
return Object.freeze(obj)
}
```