@snek/private

1.0.1 • Public • Published

@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;

Readme

Keywords

none

Package Sidebar

Install

npm i @snek/private

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

58.1 kB

Total Files

14

Last publish

Collaborators

  • snek