base-uuid

0.1.8 • Public • Published

base-uuid

GitHub license NPM Package Build Status

Simple UUID shortener

Installation

npm install base-uuid

Usage

const baseUuid = require('base-uuid');

const base62 = baseUuid(62); // Create a base62 encoder/decoder

// UUIDs
const uuid1 = '00000000-0000-4000-8000-000000000000';
const uuid2 = 'ffffffff-ffff-4fff-bfff-ffffffffffff';

// Shorten UUIDs
const encoded1 = base62.encode(uuid1); // 1vGeH72LxVtxKg
const encoded2 = base62.encode(uuid2); // 7N42dgm5pw9utfkXp3nwyH

// Decode shortened UUIDs
const decoded1 = base62.decode(encoded1); // 00000000-0000-4000-8000-000000000000
const decoded2 = base62.decode(encoded2); // ffffffff-ffff-4fff-bfff-ffffffffffff

API

const baseN = baseUuid([radix]) Creates an encoder/decoder using radix. The default radix is 64.

const str = baseN.encode(uuid) Creates a shortened UUID string.

const uuid = baseN.decode(str) Decodes a shortened UUID.

const uuid = baseN.decodePlain(str) Like decode but produces UUID without dashes.

baseN.base Radix of the shortener, integer between 16...64.

Credit

Based on uuid-base62

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i base-uuid

Weekly Downloads

0

Version

0.1.8

License

MIT

Unpacked Size

5.71 kB

Total Files

6

Last publish

Collaborators

  • teabore