TypeScript reference library for ZLID.
- ordered ZLIDs with the
defaultandhigh-throughputprofiles - ZLID-R random IDs
- ZLID-A keyed reversible aliases for ordered ZLIDs
- canonical and friendly Crockford Base32 parsing
NILandMAXsentinels- unknown-tag round-tripping as opaque 16-byte payloads
- the optional partition helper
- the official v0.1 golden conformance dataset
This is the initial TypeScript reference implementation for the v0.1 spec.
Install the pre-release from here:
npm install @zlid-io/[email protected]It will be available on npm shortly.
import { ZLID } from 'zlid-ts';
const ordered = ZLID.next();
const random = ZLID.random();
const highThroughput = ZLID
.generator({ profile: 'high-throughput' })
.next({ partition: 7 });
const alias = ZLID.alias(ordered, {
key: Uint8Array.from([0, 1, 2, 3]),
tweak: 'users|prod',
});
console.log(ordered.text());
console.log(random.text());
console.log(highThroughput.inspect());
console.log(ZLID.unalias(alias, {
key: Uint8Array.from([0, 1, 2, 3]),
tweak: 'users|prod',
}).text());ZLID.next(options?)
ZLID.generator(options?)
ZLID.random()
ZLID.alias(id, options)
ZLID.unalias(id, options)
ZLID.parse(text)
ZLID.fromBytes(bytes)
ZLID.text(id)
ZLID.bytes(id)
ZLID.inspect(id)
ZLID.compare(a, b)
ZLID.equals(a, b)
ZLID.partition(input, options?)ZLID.next() always emits the ordered default profile. To emit high-throughput, create a generator with a fixed profile and keep that profile stable for the logical ordered stream.
src/— library sourcetest/— TypeScript test suiteconformance/— official v0.1 golden dataset and checksum