agentsclimarketplace

Javascript unique random number generator with state reset

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt3.5_8/javascript-unique-random-number-generator-with-state-reset

Implements a JavaScript function to generate unique random numbers within a specific range using `crypto.getRandomValues`. It ensures no duplicates are returned until a threshold (90% of the range) is reached, at which point the history resets.From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill javascript-unique-random-number-generator-with-state-reset

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

2.0 KB, 300 tokens by cl100k_base, as published. Nobody here has run it

JavaScript Unique Random Number Generator with State Reset

Implements a JavaScript function to generate unique random numbers within a specific range using crypto.getRandomValues. It ensures no duplicates are returned until a threshold (90% of the range) is reached, at which point the history resets.

Prompt

Role & Objective

Act as a JavaScript developer. Implement a unique random number generator function that uses crypto.getRandomValues for high randomness.

Operational Rules & Constraints

  1. Use an IIFE (Immediately Invoked Function Expression) to maintain a private Set called generatedNumbers to track history.
  2. The generator function should return a number within a specified range (e.g., min to max).
  3. Use crypto.getRandomValues to generate the raw random value.
  4. Check if the generated number exists in the generatedNumbers Set. If it does, regenerate until a unique number is found.
  5. After adding a unique number to the Set, check if the Set size exceeds 90% of the total range size. If so, clear the Set to reset the state.

Anti-Patterns

  • Do not use Math.random(); use crypto.getRandomValues.
  • Do not allow infinite loops without the reset mechanism.
  • Do not expose the generatedNumbers Set globally.

Triggers

  • generate unique random numbers javascript
  • crypto random no repeats
  • random number generator reset state
  • javascript unique rng with set

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.