0.2.1 • Published 5 years ago

safer-object v0.2.1

Weekly downloads
3
License
ISC
Repository
github
Last release
5 years ago

safer-object

Social Media Photo by freestocks.org on Unsplash

Build Status Coverage Status WebReflection status

Flattened objects with non configurable, and non writable fields (i.e. to freeze prototypes).

const obj = saferObject({
  __proto__: {
    name: 'shadowed',
    parent: 'super'
  },
  name: 'test'
});

obj.name = 'nope';
obj.parent = {nope: true};

console.assert(obj.name === 'test');
console.assert(obj.parent === 'super');
console.assert(obj.hasOwnProperty('parent'));
console.assert(obj.hasOwnProperty('hasOwnProperty'));