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

basejump

v1.1.0

Published

Built to convert 128 bit buffers to base 62 strings. Supports base 36 and buffers of arbitrary size.

Downloads

13

Readme

baseJump

Build Status Coverage Status Version npm npm Downloads Dependencies

Disclaimer

This project combines the 3 things I'm worst at:

  1. Math
  2. C++
  3. Computers

That said, I have verified the output against third party tools that will freely convert between different numeric bases. I did not include these in the tests because reasons.

Huge Thanks To Matt McCutchen

I have one dependency that is included in this code, namely the venerable and blessed Matt Mccutchen's Big Integer Library. Matt graciously hosts this source at: http://mattmccutchen.net/bigint/. If you need Maths in C++, I recommend this over using OpenSSL's BigInteger lib.

API

It's so easy even I can use it:

var jump = require( 'baseJump' );

// Node buffers can be treated as / thought of as an array of 8 bit numbers.
// Don't believe me? Call buffer.toJSON somtime. Anyway, passing one of those
// arrays to baseJump is how we pass along data.
var one = jump.toBase62( [ 100, 100, 200 ] );

// one == '000000000000000000t6Sy'
// Because of my own selfish selfishness, it auto-pads to 22 characters since that's
// the max number of characters required to represent a 128 bit unsigned integer. Maybe. Who knows.
// Certainly not me. Math is hard.
// The good news is you can control this:
var two = jump.toBase62( [ 100, 100, 200 ], 10 );

// two == '000000t6Sy' Easy.

// And base 36 calls work the same, btw, toBase36 defaults to 26 spaces.
var three = jump.toBase36( [ 100, 100, 200 ], 10 );

// three == '000007THES' ta-da

Frequently Imagined Questions (FIQ)

How Do I Get This Crap To Install on Windows

You'll need a pre-3.0 Python version installed an in your PATH. You'll also need a C++ compiler. This will be annoying to set up if you don't have one. But you're on Windows and that's just how they do.

Why?

Flake ids should be 128 bits as the good Boundary intended. Or whoever came up with it. Anyway, I want flake ids and I want them today and in 128 bits and rendered as base 62 encoded, lexicograhpically sortable strings. And I want it to be as fast as possible. That is the only reason anyone should ever hurt themselves with C++.

BaseJump?

Yeah. So. Take the code and call it something else. If other people ask me, I might be able to add different base conversions. I tried to make it so it'd be easy for me. But I see a lot of folks asking for 62 and 36 and almost nothing supports either (in Node anyway) or does it sloooooowwwwwllllyyyyy.

Why Didn't You Just Use [some other thing]

I tried. Those other things were slow and/or irritating and/or required a ton of dependencies.