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

z85e

v1.0.0

Published

A javascript port of the Z85e C# library by coenm. Z85e is a Zero-MQ Base-85 Binary-To-Text encoding.

Downloads

4

Readme

z85e

This project implements an extended version of the ZeroMQ z85 encoding standard described here. It is a port of coenm/Z85e from C# to javascript. The extension is simply to enable encoding and decoding of arbirary length inputs, where the original required inputs to be multiples of 4 bytes to encode or 5 characters to decode.

The Z85 encoding has a few nice properties. It doesn't blow up data as much as Base64 does, and it is source code safe - you can copy and paste it into a string, and not have to worry about escapes or quotes causing problems.

This library can be included as a single file without dependencies in a browser or node (./src/z85e.js).

Stream support is provided in a separate file (./src/streams.js)

Installation

npm install z85e

If you plan to use the z85encode and z85decode cli tools, you might want to use the -g flag to install them globally.

Use

import {decode, encode} from "z85e"
import {readFileSync} from "fs"

const fileContentBuffer = readFileSync("./src/z85e.js", null)
const fileContentStr = readFileSync("./src/z85e.js", "utf-8")
const str = encode(fileContentBuffer)
const decodedStr = decode(str)
if (new TextDecoder().decode(decodedStr) !== fileContentStr) {
    throw new Error("Decode failed")
}

API

encode

encode takes a buffer or string and returns a string of it encoded in the z85e encoding. You can instead call encodeToUint8Array which performs the encoding and returns a Uint8Array of the character codes.

decode

decode can operate on strings or Uint8Arrays. It will decode a z85e encoded string to a Uint8Array.

streams

I have included web transform streams that can be included to encode or decode streams.

Here's encoding a stream from node.

#! /usr/bin/env node

import {Z85EncodeTransform} from "z85e"
import {Readable, Writable} from "stream"
import {argv} from "node:process";

let input = Readable.toWeb(process.stdin)
let output = Writable.toWeb(process.stdout)

if (argv[argv.length - 1] === "-z") {
    input = input.pipeThrough(new CompressionStream("gzip"))
}

Z85EncodeTransform
    .z85Encode(input)
    .pipeTo(output)

This also shows how easy it is to include gzip in the stream.

cli

cat ReadMe.md | z85encode -z > encodedReadMe.txt
cat encodedReadMe.txt
cat encodedReadMe | z85decode -z

The -z argument includes gzip compression / decompression which depending on the data being encoded can reduce the size of the final encoding.