unassert-js / unassert

Encourages programming with assertions by providing tools to compile them away.
MIT License
192 stars 13 forks source link

Support removal of assert variable assignment #2

Closed twada closed 8 years ago

twada commented 8 years ago

Support removal of assignment to assert variable. (For example, CoffeeScript produces this style of assinment) On the other hand, do not remove VariableDeclarator since there are too many assumptions to make.

before:

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

after:

var assert;
function add(a, b) {
    return a + b;
}