Socket
Socket
Sign inDemoInstall

es-privates-loader

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    es-privates-loader

Webpack loader for add private props to javascript


Version published
Weekly downloads
1
decreased by-75%
Maintainers
1
Install size
10.3 kB
Created
Weekly downloads
 

Readme

Source

Webpack loader for add private props to javascript

Add privates to javascript in file level. Props when start with _ will be replaced to symbols. Its just experiment =).

Actually next in next ECMA specifications, private props will be like this#prop = 11. So, this webpack loader is temporary solution.

Example:

class EventEmitter {

  constructor() {
    this._handlers = []
    this._initHandlers()
  }

  _initHandlers() {

  }

}

compile to:

var $$handlers$$ = Symbol('handlers');
var $$initHandlers$$ = Symbol('initHandlers');

class EventEmitter {

  constructor() {
    this[$$handlers$$] = []
    this[$$initHandlers$$]()
  }

  [$$initHandlers$$]() {
    
  }

}

TODO:

  • Add obj#prop in ECMA specifications
  • Add class level scope, no file scope
  • Add obj#prop support to Babel
  • Fix var _name, now its compile to var [$$name$$], this is syntax error.
  • Fix function _name(){}, now its compile to function [$$name$$]{}, this is syntax error.
  • Fix `str${this._prop}ing` must be `str${this[$$prop$$]}ing`

Keywords

FAQs

Last updated on 30 Jul 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc