babel-plugin-transform-bigint
Advanced tools
Comparing version 1.0.13 to 1.0.14
@@ -151,1 +151,13 @@ // to run this test file use `npx jest` in the parent folder or `npm run test` | ||
}); | ||
it('it does not mutable variables', function () { | ||
const example = ` | ||
function f() { | ||
for (let i = 0; i < 10; i += 1) { | ||
console.log(i * i); | ||
} | ||
} | ||
`; | ||
const {code} = babel.transform(example, {plugins: [plugin]}); | ||
expect(code).toMatchSnapshot(); | ||
}); |
19
index.js
@@ -107,8 +107,17 @@ // see https://github.com/babel/babel/pull/6015 | ||
const x = binding.path.get('init'); | ||
if (x.node != null && canBeBigInt(x) === false && binding.constant) { | ||
return false; | ||
if (x.node != null) { | ||
const X = canBeBigInt(x); | ||
if ((X === false || X === JSBI) && binding.constant) { | ||
return X; | ||
} | ||
if ((X === false || X === JSBI) && !binding.constant) { | ||
let allAssignmentsHaveSameType = true; | ||
for (const path of binding.constantViolations) { | ||
allAssignmentsHaveSameType = allAssignmentsHaveSameType && canBeBigInt(path) === X; | ||
} | ||
if (allAssignmentsHaveSameType) { | ||
return X; | ||
} | ||
} | ||
} | ||
if (x.node != null && canBeBigInt(x) === JSBI && binding.constant) { | ||
return JSBI; | ||
} | ||
} | ||
@@ -115,0 +124,0 @@ for (const path of binding.referencePaths) { |
{ | ||
"name": "babel-plugin-transform-bigint", | ||
"version": "1.0.13", | ||
"version": "1.0.14", | ||
"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
36066
670