1.0.3 • Published 8 years ago

iammutable v1.0.3

Weekly downloads
-
License
WTFPL
Repository
-
Last release
8 years ago

I am mutable

But not.

npm.io

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