babel-plugin-transform-bigint
Advanced tools
Comparing version 1.0.33 to 1.0.34
@@ -392,1 +392,28 @@ // to run this test file use `npx jest` in the parent folder or `npm run test` | ||
it('destructuring assignment', function () { | ||
const example = ` | ||
const f = function () { | ||
let [A, B] = [1n, 0n]; | ||
return A + B; | ||
} | ||
`; | ||
const {code} = babel.transform(example, {plugins: [plugin]}); | ||
expect(code).toMatchSnapshot(); | ||
}); | ||
it('destructuring assignment 2', function () { | ||
const example = ` | ||
const f = function () { | ||
let A = 1n; | ||
let B = 0n; | ||
[A, B] = [3n, 4n]; | ||
return A + B; | ||
} | ||
`; | ||
const {code} = babel.transform(example, {plugins: [plugin]}); | ||
expect(code).toMatchSnapshot(); | ||
}); | ||
17
index.js
@@ -160,2 +160,5 @@ // see https://github.com/babel/babel/pull/6015 | ||
if (path.node.type === 'AssignmentExpression') { | ||
if (path.node.left.type === 'ArrayPattern') { | ||
return maybeJSBI; | ||
} | ||
if (path.node.operator === '=') { | ||
@@ -173,5 +176,8 @@ return canBeBigInt(path.get('right')); | ||
if (x.node != null) { | ||
const X = canBeBigInt(x); | ||
if (tryType(X, binding, path)) { | ||
return X; | ||
let X = null; | ||
if (x.node.type !== 'ArrayExpression') { | ||
X = canBeBigInt(x); | ||
if (tryType(X, binding, path)) { | ||
return X; | ||
} | ||
} | ||
@@ -431,3 +437,6 @@ } | ||
} | ||
console.debug('unknown path.node.type: ' + path.node.type); | ||
if (path.node.type === 'ArrayPattern') { | ||
return maybeJSBI; | ||
} | ||
console.warn('unknown path.node.type: ' + path.node.type); | ||
//TODO: | ||
@@ -434,0 +443,0 @@ return maybeJSBI; |
{ | ||
"name": "babel-plugin-transform-bigint", | ||
"version": "1.0.33", | ||
"version": "1.0.34", | ||
"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
67219
1101