Share a secret across ES6 specific modules, so that other modules cannot access the secret?
joe at trusktr.io
Sun Apr 23 20:42:47 UTC 2017
Is there a way to share some secret value across a few modules, and prevent
other modules? f.e. prevent modules of an app dev who is importing modules
of a library where the library wants to share private stuff across its
modules. Is this possible to implement somehow?
WeakMaps can be encapsulated inside a module to implement "private"
properties for a class defined inside that module and then exported. But
"protected" can't be implemented with a WeakMap shared with modules because
then end-user app code can import the WeakMap and read all the stuff. Is
there some way to share a WeakMap private with classes defined across
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss