Skip to content
Compile JSBI code that works in today’s environments to native BigInt code.
Branch: master
Clone or download
Latest commit 5c36539 Jul 11, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Support JSBI.{asIntN,asUintN} (#2) Jul 11, 2019
test Support JSBI.{asIntN,asUintN} (#2) Jul 11, 2019
.babelrc Initial commit Nov 21, 2018
.editorconfig
.eslintrc.js Initial commit Nov 21, 2018
.gitignore Initial commit Nov 21, 2018
.nvmrc Initial commit Nov 21, 2018
.travis.yml Initial commit Nov 21, 2018
CONTRIBUTING.md Initial commit Nov 21, 2018
LICENSE Initial commit Nov 21, 2018
README.md Support JSBI.{asIntN,asUintN} (#2) Jul 11, 2019
package.json Release v1.1.0 Jul 11, 2019

README.md

babel-plugin-transform-jsbi-to-bigint Build status

Compile JSBI code that works in today’s environments to native BigInt code.

Example

Input using JSBI:

import JSBI from 'jsbi';

const a = JSBI.BigInt(Number.MAX_SAFE_INTEGER);
const b = JSBI.BigInt('2');

JSBI.add(a, b);
JSBI.subtract(a, b);
JSBI.multiply(a, b);
JSBI.divide(a, b);
JSBI.remainder(a, b);
JSBI.exponentiate(a, b);
JSBI.leftShift(a, b);
JSBI.signedRightShift(a, b);
JSBI.bitwiseAnd(a, b);
JSBI.bitwiseOr(a, b);
JSBI.bitwiseXor(a, b);

JSBI.unaryMinus(a);
JSBI.bitwiseNot(a);

JSBI.equal(a, b);
JSBI.lessThan(a, b);
JSBI.lessThanOrEqual(a, b);
JSBI.greaterThan(a, b);
JSBI.greaterThanOrEqual(a, b);

a.toString();
JSBI.toNumber(a);

JSBI.asIntN(64, JSBI.BigInt('42'));
JSBI.asUintN(64, JSBI.BigInt('42'));

Transpiled output using native BigInts:

const a = BigInt(Number.MAX_SAFE_INTEGER);
const b = 2n;

a + b;
a - b;
a * b;
a / b;
a % b;
a ** b;
a << b;
a >> b;
a & b;
a | b;
a ^ b;

-a;
~a;

a === b;
a < b;
a <= b;
a > b;
a >= b;

a.toString();
Number(a);

BigInt.asIntN(64, 42n);
BigInt.asUintN(64, 42n);

See the JSBI documentation for more information.

Installation

$ npm install babel-plugin-transform-jsbi-to-bigint

Usage

Via .babelrc (recommended)

.babelrc

{
  "plugins": ["transform-jsbi-to-bigint"]
}

Via CLI

$ babel --plugins transform-jsbi-to-bigint script.js

Via Node.js API

require('@babel/core').transform(code, {
  'plugins': ['transform-jsbi-to-bigint']
});
You can’t perform that action at this time.