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

babel-plugin-auto-constant

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-auto-constant

Shortcut for constant definitions

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

Auto Constant!

This space aged babel plugin allows you to create constants whose value is the named expression by simply writing the expression without const or assigning a value:

E.g. instead of:

const FOO_UPDATE_IN_FLIGHT = 'FOO_UPDATE_IN_FLIGHT';

simply write:

FOO_UPDATE_IN_FLIGHT;

... which compiles the same to:

var FOO_UPDATE_IN_FLIGHT = 'FOO_UPDATE_IN_FLIGHT';

Exporting

If you want to export, add two underscores to the end of your expression:

FOO_LOADED__

...which will compile to

var FOO_LOADED = exports.FOO_LOADED = 'FOO_LOADED';

Note if you are only exporting constants, make sure to export a default or any value so that Babel will define the __esModule property on exports

Keywords

FAQs

Package last updated on 13 Dec 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

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