empower-assert
v2.0.0
Published
Convert assert to power-assert on ESTree AST
Downloads
159,061
Maintainers
Readme
empower-assert
Convert assert to power-assert on ESTree AST.
Install
$ npm install --save-dev empower-assert
Usage
const empowerAssert = require('empower-assert');
const acorn = require('acorn');
const escodegen = require('escodegen');
let source =
`'use strict';
const assert = require('assert');
function add(a, b) {
assert(!isNaN(a));
assert.equal(typeof b, 'number');
assert.ok(!isNaN(b));
return a + b;
}`;
let transformed = empowerAssert(acorn.parse(source));
console.log(escodegen.generate(transformed));
// 'use strict';
// const assert = require('power-assert');
// function add(a, b) {
// assert(!isNaN(a));
// assert.equal(typeof b, 'number');
// assert.ok(!isNaN(b));
// return a + b;
// }
License
MIT License: Teppei Sato <[email protected]>
This is a port of babel-plugin-empower-assert.
Copyright (c) 2016 Takuto Wada, https://github.com/power-assert-js/babel-plugin-empower-assert