private.js
private.js provides private accessor to object property with option prefix.
Install
Node
$ npm install private.js
Browser
<script src="private.min.js"></script>
Usage
Node.js sample.
var $pvt = require("private.js"),
expect = require("expect.js");
var klass = $pvt("_" , {
getPublicVariable: function() {
return this.publicVariable;
},
getPrivatevariable: function() {
return _privateVariable;
},
getPrivateMethodReferPrivateVariable: function() {
return _getPrivateVariable();
},
getPrivateMethodReferPublicVariable: function() {
return _getPublicVariable.call(this);
},
_getPrivateVariable: function() {
return _privateVariable;
},
_getPublicVariable: function() {
return this.publicVariable;
},
publicVariable: 1,
_privateVariable: 2
});
Test
$ npm test
Minify
$ grunt
Release note
- 2013/04/22 0.0.1 release
- 2013/04/24 0.0.4 release