1.1.0 • Published 7 months ago

@mhysko/s-uuid v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

s-uuid

s-uuid is a tiny wrapper on uuid that allows to translate standard UUIDs into shorter - or just different - formats and back.

This is a remake of short-uuid.

Usage

import { translate, generate, validate } from 's-uuid';

// Translate generated uuid V7 to Base58 format and back
translate('017f22e2-79b0-7cc3-98c4-dc0c0c07398f'); // 'BihbxwwQ4NZZpKRH9JDCz'
translate('BihbxwwQ4NZZpKRH9JDCz'); // '017f22e2-79b0-7cc3-98c4-dc0c0c07398f'

// Generate uuid V4 in Base58 format. By default generate func uses uuid V4
generate(); // '73WakrfVbNJBaAmhQtEeDv'

// validation
validate('017f22e2-79b0-7cc3-98c4-dc0c0c07398f'); // true
validate('BihbxwwQ4NZZpKRH9JDCz'); // true
validate(''); // false
validate(undefined); // false
validate('00000000-0000-0000-0000-000000000000'); // true

The default behavior can be changed

import { v7, Suuid } from 's-uuid';

const suuid = new Suuid(v7);

const suuid = suuid.generate(); // 'BihbxwwQ4NZZpKRH9JDCz'
const uuid = suuid.translate(suuid); // '017f22e2-79b0-7cc3-98c4-dc0c0c07398f'
suuid.translate(uuid); // 'BihbxwwQ4NZZpKRH9JDCz'
1.1.0

7 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.0

7 months ago