0.0.3 • Published 8 years ago

deep-lockdown v0.0.3

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

Deep Lockdown


Recursively call Object.freeze(), Object.seal(), and Object.preventExtensions() on objects.

This is based on the deep-freeze library but takes it a step further and prevents new properties from being added or removed to the object. It also marks all existing properties as non-configurable.


Install

npm install deep-lockdown


Usage

var deepLockdown = require('deep-lockdown');

var myObj = {
  a: 'a',
  b: 'b',
  c: {
    e: {
      q: 'word'
    }
  }
};

deepLockdown(myObj);

myObj.d = 'd';
myObj.a = 'jkl';
myObj.c.e.q = 'different-word';
myObj.c.e.f = 'add-some-words';

console.log(myObj);

var myObj = { a: 'a', b: 'b', c: { e: { q: 'word' } } };