Skip to content

createReverseTimestampId

createReverseTimestampId<Brand>(brand, opts?): ReverseTimestampCodec<Brand>

Defined in: src/codecs/reverse/index.ts:135

Creates a Reverse Timestamp codec for brand (three lowercase a–z characters).

IDs sort newest-first: the 48-bit timestamp field is bitwise-inverted before encoding, so lexicographic ID order equals descending creation-time order. extractTimestamp inverts back to recover the original millisecond.

Brand extends string

Brand & ValidBrand<Brand>

Entity type brand validated once at construction.

ReverseTimestampOptions = {}

Optional now, rng, and allowDuplicateBrand overrides.

ReverseTimestampCodec<Brand>

const posts = createReverseTimestampId("pst");
const id = posts.generate(); // Id<"pst"> (newest-first sort)
posts.extractTimestamp(id); // Date