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

random-test-values

v2.0.0

Published

A typescript library for generating random values for testing

Readme

Random Test Values

Build Status

Installing

npm install random-test-values --save

Using the Library

import { Random } from 'random-test-values';

var someNumber: number = Random.Number();
var someString: string = Random.String();
var someBool: boolean = Random.Boolean();
var someObject: SomeType = Random.Object(SomeType);

Method Breakdown

String

By default the only characters in a generated string are alphanumeric characters of any case.

// Generate a random String
Random.String();

// Specify a min/max length for the string
Random.String({minLength: 5, maxLength: 50});

// Specify characters that are allowed in generated string
Random.String({whiteListString: "1234567890"}); // Would only generate numbers

// Specify characters to exclude in generated string
Random.String({blackListString: "1234567890"}); // Would only generate alpha strings

RegexString

Uses the library https://github.com/fent/randexp.js? to generate strings that match a pattern

Random.RegexString(/hello World/); // Would generate "hello World"
Random.RegexString(/hello World!*/, {minRepetition: 500}); // Would Generate "hello World" with 500+ "!"

Number

Generates an integer

Random.Number(); // Creates a random integer
Random.Number({min: 5, max: 20}); // Generates a number between 5 and 20

DecimalNumber

Like Number but generates a decimal n umber

Random.DecimalNumber(); // Creates a random decimal number
Random.DecimalNumber({min: 5, max: 20, maxDecimalPlaces: 2}); // Creates a random decimal number between 5 and 20, rounding to 2 decimal places.

Boolean

Creates a random boolean, not the best for testing though.

Random.Boolean(); // Creates a boolean, either true or false.

Date

Creates a random valid date.

Random.Date(); // Creates a Date
Random.Date({after: new Date(), before: new Date()}); // Creates a date between the after and before dates

Array

Creates a random array of specified length and type

Random.Array(TestObject, 3); // Creates an array of TestObject of length 3
Random.Array(String, 5); // Creates an array of Strings of length 5

Object

Creates a random object of a given type

NOTE: Object properties must be initilized in the constructor of the class, otherwise they will not be randomly assigned in Random.Object!

Random.Object(TestObject); // Creates a random TestObject