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

fast-color-generator

v2.0.0

Published

Super fast and efficient pseudo-random color generator, powered by a Linear Congruential Generator (LCG).

Readme

Fast Color Generator Build

Fast Color Generator is a high-performance JavaScript library for generating pseudo-random colors efficiently. This utility uses a Linear Congruential Generator (LCG) for deterministic color generation, making it ideal for applications requiring random or seeded colors, such as data visualization, gaming, and procedural art.

Features

  • High-Performance: Efficient color generation with a minimal memory footprint (Up to 2x faster!)
  • Predictability and Seedable: Deterministic color generation based on a seed value, allowing you to generate the same sequence of colors consistently.
  • Versatile API: Easy-to-use getter and setter methods for hex and RGB values.
  • Lightweight: No external dependencies, perfect for high-performance use cases.
  • Type-safe and tested: Written in typescript and has a 100% test coverage through vitest unit testing.

Installation

Install the package via npm:

npm install fast-color-generator --save
pnpm install fast-color-generator --save

Usage

Here’s how to use the Fast Color Generator:

import FastColorGenerator from "fast-color-generator";

// Create a new generator instance with an optional seed
const generator = new FastColorGenerator(12345);

// Generate the next color
generator.next();

// Get the current color
console.log(generator.hex); // Output: #3a2f1c (example)
console.log(generator.rgb); // Output: { r: 58, g: 47, b: 28 }

// Set a specific color
generator.hex = "#ff8800";
generator.rgb = { r: 255, g: 136, b: 0 };

API

new FastColorGenerator(seed?: number)

Creates a new Fast Color Generator instance. If no seed is provided, the current date as an integer is used.

  • Parameters:
    • seed (number): A 32-bit integer used as the starting state.

next()

Advances the internal state to generate the next color.


hex: string

Gets or sets the current color as a hexadecimal string in the format #rrggbb.

  • Getter Example:

    console.log(generator.hex); // "#3a2f1c"
  • Setter Example:

    generator.hex = "#00ff00";

rgb: { r: number; g: number; b: number }

Gets or sets the current color as an RGB object.

  • Getter Example:

    console.log(generator.rgb); // { r: 58, g: 47, b: 28 }
  • Setter Example:

    generator.rgb = { r: 200, g: 150, b: 100 };

Benchmark Results

Performance Comparison

| Colors Generated | Simple Function (ms) | Fast Color Generator (ms) | | ---------------- | -------------------- | ------------------------- | | 1 | 0.0033 | 0.01085 | | 100 | 0.02345 | 0.09258 | | 1,000 | 0.26076 | 0.33389 | | 10,000 | 1.43601 | 0.82281 | | 100,000 | 12.48264 | 6.02200 | | 1,000,000 | 123.56793 | 58.55502 | | 16,777,216 | 2053.39782 | 946.79718 |

The Fast Color Generator is more efficient for large-scale color generation, outperforming even the most simple random color generator implementation significantly as the dataset grows. However, due to the initialization cost of its constructor, it should be used with caution for small-scale operations.


Acknowledgements

The Linear Congruential Generator (LCG) algorithm used in this library was originally published in 1958 by W. E. Thomson and A. Rotenberg.


Contributing

Contributions are welcome! Feel free to report issues, suggest features, or submit pull requests on the GitHub repository.


License

This project is licensed under the MIT License. See the LICENSE file for details.