Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-enum-minimize

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

babel-plugin-enum-minimize

Babel plugin that minimize enums in file

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

babel-plugin-enum-minimize

Babel plugin that will minimize the enum defininition in specified file.

Use comment at top to determine whether enable the feature for current file.

Examples

Suppose you have a file defined all Redux action types as follows:

In

// @enums
export const add = 'todos/add';
export const remove = 'todos/remove';
export const complete = 'todos/complete';
export const filter = 'todo-list/filter';

Out

// @enums
export const add = '!';
export const remove '"';
export const complete = '#';
export const filter = '$';

Please notice that this is an opt-in feature, meaning that you have to write // @enums at top of file to enable this feature file by file.

Installation

$ npm install babel-plugin-enum-minimize

Usage

.babelrc

{
  "plugins": ["enum-minimize"]
}

Via Node API

require('babel-core').transform('code', {
  plugins: ['enum-minimize'],
});

Options

useString

boolean, defaults to true.

This option determines whether you would like to keep string as enum types. If false is given, integers starting from 0 will be used instead. Meanwhile, if use string, char starting from "!" will be used.

asciiOnly

boolean, defaults to false.

This option determines whether you allow to have unicode char in string. It will only be valid when you set useString option to true.

When asciiOnly is set to be true, enum will be transformed to a string representation of it's index in radix 16. However, if use unicode, characters from range "!" to "]" and any character whose charCode is greater than 256 will be used.

License

MIT

Keywords

FAQs

Package last updated on 18 Oct 2017

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc