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

@lihs-ie/forger-ts

v0.0.2

Published

A library for generating test data

Readme

forger-ts

A TypeScript library for generating test data with deterministic, seed-based randomness.

Installation

npm install -D @lihs-ie/forger-ts
# or
pnpm add -D @lihs-ie/forger-ts

Features

  • Deterministic data generation using seeds
  • Type-safe API with full TypeScript support
  • Built-in molds for strings, enums, and maps
  • Create custom molds for any data type

Usage

Basic Example

import { Mold, Forger, StringMold } from "@lihs-ie/forger-ts";

// Define value objects
type UserID = { value: string };
type UserName = { value: string };

type User = {
  id: UserID;
  name: UserName;
};

// Create molds for value objects
const UserIDMold = Mold<UserID, UserID>({
  pour: (props) => props,
  prepare: (overrides, seed) => ({
    value: overrides.value ?? `user-${seed}`,
  }),
});

const UserNameMold = Mold<UserName, UserName>({
  pour: (props) => props,
  prepare: (overrides, seed) => ({
    value: overrides.value ?? `User ${seed}`,
  }),
});

// Create forgers for value objects
const userIDForger = Forger(UserIDMold);
const userNameForger = Forger(UserNameMold);

// Compose to create UserMold
const UserMold = Mold<User, User>({
  pour: (props) => props,
  prepare: (overrides, seed) => ({
    id: overrides.id ?? userIDForger.forgeWithSeed(seed),
    name: overrides.name ?? userNameForger.forgeWithSeed(seed),
  }),
});

// Create a forger
const userForger = Forger(UserMold);

// Generate test data
const user = userForger.forge();
// { id: { value: "user-123456" }, name: { value: "User 123456" } }

const users = userForger.forgeMulti(5);
// Array of 5 unique users

// With overrides
const admin = userForger.forge({ name: { value: "Admin" } });
// { id: { value: "user-789012" }, name: { value: "Admin" } }

// Deterministic generation with seed
const consistentUser = userForger.forgeWithSeed(42);
// Always returns the same user for seed 42

Built-in Molds

StringMold

Generate random strings with configurable length and character set.

import { Forger, StringMold, Characters } from "@lihs-ie/forger-ts";

// Default: 1-255 characters, alphanumeric
const stringForger = Forger(StringMold());

// Custom length range
const shortStringForger = Forger(StringMold(5, 10));

// Custom character set
const numericForger = Forger(StringMold(10, 10, Characters.NUMERIC));
const slugForger = Forger(StringMold(10, 20, Characters.SLUG));

Available character sets in Characters:

  • ALPHANUMERIC - a-z, A-Z, 0-9
  • ALPHA - a-z, A-Z
  • NUMERIC - 0-9
  • SLUG - a-z, 0-9, -
  • SYMBOL - Special characters

EnumMold

Generate random values from an enum or object.

import { Forger, EnumMold } from "@lihs-ie/forger-ts";

const Status = {
  Active: "active",
  Inactive: "inactive",
  Pending: "pending",
} as const;

const statusForger = Forger(EnumMold(Status));

const status = statusForger.forge();
// "active" | "inactive" | "pending"

// Exclude specific values
const nonPendingStatus = statusForger.forge({ exclusion: "pending" });

// Exclude multiple values
const exclusions = new Set(["inactive", "pending"] as const);
const activeOnly = statusForger.forge({ exclusion: exclusions });

MapMold

Generate random maps with typed keys and values.

import { Forger, MapMold, StringMold } from "@lihs-ie/forger-ts";

const keyMold = StringMold(5, 5);
const valueMold = StringMold(10, 10);

const mapForger = Forger(MapMold(keyMold, valueMold));

const map = mapForger.forge();
// Map with 1-10 entries

API Reference

Mold

Creates a mold that defines how to generate instances of a type.

const mold = Mold<T, P>({
  pour: (properties: P) => T,
  prepare: (overrides: Partial<P>, seed: number) => P,
});

Forger

Creates a forger from a mold for generating test data.

const forger = Forger(mold);

// Generate a single instance with random seed
forger.forge(overrides?)

// Generate multiple instances with random seeds
forger.forgeMulti(size, overrides?)

// Generate with a specific seed (deterministic)
forger.forgeWithSeed(seed, overrides?)

// Generate multiple with sequential seeds starting from seed
forger.forgeMultiWithSeed(size, seed, overrides?)

License

MIT