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.20 to 1.0.21

25

__tests__/index-test.js

@@ -153,2 +153,3 @@ // to run this test file use `npx jest` in the parent folder or `npm run test`

}
export {f1, f2, f3, f4, f5};
`;

@@ -243,2 +244,3 @@ const {code} = babel.transform(example, {plugins: [plugin]});

}
export default f;
`;

@@ -248,1 +250,24 @@ const {code} = babel.transform(example, {plugins: [plugin]});

});
it('internal number function', function () {
const example = `
function f(a) {
return a * a;
}
console.log(f(3));
`;
const {code} = babel.transform(example, {plugins: [plugin]});
expect(code).toMatchSnapshot();
});
it('internal bigint function', function () {
const example = `
function f(a) {
return a * a;
}
console.log(f(3n));
`;
const {code} = babel.transform(example, {plugins: [plugin]});
expect(code).toMatchSnapshot();
});

@@ -163,2 +163,40 @@ // see https://github.com/babel/babel/pull/6015

}
if (binding.path.node.type === 'Identifier' && binding.path.parentPath.node.type === 'FunctionDeclaration') {
//console.log(binding.path.parentPath.node, '!!!');
const functionPath = binding.path.parentPath;
const id = functionPath.get('id');
const functionBinding = functionPath.scope.getBinding(id.node.name);
if (functionBinding != null) {
let argIsBigInt = undefined;
//TODO: check no exports
for (const path of functionBinding.referencePaths) {
//console.log('function call: ' + path.parentPath + '', path.parentPath);
const functionCall = path.parentPath;
if (types.isCallExpression(functionCall)) {
//TODO: check arguments
const args = functionCall.get('arguments');
for (let i = 0; i < args.length; i += 1) {
const a = args[i];
//console.log('arg', a);
const t = canBeBigInt(a);
if (t === false && (argIsBigInt == undefined || argIsBigInt === 'false')) {
argIsBigInt = 'false';
} else if (t === JSBI && (argIsBigInt == undefined || argIsBigInt === 'true')) {
argIsBigInt = 'true';
} else {
argIsBigInt = 'NO';
}
}
} else {
argIsBigInt = 'NO';
}
}
if (argIsBigInt === 'false') {
return false;
}
if (argIsBigInt === 'true') {
return JSBI;
}
}
}
} else {

@@ -165,0 +203,0 @@ if (path.node.name === 'undefined') {

2

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