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-8/

Random Number Generator Validator

Build a utility that validates and reports on the quality of random number generators available in different JavaScript environments.

Requirements

Your utility should provide functionality to:

  1. Detect the available random number generator in the current environment
  2. Generate a sample of random values using the detected generator
  3. Validate that the generator produces values in the expected range (0 to 1)
  4. Return a report containing:
    • The number of samples generated
    • Whether all samples are within the valid range
    • Basic statistics (minimum and maximum values found)

The utility should work correctly across different JavaScript environments (Node.js, browsers, etc.) and should automatically adapt to use the most appropriate random number generator available.

Implementation

@generates

API

/**
 * Validates the random number generator and returns a quality report.
 *
 * @param {number} sampleCount - Number of random samples to generate for validation (default: 1000)
 * @returns {Object} Report object with validation results
 * @returns {number} return.samples - Number of samples generated
 * @returns {boolean} return.valid - Whether all samples are in range [0, 1)
 * @returns {number} return.min - Minimum value found
 * @returns {number} return.max - Maximum value found
 */
function validateRNG(sampleCount = 1000) {
  // IMPLEMENTATION HERE
}

module.exports = { validateRNG };

Test Cases

Basic Validation

  • Validates RNG with default sample count and returns all required fields @test
  • Validates RNG with custom sample count (100 samples) and returns correct sample count in report @test

Range Checking

  • All generated samples are within valid range [0, 1) @test
  • Report indicates valid=true when all samples are in range @test

Dependencies { .dependencies }

ulid { .dependency }

Provides cross-environment random number generation detection

@satisfied-by

Version

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