CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-ulid

A universally-unique, lexicographically-sortable, identifier generator

78

1.34x
Overview
Eval results
Files

task.mdevals/scenario-7/

Sequential Base32 ID Generator

Build a generator that produces sequential Base32-encoded identifiers. The generator should start from a given Base32 string and produce subsequent identifiers in order.

Requirements

Your implementation should:

  1. Accept an initial Base32-encoded string as a starting point
  2. Generate the next identifier in sequence each time it's called
  3. Handle carry-over correctly when incrementing (e.g., 'Z' wraps to '0' and carries to the next position)
  4. Use Crockford's Base32 encoding

Test Cases

  • Starting with "0000", calling next() three times produces "0001", "0002", "0003" @test
  • Starting with "000Z", calling next() produces "0010" (handles carry-over correctly) @test
  • Starting with "ZZZY", calling next() produces "ZZZZ" (simple increment) @test

Implementation

@generates

API

/**
 * Creates a sequential Base32 identifier generator
 * @param initial - Starting Base32 string
 * @returns Generator function that produces the next identifier
 * @throws Error if initial string contains invalid Base32 characters
 */
export function createSequentialGenerator(initial: string): () => string;

Dependencies { .dependencies }

ulid { .dependency }

Provides Base32 manipulation utilities for identifier generation.

Install with Tessl CLI

npx tessl i tessl/npm-ulid

tile.json