iammutable

1.0.3 • Public • Published

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

Package Sidebar

Install

npm i iammutable

Weekly Downloads

2

Version

1.0.3

License

WTFPL

Last publish

Collaborators

  • suissa