Package Exports
- @mhysko/s-uuid
- @mhysko/s-uuid/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@mhysko/s-uuid) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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'