node package manager
Orgs are free. Discover, share, and reuse code in your team. Create a free org »

iammutable

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)
}