Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-transform-bigint

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-bigint - npm Package Compare versions

Comparing version 1.0.21 to 1.0.22

21

__tests__/index-test.js

@@ -271,1 +271,22 @@ // to run this test file use `npx jest` in the parent folder or `npm run test`

it('CallExpression\'s type', function () {
const example = `
function n() {
return 3;
}
console.log(n() * n());
function b() {
return 3n;
}
console.log(b() * b());
function nb() {
if (Math.random() < 0.5) {
return 3;
}
return 3n;
}
console.log(nb() * nb());
`;
const {code} = babel.transform(example, {plugins: [plugin]});
expect(code).toMatchSnapshot();
});

17

index.js

@@ -326,10 +326,21 @@ // see https://github.com/babel/babel/pull/6015

if (binding.path.node.type === 'FunctionDeclaration') {
const statements = binding.path.get('body').get('body');
//console.log('binding.path', binding.path);
//const statements = binding.path.get('body').get('body');
const statements = [];
binding.path.getScope().traverse(binding.path.node, {ReturnStatement: function(path){ statements.push(path); }}, this);
let returnType = undefined;
for (const statement of statements) {
if (statement.type === 'ReturnStatement') {
if (canBeBigInt(statement.get('argument')) === false) {
return false;
const t = canBeBigInt(statement.get('argument'));
if (returnType === undefined) {
returnType = t;
}
if (returnType !== t) {
returnType = maybeJSBI;
}
}
}
if (returnType === false || returnType == JSBI) {
return returnType;
}
}

@@ -336,0 +347,0 @@ }

2

package.json
{
"name": "babel-plugin-transform-bigint",
"version": "1.0.21",
"version": "1.0.22",
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc