@natoboram/based.ts
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

based.ts

GitHub Pages Node.js CI

A TypeScript library for working with arbitrary bases.

Installation

It can be installed globally if you want to generate base36-encoded UUIDs.

pnpm install --global @natoboram/based.ts
basedts
Base 36 UUID: 2pcugbwbg50o24pnu8h3u1f0b

Proper CLI options are planned for the future, but for now that's all I needed this package for.

Usage

pnpm i -D @natoboram/based.ts
import {
	basedToBigInt,
	bytesToBigInt,
	getRandomBytes,
	toBase,
} from "@natoboram/based.ts"

// Generate a base36-encoded UUID
const bytes = getRandomBytes()
const bigInt = bytesToBigInt(bytes)
const base36 = toBase(bigInt, 36n)
console.log("Base 36 UUID:", base36)

// Convert between two bases
const base64 = toBase(basedToBigInt("20zsnycqen1k898slr7xgnc9t", 36n), 64n)

Package Sidebar

Install

npm i @natoboram/based.ts

Weekly Downloads

1

Version

0.0.2

License

LGPL-3.0-or-later

Unpacked Size

26.8 kB

Total Files

39

Last publish

Collaborators

  • natoboram