1.0.0 • Published 7 years ago

imut v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

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)

ParameterTypeValue
objectobjectany object
withPropsbooleantrue or false