mini-unassert
remove assert calls from a stream of javascript
Last updated 3 years ago by goto-bus-stop .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install mini-unassert 
SYNC missed versions from official npm registry.

mini-unassert

a small and fast unassert transform

npm travis standard

It transforms assert calls to void expressions. Use a minifier like terser to completely remove them.

Input:

var assert = require('assert')
assert(true)
assert.equal(typeof x, 'string')
assert(sideEffectCall())
assert.throws(function () {})

Output:

;
void (true)
void (typeof x, 'string')
void (sideEffectCall())
void (function () {})

After minification:

sideEffectCall();

Install

npm install mini-unassert

Usage

It works as a stream and as a browserify transform.

var unassert = require('mini-unassert')
fs.createReadStream('file.js')
  .pipe(unassert({ modules: ['assert', 'power-assert', 'nanoassert'] }))
  .pipe(fs.createWriteStream('file.unassert.js'))
browserify -g mini-unassert -g uglifyify

API

stream = unassert(opts={})

Create a stream that replaces assert calls with void expressions.

  • opts.modules is an array of assertion module names, defaulting to ['assert'].

b.transform(unassert, opts={})

Add unassert as a browserify transform. b is an instance of browserify.

  • Set opts.global to run it on all files, including dependencies in node_modules. (recommended)
  • opts.modules is an array of assertion module names, defaulting to ['assert'].

License

Apache-2.0

Current Tags

  • 1.1.0                                ...           latest (3 years ago)

3 Versions

  • 1.1.0                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (6)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |