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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@night_slayer/fake-js

v1.1.0

Published

This package contains fake data for development purposes. Which includes fake names, emails, phone numbers, addresses, etc.

Readme

@night_slayer/fake-js

A lightweight, enterprise-grade fake data generator for development and testing. Now with TypeScript support, seeded randomness, and a flexible API.

Features

  • 🔒 Type Safe: Written in TypeScript with full type definitions.
  • 🧠 Smart Consistency: Emails match names (e.g., "John Doe" -> "[email protected]").
  • 📅 Dynamic Dates: Generates realistic past, future, and birth dates.
  • 🎲 Deterministic: Support for seeded randomness for reproducible tests.
  • 🌍 Localization: Support for 10+ locales (en, es, fr, de, it, pt, ru, ja, zh, hi).
  • 🛠️ CLI Tool: Generate data directly from the command line.
  • 🔌 Extensible: Add custom data generators easily.
  • 📦 Tree Shakeable: Granular access to data generators.
  • Fast: Lightweight and efficient.
  • 📚 Rich Data: Over 100+ items per category for each locale.

Installation

npm install @night_slayer/fake-js

Usage

Basic Usage

Import the Faker class and create an instance to generate data.

import { Faker } from '@night_slayer/fake-js';

const faker = new Faker();

// Generate a single user object
const user = faker.createUser();
console.log(user);
/*
{
  id: 1,
  name: 'John Doe',
  email: '[email protected]',
  birthdate: 1990-05-15T00:00:00.000Z,
  ...
}
*/

// Generate multiple users
const users = faker.createUsers(5);

Deterministic Data (Seeding)

Pass a seed to the constructor to generate the same data every time. This is perfect for unit tests that need to be consistent.

const faker = new Faker({ seed: 123 });

console.log(faker.person.name()); // Always the same name for seed 123

Localization

Initialize Faker with a locale to generate localized data.

// Generate Spanish data
const faker = new Faker({ locale: 'es' });

console.log(faker.person.name()); // "Juan Perez"
console.log(faker.location.city()); // "Madrid"

Supported locales: en, es, fr, de, it, pt, ru, ja, zh, hi.

Granular Access & Consistency

You can access specific data generators directly.

const faker = new Faker();

// Smart Consistency
const name = faker.person.name();
const email = faker.internet.email(name); // "[email protected]"

// Dynamic Dates
const past = faker.date.past();   // Random date in past year
const future = faker.date.future(); // Random date in future year
const birthdate = faker.person.birthdate({ min: 18, max: 65 }); // Age 18-65

console.log(faker.phone.number());
console.log(faker.location.city());

Extensibility

Add your own custom data generators.

const faker = new Faker();

faker.addGenerator('customId', () => `ID-${Math.random()}`);

const user = faker.createUser();
console.log(user.customId); // "ID-0.123..."

CLI Usage

Generate data directly from your terminal.

# Generate 5 users with French locale
npx fake-js --count 5 --locale fr

# Save to file
npx fake-js --count 100 > users.json

API Reference

new Faker(options?)

  • options.seed (optional): A number or string to seed the random number generator.
  • options.locale (optional): The locale to use (default: 'en').

Methods

  • createUser(id?: number): User: Generates a complete user object with consistent data.
  • createUsers(count?: number): User[]: Generates an array of user objects.

Modules

  • faker.person: name(), birthdate(options?), educationLevel(), hobby()
  • faker.internet: email(name?)
  • faker.date: past(years?), future(years?), between(from, to)
  • faker.phone: number()
  • faker.location: city(), address()
  • faker.work: jobTitle(), companyName(), skill(), skills(count)

License

MIT