Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
babel-plugin-empower-assert
Advanced tools
Babel plugin to convert assert to power-assert at compile time
babel-plugin-empower-assert
is a Babel plugin to convert assert to power-assert at compile time.
$ npm install --save-dev babel-plugin-empower-assert power-assert
Babel7 is incompatible with Babel6.
For Babel6, you need to use the 1.x release of babel-plugin-empower-assert.
$ npm install --save-dev babel-plugin-empower-assert@1.4.0
{
"presets": [
...
],
"env": {
"development": {
"plugins": [
"babel-plugin-empower-assert"
],
}
}
}
$ babel /path/to/src/target.js > /path/to/build/target.js
$ babel --plugins babel-plugin-empower-assert /path/to/src/target.js > /path/to/build/target.js
or shortly,
$ babel --plugins empower-assert /path/to/src/target.js > /path/to/build/target.js
var babel = require('@babel/core');
var jsCode = fs.readFileSync('/path/to/src/target.js');
var transformed = babel.transform(jsCode, {
presets: [...],
plugins: ['babel-plugin-empower-assert']
});
console.log(transformed.code);
For given math.js
below,
'use strict';
var assert = require('assert');
function add (a, b) {
assert(!isNaN(a));
assert.equal(typeof b, 'number');
assert.ok(!isNaN(b));
return a + b;
}
Run babel
with --plugins empower-assert
to transform code.
$ babel --plugins empower-assert /path/to/demo/math.js > /path/to/build/math.js
You will see assert
is converted to power-assert
.
'use strict';
var assert = require('power-assert');
function add(a, b) {
assert(!isNaN(a));
assert.equal(typeof b, 'number');
assert.ok(!isNaN(b));
return a + b;
}
Licensed under the MIT license.
2.0.0-beta.1 (2018-03-30)
For Babel6, you need to use the 1.x release of babel-plugin-empower-assert.
$ npm install --save-dev babel-plugin-empower-assert@1.4.0
FAQs
Babel plugin to convert assert to power-assert at compile time
The npm package babel-plugin-empower-assert receives a total of 3,843 weekly downloads. As such, babel-plugin-empower-assert popularity was classified as popular.
We found that babel-plugin-empower-assert demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.