Socket
Socket
Sign inDemoInstall

babel-plugin-short-private-properties

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    babel-plugin-short-private-properties

A babel plugin which will convert all private properties `_prop` or methods `_doSome` to short name.


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Install size
9.12 kB
Created
Weekly downloads
 

Readme

Source

short-private-properties

This plugin find in ES6 Classes all methods or properties with start _ and replace them with a short name.

npm AppVeyor Travis

Install

yarn add -D babel-plugin-short-private-properties
# or npm i -D babel-plugin-short-private-properties

Input:

class A {
  constructor() {
    this._veryLondProppertyNameA = "Test class A";
    this._veryLondProppertyNameA2 = "Write A";
  }
  _getAProperty() {
    console.log(this._veryLondProppertyNameA);
  }
}

class B extends A {
  constructor() {
    super();
    this._veryLondProppertyNameA2 = "Overwrite B";
    this._veryLondProppertyNameB = "Test class B";
  }
  getResult() {
    this._getAProperty();
    console.log(this._veryLondProppertyNameB);
    console.log(this._veryLondProppertyNameA2);
  }
}

new B().getResult();
// Test class A
// Test class B
// Overwrite B

Output:

class A {
  constructor() {
    this._b = "Test class A";
    this._c = "Write A";
  }
  _d() {
    console.log(this._b);
  }
}

class B extends A {
  constructor() {
    super();
    this._c = "Overwrite B";
    this._e = "Test class B";
  }
  getResult() {
    this._d();
    console.log(this._e);
    console.log(this._c);
  }
}

new B().getResult();
// Test class A
// Test class B
// Overwrite B

Usage

{
  "plugins": ["babel-plugin-short-private-properties"]
}

Via CLI

$ babel --plugins babel-plugin-short-private-properties script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["babel-plugin-short-private-properties"]
});

FAQs

Last updated on 03 Feb 2018

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