Socket
Book a DemoInstallSign in
Socket

@bignum/babel-plugin

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bignum/babel-plugin

Babel plugin to replace tagged template literals with BigNum JS expressions.

latest
Source
npmnpm
Version
2.1.0
Version published
Weekly downloads
1
-92.31%
Maintainers
1
Weekly downloads
 
Created
Source

@bignum/babel-plugin

Babel plugin to replace tagged template literals with BigNum JS expressions.

NPM license NPM version NPM downloads NPM downloads NPM downloads NPM downloads NPM downloads

🚀 Features

  • This pre-compiles tagged template literals written with @bignum/template.f`.
  • It also, pre-compiles tagged template literals written with @bignum/template-light.f`.

💿 Installation

npm install -D @bignum/babel-plugin
npm install @bignum/template
# or
npm install @bignum/template-light

📖 Usage

Configuration

Include @bignum/babel-plugin in your Babel configuration.

{
  "plugins": ["@bignum/babel-plugin"]
}

Writing Code

Use @bignum/template.f to write the calculation formula.

import { f } from "@bignum/template";

const num = 0.1;
const result = f`${num} + 0.1 * 2`;
console.log(result); // 0.3
console.log(f`${0.2} + ${0.1}`); // 0.3

Output:

import { multiply, add, toResult } from "@bignum/template/core";
const num = 0.1;
const result = toResult(add(num, multiply("0.1", 2)));
console.log(result); // 0.3
console.log(toResult(add(0.2, 0.1))); // 0.3

Or use @bignum/template-light.f to write the calculation formula.

import { f } from "@bignum/template-light";

console.log(f`${0.2} + ${0.1}`); // 0.3

Output:

import { add, execCompiled } from "@bignum/template-light/core";

console.log(execCompiled([0.2, 0.1], (args) => add(args[0], args[1]))); // 0.3

🛸 Prior Art

  • bigjs-literal
    This package is similar to bigjs-literal in that it uses template literals for calculations, but is more lightweight.

Keywords

bignum

FAQs

Package last updated on 03 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts