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

@litert/encodings

v2.2.0

Published

The buffer-based encoding utility method for node.js.

Downloads

60

Readme

LiteRT/Encodings

npm version License GitHub issues GitHub Releases

The buffer-based encoding utility method for node.js.

Following types of encodings are supported:

Name | Description | Binary-Safe -------------|---------------------------------|:-----------: base64 | The standard BASE64 encoding. | Yes base64url | The URL-safe BASE64 encoding. | Yes base62x | The BASE62x encoding. | Yes base32 | The standard BASE32 encoding. | Yes hex | The hexadecimal encoding. | Yes urlencode | The purely URL-safe encoding. | Yes strict_uri | The extended URL-safe encoding. | No

Encoding urlencode

This is a real urlencode implement, it will escape all bytes as %xx format, excepting A-Z, a-z and 0-9. This is a binary-safe encoding.

Binary-safe means it could work with binary data perfectly, without gibberish. And it's all the same below.

Encoding uri

This is a simple reference of method encodeURIComponent, so it works as method encodeURIComponent does. And it's not a binary-safe encoding.

Encoding strict_uri

This is based on uri, but all special chars including "-", ".", "_", "!", "*", "(", ")", "~", "'" will be escaped. However, it's still not a binary-safe encoding.

NOTE: The data of strict_uri encoding, could be simply decoded by function decodeURIComponent.

Encoding base64url

This is based on base64, while charactors "=", "+", "/" will be replaced with URL-safe charactors. This is a binary-safe encoding.

Encoding base62x

This is a variation of base64. And it is a binary-safe encoding.

Installation

npm i @litert/encodings -S

Usage

import * as Enc from "@litert/encodings";

const hex = Enc.stringToHex("hello world");             // Encode a string into hex
const b62 = Enc.stringToBase62x("hello world");         // Encode a string into BASE62x
const b64 = Enc.stringToBase64("hello world");          // Encode a string into BASE64
const b64url = Enc.stringToBase64Url("hello world");    // Encode a string into BASE64URL
const b32 = Enc.stringToBase32("hello world");          // Encode a string into BASE32
const url = Enc.stringToUrlencode("hello world");       // Encode a string into URL
const strict = Enc.stringToStrictUri("hello world");    // Encode a string into Strict-URI

// Also, buffer is accepted as input.

Enc.bufferToHex(Buffer.from("hello world"));
Enc.bufferToBase62x(Buffer.from("hello world"));
Enc.bufferToBase64(Buffer.from("hello world"));
Enc.bufferToBase64Url(Buffer.from("hello world"));
Enc.bufferToBase32(Buffer.from("hello world"));
Enc.bufferToUrlencode(Buffer.from("hello world"));
Enc.bufferToStrictUri(Buffer.from("hello world"));

Enc.stringFromHex(hex);                         // Decode a hex-encoded data as a string
Enc.stringFromBase62x(b62);                     // Decode a BASE62x-encoded data as a string
Enc.stringFromBase64(b64);                      // Decode a BASE64-encoded data as a string
Enc.stringFromBase64Url(b64url);                // Decode a BASE64URL-encoded data as a string
Enc.stringFromBase32(b32);                      // Decode a BASE32-encoded data as a string
Enc.stringFromUrlencode(url);                   // Decode a urlencoded data as a string
Enc.stringFromStrictUri(strict);                // Decode a Strict-URI-encoded data as a string

Enc.bufferFromHex(hex);
Enc.bufferFromBase62x(b62);
Enc.bufferFromBase64(b64);
Enc.bufferFromBase64Url(b64url);
Enc.bufferFromBase32(b32);
Enc.bufferFromUrlencode(url);
Enc.bufferFromStrictUri(strict);

License

This library is published under Apache-2.0 license.