
Security News
Feross on the 10 Minutes or Less Podcast: Nobody Reads the Code
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.
fast-bigint
Advanced tools
Module for fast operations with long integers.
Arithmetic operations are written in C.
const FastBigInt = require('fast-bigint');
// Create using number
const a = new FastBigInt(123);
// Create using little-endian buffer
const b = new FastBigInt(Buffer.from([0xff, 0xee, 0xff]));
// Add using 'add(a, b)'
const x = FastBigInt.add(a, b);
// Subtract using 'sub(a, b)'
const x = FastBigInt.sub(a, b);
// Multiply using 'mul(a, b)'
const x = FastBigInt.mul(a, b);
// Divide using 'div(a, b)'
const x = FastBigInt.div(a, b);
// Modulo using 'mod(a, b)'
const x = FastBigInt.mod(a, b);
// Set thread limit for async functions (default 8)
FastBigInt.setMaxThreads(8);
// Run async on new thread
const x = await FastBigInt.addAsync(a, b);
const x = await FastBigInt.subAsync(a, b);
const x = await FastBigInt.mulAsync(a, b);
const x = await FastBigInt.divAsync(a, b);
const x = await FastBigInt.modAsync(a, b);
FastBigInt.addAsync(a, b, (x) => {
// Callback
});
FastBigInt.subAsync(a, b, (x) => {
// Callback
});
FastBigInt.mulAsync(a, b, (x) => {
// Callback
});
FastBigInt.divAsync(a, b, (x) => {
// Callback
});
FastBigInt.modAsync(a, b, (x) => {
// Callback
});
//Get little-endian buffer
//Buffer size is padded to multiple of 8
const x = new FastBigInt(8);
x.getBuffer() // = <Buffer 08 00 00 00 00 00 00 00>
//Compare using compare(a, b)
//returns
// -1 if a < b
// 0 if a = b
// 1 if a > b
FastBigInt.compare(
new FastBigInt(10),
new FastBigInt(15)
); // = -1
//Compare using compare functions
new FastBigInt(5).isGreaterOrEqual(new FastBigInt(4)); // = true
This module only supports positive numbers, so sub(a, b) when a < b will return invalid values
It's currently faster than JavaScript BigInt
Division and modulo are now slower than JS BigInt, I will try to improve the algorithm in the future
You can perform calculations on multiple threads with async functions (unlike JavaScript, which is single-threaded)
FAQs
Module for fast operations with long integers.
We found that fast-bigint demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.