babel-plugin-transform-bigint
Advanced tools
Comparing version 1.0.18 to 1.0.19
@@ -147,2 +147,8 @@ // to run this test file use `npx jest` in the parent folder or `npm run test` | ||
} | ||
function f5(a) { | ||
if (typeof a !== 'bigint') { | ||
void 0; | ||
} | ||
return a * a; | ||
} | ||
`; | ||
@@ -149,0 +155,0 @@ const {code} = babel.transform(example, {plugins: [plugin]}); |
13
index.js
@@ -205,2 +205,11 @@ // see https://github.com/babel/babel/pull/6015 | ||
const variableName = path.node.name; | ||
const consequent = ifStatement.get('consequent').node; | ||
let ok = false; | ||
if (types.isBlockStatement(consequent)) { | ||
if (consequent.body.length === 1) { | ||
if (types.isThrowStatement(consequent.body[0])) { | ||
ok = true; | ||
} | ||
} | ||
} | ||
const isNotTypeOfCheck = function (node, type, variableName) { | ||
@@ -226,6 +235,6 @@ if (node.type === 'BinaryExpression' && node.operator === '!==') { | ||
}; | ||
if (isNotTypeOfCheck(tmp.node, 'bigint', variableName)) { | ||
if (ok && isNotTypeOfCheck(tmp.node, 'bigint', variableName)) { | ||
return JSBI; | ||
} | ||
if (isNotTypeOfCheck(tmp.node, 'number', variableName)) { | ||
if (ok && isNotTypeOfCheck(tmp.node, 'number', variableName)) { | ||
return false; | ||
@@ -232,0 +241,0 @@ } |
{ | ||
"name": "babel-plugin-transform-bigint", | ||
"version": "1.0.18", | ||
"version": "1.0.19", | ||
"description": "A plugin for babel to transform `x * y` into something like `JSBI.multiply(x, y)` to support bigints.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46553
794