private-props

0.1.1 • Public • Published

private-props

Version Simulation of private property for javascript (though private property isn't that needed in javascript), this module would probably be useless.

Installation

npm install -S private-props

Usage

// sample usage on how to use this module
let props = require('private-props')
 
class Foo {
    constructor() {
        /** now this properties won't be accessible to the outside world */
        props(this).width = 100
        props(this).height = 100
        /** this is publicized properties */
        this.weight = 50
    }
 
    // accessing property from within class
    getWidth() {
        return props(this).width
    }
}
 
module.exports = Foo

Issues

  • somehow the content of the class is visible if you supply an instantiated version of the class

Package Sidebar

Install

npm i private-props

Weekly Downloads

1

Version

0.1.1

License

ISC

Last publish

Collaborators

  • yakovmeister