Giter Club home page Giter Club logo

babel-plugin-transform-jsbi-to-bigint's Introduction

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('42');

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.notEqual(a, b);
JSBI.lessThan(a, b);
JSBI.lessThanOrEqual(a, b);
JSBI.greaterThan(a, b);
JSBI.greaterThanOrEqual(a, b);

JSBI.EQ(a, b);
JSBI.NE(a, b);
JSBI.LT(a, b);
JSBI.LE(a, b);
JSBI.GT(a, b);
JSBI.GE(a, b);

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

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 = 42n;

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 >= b;

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

a.toString();
Number(a);
typeof a === 'bigint';

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']
});

babel-plugin-transform-jsbi-to-bigint's People

Contributors

futpib avatar gaubee avatar jakobkummerow avatar mathiasbynens avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.