Socket
Book a DemoInstallSign in
Socket

es-privates-loader

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

es-privates-loader

Webpack loader for add private props to javascript

latest
npmnpm
Version
0.0.0
Version published
Maintainers
1
Created
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

privates

FAQs

Package last updated on 30 Jul 2016

Did you know?

Socket

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