priv-fields
v1.2.0
Published
Private fields in JavaScript and TypeScript.
Downloads
2
Readme
Private Fields
Private fields in JavaScript and TypeScript.
Installation
From npmjs.com (recommended) - choose one of the options:
npm install priv-fields
yarn add priv-fields
From Adrosar/priv-fields - downloads the entire contents of the repository:
npm install bitbucket:Adrosar/priv-fields
How to use
import { Private } from "priv-fields";
type Priv = {
name: string;
}
const priv = new Private<Foo, Priv>();
const _ = priv.createAccess();
class Foo {
constructor(name: string) {
priv.initValue(this, {
name: name
});
}
public getName(): string {
return _(this).name;
}
}
const foo: Foo = new Foo("Foo");
console.log(foo.getName()); //> "Foo"
Development
Running the tests:
For Node.js:
npm run node:test
For browser:
- Run in terminal
npm run rollup:test
- Run in terminal
npm run server
- Open link http://127.0.0.1:61088/test.rollup.html
- Open DevTools Console (F12 in Google Chrome / Windows)
- Use F5 to refresh the page
- If there is no exception, then the test passed successfully
Versioning
I use the versioning system SemVer (2.0.0)
Author
- Adrian Gargula
License
This project is licensed under the ISC License - see the wiki/ISC_license
Other
This project is based on Adrosar/ts-startek-kit (version 1.5.0)