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

axy-sourcemap-base64vlq

v0.1.1

Published

Codec for VLQ (variable-length quantity) Base64 algorithm

Downloads

10

Readme

axy-sourcemap-base64vlq

Codec for VLQ (variable-length quantity) Base64 algorithm (Node.js).

VQL + Base64

Base64 allows us to represent a sequence of numbers in a text string that can be stored and transmit in text formats (JSON, XML, etc).

VLQ allows us to represent an integer in a sequence numbers with little digit capacity. For example 6 bit is the limit for Base64. The resulting numbers are called "VLQ digits". Small input number is represented by fewer VLQ-digits than big number. Thus VLQ is most effective if the input sequence is contains mainly the small numbers.

VLQ+Base64 allows us effectively represented a sequence of integers (dominated by a small number of) in the text format.

For example, it used in JavaScript/CSS source map.

The Algorithm

For example, we have a block of numbers: [12345, -12345, 0].

(1). VLQ only works with unsigned integers. Transfer the sign bit to the end of the integer.

12345 in binary is 11000000111001. Added 0 (positive) to the end: 110000001110010.

For -12345 take a positive form and add 1 (negative) to the end: 110000001110011.

Result is [110000001110010, 110000001110011, 0].

(2). Transform to the VLQ-sequence. For Base64 we need a block of 6-bit numbers. Most significant bit is reserved - it is "continuation".

Split numbers to groups of 5 bits: [11000 00011 10010, 11000 00011 10011, 00000]. Output starting from the least significant bits. If the group is not the last in the current number then set the continuation bit.

Result: [110010 100011 011000 110011 100011 011000 000000]. Or decimal [50, 35, 24, 51, 35, 24, 0]. These are VLQ digits.

(3). Replace the numbers on the letters of the Base64-alphabet. The standard alphabet is A..Za..z0..9+/.

Result is yjYzjYA.

How to use

npm install axy-sourcemap-base64vlq
var encoder = require("axy-sourcemap-base64vlq");

encoder.encode([12345, -12345, 0]); // yjYzjYA
encoder.decode("yjYzjYA"); //  [12345, 012345, 9]

encoder.decode("Variable+Length+QuantitY"); // [-10, 13, -13349, -13 ... -12797139]