0.2.1 • Published 5 years ago
safer-object v0.2.1
safer-object
Social Media Photo by freestocks.org on Unsplash
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'));