0.1.8 • Published 5 years ago

base-uuid v0.1.8

Weekly downloads
5
License
MIT
Repository
github
Last release
5 years ago

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

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago