CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/npm-ulid

tessl install tessl/npm-ulid@3.0.0

A universally-unique, lexicographically-sortable, identifier generator

Agent Success

Agent success rate when using this tile

78%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.34x

Baseline

Agent success rate without this tile

58%

task.mdevals/scenario-10/

Deterministic ULID Generator

Build a deterministic ULID generation system that produces repeatable identifiers for testing and development environments. The system should allow seeding a pseudo-random number generator to create predictable, reproducible ULID sequences while maintaining the ULID format and properties.

Requirements

Seeded Generator

Create a seeded pseudo-random number generator that accepts a numeric seed and produces consistent random values. The generator should return values between 0 and 1, suitable for use with the identifier generation library.

Deterministic ID Generation

Implement a function that generates identifiers using a custom seeded random number generator. The function should:

  • Accept a seed value to initialize the random number generator
  • Generate identifiers that are reproducible given the same seed
  • Return valid, properly formatted identifiers
  • Maintain the standard identifier structure (timestamp + random component)

Sequence Generation

Create a function that generates a sequence of identifiers using a seeded generator. The function should:

  • Accept a seed value and a count parameter
  • Generate the specified number of identifiers
  • Use a fixed timestamp (1609459200000 - January 1, 2021 00:00:00 UTC) for all identifiers in the sequence
  • Return an array of identifiers

All identifiers must be valid and conform to the expected 26-character format.

Test Cases

  • Given seed 12345, generating two separate identifiers with the same seed produces identical results @test
  • Given seed 42, generating a sequence of 3 identifiers returns an array with exactly 3 identifiers @test
  • All generated identifiers are valid and pass validation checks @test

Implementation

@generates

API

/**
 * Creates a seeded pseudo-random number generator
 * @param seed - Numeric seed value
 * @returns A function that returns numbers between 0 and 1
 */
export function createSeededPRNG(seed: number): () => number;

/**
 * Generates a deterministic identifier using a seeded PRNG
 * @param seed - Numeric seed value
 * @param timestamp - Optional timestamp in milliseconds
 * @returns A 26-character identifier string
 */
export function generateDeterministicULID(seed: number, timestamp?: number): string;

/**
 * Generates a sequence of deterministic identifiers
 * @param seed - Numeric seed value
 * @param count - Number of identifiers to generate
 * @returns Array of identifier strings
 */
export function generateSequence(seed: number, count: number): string[];

Dependencies { .dependencies }

ulid { .dependency }

Provides unique identifier generation support with custom PRNG capability.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/ulid@3.0.x
tile.json