https://github.com/natoboram/based.ts
A TypeScript library for working with arbitrary bases
https://github.com/natoboram/based.ts
base10 base16 base2 base36 base62 base64 uuid
Last synced: 3 months ago
JSON representation
A TypeScript library for working with arbitrary bases
- Host: GitHub
- URL: https://github.com/natoboram/based.ts
- Owner: NatoBoram
- License: lgpl-3.0
- Created: 2024-01-06T20:25:01.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-01T08:06:26.000Z (3 months ago)
- Last Synced: 2025-04-02T22:06:12.763Z (3 months ago)
- Topics: base10, base16, base2, base36, base62, base64, uuid
- Language: TypeScript
- Homepage: https://natoboram.github.io/based.ts/
- Size: 392 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yaml
- License: LICENSE.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# `based.ts`
[](https://github.com/NatoBoram/based.ts/actions/workflows/node.js.yaml) [](https://github.com/NatoBoram/based.ts/actions/workflows/github-pages.yaml) [](https://github.com/NatoBoram/based.ts/releases) [](https://www.npmjs.com/package/@natoboram/based.ts) [](https://github.com/NatoBoram/based.ts/actions/workflows/dependabot/dependabot-updates)
A TypeScript library for working with arbitrary bases.
## Installation
It can be installed globally if you want to generate base36-encoded UUIDs.
```sh
pnpm install --global @natoboram/based.ts
basedts
``````log
Base 36 UUID: 2pcugbwbg50o24pnu8h3u1f0b
```Proper CLI options are planned for the future, but for now that's all I needed this package for.
## Usage
```sh
pnpm i -D @natoboram/based.ts
``````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)
```