Sign inSign up

natoboram/based.ts

By natoboram

•Updated 4 months ago

A MCP server for working with arbitrary bases

Image
0

793

natoboram/based.ts repository overview

⁠@natoboram/based.ts⁠

Node.js CI Docker CI CodeQL Coverage GitHub Pages IPFS GitHub Downloads NPM Downloads JSR Score Docker Pulls Dependabot Updates Wakapi CodeRabbit Pull Request Reviews

A TypeScript library for working with arbitrary bases.

⁠CLI

It can be installed globally if you want to convert numbers or generate UUIDs from the terminal.

pnpm add --global @natoboram/based.ts
pnpm add --global jsr:@natoboram/based-ts
Usage: basedts convert [options] <number>

Convert a number from a base in a space to another base in another space

Arguments:
  number                The number to convert

Options:
  --from-base <base>    The base of the number (default: "10")
  --from-space <space>  The space of the number to convert from (default: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/")
  --to-base <base>      The base to convert to (default: "10")
  --to-space <space>    The space to convert the number to (default: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/")
Usage: basedts uuid [options]

Generate a UUID in a different base with a different space than normal UUIDs

Options:
  --base <base>    The base of the UUID to generate (default: "16")
  --space <space>  The space of the UUID to generate (default: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/")
  -h, --help       Display help for command

⁠Library

pnpm add @natoboram/based.ts
pnpm add jsr:@natoboram/based-ts
import { toBase, basedToBigInt } from "@natoboram/based.ts"

// Convert between two bases
const bigInt = basedToBigInt("69", 10n)
const based = toBase(bigInt, 16n)

console.log(based) // 45
import { Based } from "@natoboram/based.ts"

// Perform operations on numbers of different bases
const four = new Based("4", 64n)
const two = new Based("2", 16n)
const result = four.divide(two).to(10n)

console.log(result.value) // 2

⁠License

This Source Code Form is subject to the terms of the Mozilla Public License v2.0. If a copy of the MPL was not distributed with this file, you can obtain one at https://mozilla.org/MPL/2.0⁠.

Tag summary

Content type

Image

Digest

sha256:445f71306…

Size

139.9 MB

Last updated

4 months ago

docker pull natoboram/based.ts