imut
v1.0.0
Published
This is a lib to make any object imutable
Downloads
7
Readme
imut
This is a lib to make any object imutable
Install
$ npm install imut
Usage
const imut = require('imut');
//Only parent object
// Simple usage
const a = {};
imut(a);
a.b = 'test'
console.log(a.b); //undefined
// With object property
const a = { b: { c: 'd' } };
imut(a);
a.b = 'test'
console.log(a.b); //test
//With childs objects
const a = { b: { c: 'd' } };
imut(a, true);
a.b = 'test'
console.log(a.b); //{ c: 'd' }
API
imut(object, withProps)
| Parameter | Type | Value | |-----------|----------|-------------------| | object | object | any object | | withProps | boolean | true or false |