Socket
Socket
Sign inDemoInstall

varify

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

varify

browserify transform that converts all const assignments to var assignments.


Version published
Weekly downloads
2.3K
decreased by-9.44%
Maintainers
1
Weekly downloads
 
Created
Source

varify build status

browserify transform that converts all const assignments to var assignments.

npm install varify

Why?

So you can get the benefits of immutable variables with help of lint tools while staying compatible with older browsers that have no const.

Warning

The real const is block scoped, however when replaced with var this feature is lost. So only use varify if you can do without block scope and are only looking for some immutability support that gets compiled out for compatibility.

If you are after block scope, have a look at def.js which provides limited support for that.

Example

Given this JavaScript:

const a = 1;

var keep = { const: 1 };
keep.const = 2;

const foo = function () {
  console.log('some const s should be left unchanged');
};

Running browserify with varify transform:

require('browserify')()
  .transform(require('varify'))
  .add(__dirname + '/sample.js')
  .bundle()
  .pipe(process.stdout);

Outputs:

var a = 1;

var keep = { const: 1 };
keep.const = 2;

var foo = function () {
  console.log('some const s should be left unchanged');
};

Usage from Commandline

browserify -t varify sample.js > bundle.js

Keywords

FAQs

Package last updated on 10 Mar 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