Socket
Socket
Sign inDemoInstall

babel-plugin-transform-bigint

Package Overview
Dependencies
55
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.27 to 1.0.28

34

__tests__/index-test.js

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

expect(code).toMatchSnapshot();
});
});
it('maybeJSBI', function () {
const example = `
function f(a) {
return Number(BigInt.asUintN(64, a));
}
console.log(f(3n));
`;
const {code} = babel.transform(example, {plugins: [plugin]});
expect(code).toMatchSnapshot();
});
it('maybeJSBI2', function () {
const example = `
function f(a) {
return Number(BigInt(a) < BigInt(0));
}
console.log(f(3n));
`;
const {code} = babel.transform(example, {plugins: [plugin]});
expect(code).toMatchSnapshot();
});
it('maybeJSBI2a', function () {
const example = `
function f(a) {
const x = BigInt(a) < BigInt(0);
return Number(x);
}
console.log(f(3n));
`;
const {code} = babel.transform(example, {plugins: [plugin]});
expect(code).toMatchSnapshot();
});

@@ -110,2 +110,5 @@ // see https://github.com/babel/babel/pull/6015

if (path.node.type === 'BinaryExpression') {
if (getRelationalFunctionName(path.node.operator) != null) {
return false;
}
return and(canBeBigInt(path.get('left')), canBeBigInt(path.get('right')));

@@ -325,3 +328,8 @@ }

path.node.callee.object.type === 'Identifier' &&
path.node.callee.object.name === 'JSBI') {
(path.node.callee.object.name === 'JSBI' || path.node.callee.object.name === 'BigInt')) {
if (path.node.callee.object.name === 'JSBI') {
if (['lessThan', 'greateThan', 'equal', 'notEqual', 'lessThanOrEqual', 'greaterThanOrEqual', 'toNumber'].indexOf(path.node.callee.property.name) !== -1) {
return false;
}
}
return JSBI;

@@ -484,3 +492,3 @@ }

BinaryExpression: function (path, state) {
const JSBI = canBeBigInt(path);
const JSBI = and(canBeBigInt(path.get('left')), canBeBigInt(path.get('right')));
const operator = path.node.operator;

@@ -487,0 +495,0 @@ if (JSBI !== false) {

2

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc