npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bobbythecatfish/no-repeat

v1.1.1

Published

Get random preset strings or objects at any time without repetition

Readme

A utility class for randomly selecting items from an array without repetition. It ensures that each item is only picked once before resetting, while preventing the most recent item from being selected consecutively.

Ideal for scenarios that require randomized selection without repetition.

Written in TypeScript with no dependencies.

Installation

npm install --save no-repeat@npm:@bobbythecatfish/no-repeat

Usage

const NoRepeat = require("no-repeat");

// load data into NoRepeats
// strings are used for these demos, but it works with any variable type
const intros = new NoRepeat(data.intros);
const names = new NoRepeat(data.names);
const excuses = new NoRepeat(data.excuses);

function makeExcuse() {
    // generate a randomized and unique output
    return `<${intros.getRandom()}> <${names.getRandom()}> <${excuses.getRandom()}>!`;
}
// example output 1: "<It's been great talking to you, but> <Bobby> <is trying to tag me>!"
// example output 2: "<Look. I'll be completely honest with you.> <A snail> <has been perfecting its taco recipe and I gotta try it>!"

Advanced Usage

Reset-Delayed Options

const NoRepeat = require("no-repeat");

const firstSet = ["Tom", "David", "Bobby"];
const secondSet = ["Larry", "Terry", "Jerry"];

// Tom, David, and Bobby will be the only possible responses for the first 3 calls of getRandom().
const arr = new NoRepeat(firstSet, undefined, secondSet);
const a = arr.getRandom(); // Tom
const b = arr.getRandom(); // David
const c = arr.getRandom(); // Bobby
// At this point, arr is reset and the second set are mixed in with the first
// Bobby is not a possible result until the next reset since it was picked last
const d = arr.getRandom(); // David
const e = arr.getRandom(); // Larry
const f = arr.getRandom(); // Tom
...

Faster Reset

const NoRepeat = require("no-repeat");

const set = ["Tom", "David", "Bobby", "Larry", "Terry", "Jerry"];

// reset after returning 4 elements instead of all 6
const arr = new NoRepeat(set, 4);

const a = arr.getRandom(); // Terry
const b = arr.getRandom(); // David
const c = arr.getRandom(); // Tom
const d = arr.getRandom(); // Jerry
// at this point, arr is reset.
// Jerry is not a possible response until the next reset.
const e = arr.getRandom(); // Larry
const f = arr.getRandom(); // Tom
// another reset just for fun.
// Since this is a complete reset, Tom *is* a possible response despite being picked last.
arr.reset();
...

arr.resetAt can be changed at any time.

Adding to items

const NoRepeat = require("no-repeat");

const set = ["Tom", "David", "Bobby"];

const arr = new NoRepeat(set);
const a = arr.getRandom(); // Bobby

// add a new element into the mix
arr.items.push("Larry");

const b = arr.getRandom() // Larry

The same can be done with arr.used.push() to make it a possible selection after the next reset.