access-mod
Utility that brings private and protected access modifiers to ES2015 Classes
Must have support ES2015 support for Proxies and Symbols
HOW TO USE
Examples
Simple usage :
// FILE access-modified.js// --------------------------------------------------------'use strict';const AccessMod = ;let am = ;{}// will not be accessible outside class or to parent{}'private method'{}// will not be accessible outside class but will be to parent{}'protected method'{}// will be accessible everywhere{// access private or protected propertylet privateProp = am;}moduleexports = am;// --------------------------------------------------------// FILE index.js// --------------------------------------------------------'use strict';const AccessModified = ;// only public properties will be available to instancelet amfd = ;
With inheritance
// FILE access-mod-parent.js// --------------------------------------------------------'use strict';module{this__privateProperty = 'this is private.';}// will not be accessible outside class or to parent or to child{}'private method'{}// will not be accessible outside class but will be to parent and child{console;}'protected method'{}// FILE access-mod-child.js// --------------------------------------------------------'use strict';const AccessMod = ;const AccModParent = ;let am = ;{}{// called from parentam // hello world !}let accModChild = new am;