iammutable
v1.0.3
Published
Returns an Object.freeze
Downloads
5
Maintainers
Readme
I am mutable
But not.
const immutable = {}
const RealImmutable = require('iammutable')(immutable)
console.log(Object.isFrozen(RealImmutable))
If you want to use as a GLOBAL
, CAUTION!!!:
'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!
// iammutable.global.js
'use strict'
global.Immutable = (obj) => {
if(Object.isFrozen(obj)) return obj
return Object.freeze(obj)
}