CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-unique-random

Generate random numbers that are consecutively unique

90

1.13x
Overview
Eval results
Files

task.mdevals/scenario-5/

Randomized Rotation Emitter

A module that cycles through provided items in random order without immediate repeats, even when a cycle resets.

Capabilities

Emits each item once per cycle

  • Given inputs like ["a", "b", "c"], the first full cycle returns all items exactly once in any order before repeating @test

Avoids repeats across cycles

  • The first emission after a cycle reset always differs from the most recent emission of the prior cycle @test

Shared call and iteration source

  • Mixing direct calls and iterator consumption advances a single sequence, allowing iteration to continue where calls left off @test

Single item input stable

  • When initialized with a single item such as ["only"], every emission yields that value @test

Implementation

@generates

API

export type ItemEmitter = (() => string) & Iterable<string>;

/**
 * Creates a stateful emitter over the provided items.
 * @param {readonly string[]} items Non-empty list of identifiers to rotate through.
 * @returns {ItemEmitter} Infinite sequence honoring randomized, non-repeating cycles.
 */
export function createItemEmitter(items: readonly string[]): ItemEmitter;

Dependencies { .dependencies }

unique-random { .dependency }

Provides exhaustive random sequencing over an integer range without repeating the last emitted value across cycle resets. @satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-unique-random

tile.json