npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bigjs

v0.0.3

Published

A big integer library for JS, based on Leemon, with focus on prime numbers and cryptography

Downloads

539

Readme

#BigJS This is my big integer library, it is built on top of the big int library built by Leemon Baird.

I built it for my own interests in cryptography. It was built as Leemon's library polluted the global scope and had a somewhat scattered design. I especially love the implementations that were done for finding primes. Enjoy!

Construction

BI(number, base)

number - the actual number, this can be a string, a JS number, or another BI object base - this defaults to 10

  // If you're using npm, otherwise BI is part of the window objects
  var BI = require('bigjs');


  var b = new BI(16772625);
  //Or
  var b = new BI("FFEE11", 16);
  //If you put a BI object in the constructor a deep copy of that number is made
  var foo = new BI(b);
  //foo is now a BI object with the value 0xFFEE11

.toString(base)

base - this also defaults to 10

  var b = new BI(16772625).toString(16);
  //b is now the string "FFEE11"

.valueOf()

this only works by translating whatever is in the big int to a JS number. It's called whenever the object is involved in a numerical operation.

  var b = (new BI(10)) * 2
  //b is now 20

Constants

BI.ONE == 1
BI.ZERO == 0

Primes

prime(bits, probable)

bits - bit size of the prime, anything over 2048bits is rather slow on most machines
probable - determines whether or not this is a true prime or a probable prime. Setting this to true means that 1 in every 2^80 numbers generated may be composite. However, it has a speed up of about 10x compared to the true prime.

BI.prime(2048) //Generates a 2048 bit true prime encapsulated in the BI object

Comparisons

Operations

Arithmetic

add(num, me)

  var b = new BI(1997);
  b.add(19);
  // Returns a new big int object with a value of 2016
  b.add(19, true);
  // Returns the current big int object, b, with its value changed to 2016

subtract(num, me)

  var b = new BI(2016);
  b.subtract(19);
  // Returns a new big int object with a value of 1997
  b.subtract(19, true);
  // Returns the current big int object, b, with its value changed to 1997

multiply(num, me)

  var b = new BI(8);
  b.multiply(7);
  // Returns a new big int object with a value of 56
  b.multiply(7, true);
  // Returns the current big int object, b, with its value changed to 56

times(num, me)

this is a synonym of .multiply()

Bitwise