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 🙏

© 2024 – Pkg Stats / Ryan Hefner

json-mock-factory

v1.0.1

Published

This package provides a versatile solution for dynamically generating JSON files populated with customizable user profiles or product details. Ideal for developers needing mock data for testing, prototyping, or demonstration purposes, it simplifies the cr

Downloads

9

Readme

json-mock-factory

json-mock-factory is a comprehensive tool for generating massive amounts of fake (but realistic) data for testing and development purposes. From user profiles to product details, this package provides an array of functions to simulate real-world data efficiently.

Installation

To install json-mock-factory, run the following command in your project directory:

npm install json-mock-factory
yarn add json-mock-factory

Usage

json-mock-factory provides a suite of functions to generate mock data for user profiles and product details. Here's how to use them:

Users

Generate and manipulate user-related data with the following functions:

saveRandomUsers(numUsers, filePath): Generates and saves numUsers unique random user profiles to the specified filePath.

generateRandomEmail(): Generates a single random email address.

generateRandomNames(): Generates a single random name.

generateRandomCompanyName(): Generates a single random company name.

generateRandomNationality(): Generates a single random nationality.

getDesignation(companyName): Gets a company designation based on the provided companyName.

getRandomCompanyDesignation(): Gets a random company designation.

getSalary(designation, experience): Gets a salary based on the provided designation and experience.

getRandomSalary(): Gets a random salary.

getRandomExperience(): Gets a random experience level.

generateRandomAddress(): Generates a single random address.

getRandomStreetName(): Gets a random street name.

getRandomCityName(): Gets a random city name.

getRandomState(): Gets a random state name.

getRandomZipCode(): Gets a random ZIP code.

const { saveRandomUsers, generateRandomEmail, generateRandomNames, generateRandomCompanyName, generateRandomNationality, getDesignation, getRandomCompanyDesignation, getSalary, getRandomSalary, getRandomExperience, generateRandomAddress, getRandomStreetName, getRandomCityName, getRandomState, getRandomZipCode } = require('json-mock-factory');

// Generate 100 random users and save to users.json
saveRandomUsers(100, 'users.json');

// Generate a single random email and name
const email = generateRandomEmail();
const name = generateRandomNames();

console.log(`Generated email: ${email}`);
console.log(`Generated name: ${name}`);

// Generate other user details randomly
const companyName = generateRandomCompanyName();
const nationality = generateRandomNationality();
const designation = getRandomCompanyDesignation();
const {salary, experience} = getSalary(designation, getRandomExperience());
const address = generateRandomAddress();

console.log(`Company name: ${companyName}`);
console.log(`Nationality: ${nationality}`);
console.log(`Designation: ${designation}`);
console.log(`Salary: ${salary} with ${experience} years of experience`);
console.log(`Address: ${JSON.stringify(address)}`);

Products Create product-related mock data efficiently:

saveRandomProducts(numProducts, filePath): Generates and saves numProducts unique random product details to the specified filePath.

const { saveRandomProducts } = require('json-mock-factory');

// Generate 200 random products and save to products.json
saveRandomProducts(200, 'products.json');