varify / 0.1.1 last updated 3 years ago created on May 22nd 2013

Install

npm install --save varify

Clone

git clone git@github.com:thlorenz/varify.git

dependencies

main through 2.3.8 MIT
redeyed 0.4.4 MIT

maintainers

thlorenz thlorenz

versions

0.1.1 3 years ago thlorenz
0.1.0 3 years ago thlorenz
2101 Downloads yesterday.

readme

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.

Example

Given this JavaScript:

1
2
3
4
5
6
7
8
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:

1
2
3
4
5
require('browserify')
  .transform(require('varify'))
  .add(__dirname + '/sample.js')
  .bundle()
  .pipe(process.stdout);

Outputs:

1
2
3
4
5
6
7
8
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
Resolving all dependencies.. This could take a while as our cache is not yet fully warmed up.