1.0.0 • Published 7 years ago
imut v1.0.0
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 |
1.0.0
7 years ago