Nascent Prototype Metaverse
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

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

install

npm i iammutable

Downloadsweekly downloads

9

version

1.0.3

license

WTFPL

last publish

collaborators

  • avatar
Report a vulnerability