Giter Site home page Giter Site logo

natoboram / based.ts Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 226 KB

A TypeScript library for working with arbitrary bases

Home Page: https://natoboram.github.io/based.ts/

License: GNU Lesser General Public License v3.0

TypeScript 81.88% JavaScript 18.12%
base36 uuid base10 base16 base2 base64 base62

based.ts's Introduction

based.ts

Node.js CI GitHub Pages GitHub Downloads NPM Downloads Dependabot Updates

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)

based.ts's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar natoboram avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.