@ganbarodigital/ts-lib-uuid-shortener
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

UUID Shortener for Typescript

Introduction

This TypeScript library will shorten any RFC 4122 UUID in a URL-friendly way.

Quick Start

# run this from your Terminal
npm install @ganbarodigital/ts-lib-uuid-shortener
// add this import to your Typescript code
import { uuidToBase64Url } from "@ganbarodigital/ts-lib-uuid-shortener/lib/v1"

VS Code users: once you've added a single import anywhere in your project, you'll then be able to auto-import anything else that this library exports.

V1 API

uuidToBase32Url()

import { Uuid } from "@ganbarodigital/ts-lib-uuid-parser/lib/v1";
import { uuidToBase32Url } from "@ganbarodigital/ts-lib-uuid-shortener/lib/v1"

export function uuidToBase32Url(uuid: Uuid): string;

uuidToBase32Url() is a data transform. It converts a Uuid into a base32url-encoded string.

For example:

import { uuidFromFormatted } from "@ganbarodigital/ts-lib-uuid-parser/lib/v1";
import { uuidToBase32Url } from "@ganbarodigital/ts-lib-uuid-shortener/lib/v1"

const uuid = uuidFromFormatted("a968f2c6-b61b-4f88-a0e0-ec370a981a2e");
const shortened = uuidToBase32Url(inputValue);
console.log(shortened);
// outputs "59d3pcddgr9u4a1o7c6s59g6he";

uuidToBase36Url()

import { Uuid } from "@ganbarodigital/ts-lib-uuid-parser/lib/v1";
import { uuidToBase36Url } from "@ganbarodigital/ts-lib-uuid-shortener/lib/v1"

export function uuidToBase36Url(uuid: Uuid): string;

uuidToBase36Url() is a data transform. It converts a Uuid into a base36url-encoded string.

For example:

import { uuidFromFormatted } from "@ganbarodigital/ts-lib-uuid-parser/lib/v1";
import { uuidToBase36Url } from "@ganbarodigital/ts-lib-uuid-shortener/lib/v1"

const uuid = uuidFromFormatted("a968f2c6-b61b-4f88-a0e0-ec370a981a2e");
const shortened = uuidToBase36Url(inputValue);
console.log(shortened);
// outputs "a127dxfucuekzxf65qw12c84u";

uuidToBase64Url()

import { Uuid } from "@ganbarodigital/ts-lib-uuid-parser/lib/v1";
import { uuidToBase64Url } from "@ganbarodigital/ts-lib-uuid-shortener/lib/v1"

export function uuidToBase64Url(uuid: Uuid): string;

uuidToBase64Url() is a data transform. It converts a Uuid into a base64url-encoded string.

For example:

import { uuidFromFormatted } from "@ganbarodigital/ts-lib-uuid-parser/lib/v1";
import { uuidToBase64Url } from "@ganbarodigital/ts-lib-uuid-shortener/lib/v1"

const uuid = uuidFromFormatted("a968f2c6-b61b-4f88-a0e0-ec370a981a2e");
const shortened = uuidToBase64Url(inputValue);
console.log(shortened);
// outputs "qWjyxrYbT4ig4Ow3CpgaLg";

NPM Scripts

npm run clean

Use npm run clean to delete all of the compiled code.

npm run build

Use npm run build to compile the Typescript into plain Javascript. The compiled code is placed into the lib/ folder.

npm run build does not compile the unit test code.

npm run test

Use npm run test to compile and run the unit tests. The compiled code is placed into the lib/ folder.

npm run cover

Use npm run cover to compile the unit tests, run them, and see code coverage metrics.

Metrics are written to the terminal, and are also published as HTML into the coverage/ folder.

Readme

Keywords

none

Package Sidebar

Install

npm i @ganbarodigital/ts-lib-uuid-shortener

Weekly Downloads

0

Version

0.0.3

License

BSD-3-Clause

Unpacked Size

20.2 kB

Total Files

20

Last publish

Collaborators

  • stuartherbert