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

@megaorm/faker

v1.0.0

Published

This package provides a set of methods to generate realistic, randomized data for your database seeding needs.

Downloads

3

Readme

MegaORM Faker

This package provides a set of methods to generate realistic, randomized data for your database seeding needs. Whether you need user details, location information, or internet-related data, @megaorm/faker has you covered.

Table of Contents

  1. Installation
  2. MegaFaker API
  3. Extending MegaFaker

Installation

To install this package, run the following command:

npm install @megaorm/faker

MegaFaker API

Import MegaFaker from @megaorm/faker:

const { MegaFaker } = require('@megaorm/faker');

Create an Instance:

const faker = new MegaFaker();

Now you are ready to generate some fake data!

Personal Information

Generate realistic user details:

console.log(faker.firstName()); // e.g., "john"
console.log(faker.lastName()); // e.g., "Doe"
console.log(faker.name()); // e.g., "john Doe"
console.log(faker.email()); // e.g., "[email protected]"
console.log(faker.gmail()); // e.g., "[email protected]"
console.log(faker.password()); // e.g., "p@ssw0rd123"
console.log(faker.username()); // e.g., "johndoe92"

Location Information

Generate data for geographic and address fields:

console.log(faker.continent()); // e.g., "Asia"
console.log(faker.country()); // e.g., "Canada"
console.log(faker.city()); // e.g., "San Francisco"
console.log(faker.street()); // e.g., "River Street"
console.log(faker.address()); // e.g., "1234 Maple St, Toronto, Canada"

Text Generation

Generate filler text for your database:

console.log(faker.sentence()); // e.g., "Random sentence."
console.log(faker.paragraph()); // e.g., "Random paragraph."
console.log(faker.text()); // e.g., "Random text."
console.log(faker.lorem()); // e.g., "Random lorem."

Professional Information

Generate data for job-related fields:

console.log(faker.job()); // e.g., "Software Engineer"
console.log(faker.company()); // e.g., "Global Solutions"

Product Information

Simulate realistic product data:

console.log(faker.product()); // e.g., "Pro Laptop"
console.log(faker.sku()); // e.g., "123-456-789"
console.log(faker.price()); // e.g., 45.67
console.log(faker.category()); // e.g., "Sport" (45 unique categories)
console.log(faker.card('#### #### #### ###')); // e.g., "1234 5678 9012 345"

Web and Internet Data

Generate realistic web-related details:

console.log(faker.path()); // e.g., "blog/introduction"
console.log(faker.domain()); // e.g., "example.com"
console.log(faker.url()); // e.g., "https://shop.net/products/pricing"
console.log(faker.ipv4()); // e.g., "192.168.1.1"
console.log(faker.ipv6()); // e.g., "2001:0db8:85a3:0000:0000:8a2e:0370:7334"

Other Data

Generate a variety of additional data types:

console.log(faker.boolean()); // e.g., 1 | 0
console.log(faker.date()); // e.g., "2024-11-01"
console.log(faker.time()); // e.g., "14:30:00"
console.log(faker.datetime()); // e.g., "2024-11-01 14:30:00"
console.log(faker.zip()); // e.g., "90210"
console.log(faker.phone('+1 (###) ###-####')); // e.g., "+1 (123) 612-3456"
console.log(faker.id(100)); // e.g., 13 (number between 0 and 100)

Random Functions

The MegaFaker library includes helper functions for custom randomization:

const {
  randomBetween, // Generate a random number in a range
  randomIndex, // Get a random index from an array
  randomSelect, // Select a random item from an array
  randomChar, // Generate a random character
} = require('@megaorm/faker');

console.log(randomBetween(0, 10)); // e.g., 3
console.log(randomIndex(['john', 'Doe'])); // e.g., 0
console.log(randomSelect(['john', 'Doe'])); // e.g., 'john'
console.log(randomChar()); // e.g., 'A'

Extending MegaFaker

You can create custom faker methods and extend the functionality of MegaFaker. Here’s how you can do it:

Custom Faker Function

Leverage the provided random functions to define your own data generators. For example, create a function to generate random TV shows:

export function tvShow() {
  return randomSelect([
    'Breaking Bad',
    'Friends',
    'Game of Thrones',
    'Stranger Things',
  ]);
}

console.log('TV Show:', tvShow()); // e.g., "Friends"

Extending MegaFaker Class

For more advanced use cases, extend the MegaFaker class to incorporate additional functionality directly into the faker instance.

const { MegaFaker } = require('@megaorm/faker');

class BetaFaker extends MegaFaker {
  // Generate a random tv show
  tvShow() {
    return this.random.select([
      'The Office',
      'Parks and Recreation',
      'The Crown',
      'Black Mirror',
    ]);
  }

  // Generate a random 5 stars rating
  rating() {
    const left = this.random.between(1, 4); // 4
    const right = this.random.between(0, 9); // 5
    return Number(`${left}.${right}`); // 4.5
  }
}

module.exports = { BetaFaker };

Once extended, you can import your custom faker class, create an instance, and use the enhanced methods in your seeder files:

// Import `BetaFaker`
const { BetaFaker } = require('./BetaFaker');

// Create instance
const faker = new BetaFaker();

console.log(faker.tvShow()); // e.g., "The Crown"
console.log(faker.rating()); // e.g., 4.9

Why Extend MegaFaker?

  • Add domain-specific faker methods.
  • Maintain reusability by centralizing custom randomization logic.
  • Enhance the default API for niche use cases, improving productivity.

The MegaFaker API is your ultimate tool for generating realistic and diverse mock data. Let your creativity flow and streamline your database seeding!