@snek/private
v1.0.1
Published
Completely unenumerable symbols that you can use to store private data on any object. Only those with access to the symbol can access the data.
Downloads
29
Readme
@snek/private
Completely unenumerable symbols that you can use to store private data on any object. Only those with access to the symbol can access the data.
const PS = require('@snek/private');
const mySecret = PS('mySecret');
class MyClass {
constructor(x) {
this[mySecret] = x;
}
add(y) {
return this[mySecret] + y;
}
}
const obj = {};
obj[mySecret] = 5;