JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 15224
  • Score
    100M100P100Q125982F
  • License MIT

Browserify transform to remove assertions on production build

Package Exports

  • unassertify

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (unassertify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

unassertify

Browserify transform to remove assertions on production build. Encourages Design by Contract (DbC).

Build Status NPM version Dependency Status License

INSTALL

$ npm install --save-dev unassertify

HOW TO USE

via CLI

$ $(npm bin)/browserify -t unassertify /path/to/src/target.js > /path/to/build/target.js

via API

var source = require('vinyl-source-stream');
var browserify = require('browserify');
var glob = require('glob'),

gulp.task('production_build', function() {
    var files = glob.sync('./src/*.js');
    var b = browserify({entries: files, debug: false});
    b.transform('unassertify');
    return b.bundle()
        .pipe(source('bundle.js'))
        .pipe(gulp.dest('./dist'));
});

EXAMPLE

For given math.js below,

'use strict';

function add (a, b) {
    console.assert(typeof a === 'number');
    assert(!isNaN(a));
    assert.equal(typeof b, 'number');
    assert.ok(!isNaN(b));
    return a + b;
}

Run browserify with -t unassertify to transform file.

$ $(npm bin)/browserify -t unassertify /path/to/demo/math.js > /path/to/build/math.js

You will see assert calls disappear.

'use strict';
function add(a, b) {
    return a + b;
}

AUTHOR

LICENSE

Licensed under the MIT license.