A universally-unique, lexicographically-sortable, identifier generator
78
Build a utility that converts Unix timestamps (in milliseconds) into lexicographically sortable string representations. This is useful for creating time-based identifiers that maintain natural sort order.
Your implementation should:
Create a module that exports a function to encode timestamps. The function should:
The following test cases should pass:
@generates
/**
* Encodes a timestamp into a lexicographically sortable string representation.
*
* @param timestamp - The timestamp in milliseconds to encode
* @param length - The desired length of the encoded string (default: 10)
* @returns A string representation of the timestamp
* @throws Error if the timestamp is invalid (negative, NaN, or too large)
*/
export function encodeTimestamp(timestamp: number, length?: number): string;Provides unique identifier generation with lexicographic sorting capabilities.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-ulidevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10