Create an immutable enumerable object with ES6 Symbols, getters, setters and
Object.lock
.
$ npm install private-object
const priv = require('private-object')
var boop = priv({foo: 'bar'})
console.log(boop)
// => {}
console.log(boop.foo)
// => 'bar'
console.log(Object.keys(boop))
// => []
boop.bar = 3
console.log(boop, boop.bar)
// => {}, undefined
boop.foo = 'Tobi'
console.log(boop.foo)
// => 'Tobi'
This is a small experiment to see how far private properties can be pushed and locked down in ES6.