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

i-need-dummy-data

v1.0.0

Published

A random data generator package to test and speed up application development process.

Downloads

73

Readme

I Need Dummy Data

I Need Dummy Data is a flexible and customizable random data generator for testing and prototyping applications, especially useful for testing user databases and related features. Easily generate dummy data in JSON format for fields like names, emails, phone numbers, addresses, and more.

Table of Contents


Installation

Install I Need Dummy Data via npm:


npm install i-need-dummy-data

or clone this repository and link it locally using:


npm link

Usage

Basic Usage

Import the generateDummyData function, specify the fields you need, and it will generate random dummy data accordingly.

import generateDummyData from "i-need-dummy-data";

const fields = ["name", "email", "phone", "age", "address"];

const data = generateDummyData(fields);

console.log(data);

This code will output a JSON object with the specified fields.

Generating Bulk Data

To generate multiple data entries at once, specify the count parameter:

const data = generateDummyData(
  ["name", "email", "phone", "age", "address"],
  10
); // Generates 10 records

console.log(data);

The function will return an array of JSON objects, each containing the specified fields.

Supported Fields

The package currently supports the following fields:

  • name -- Full name

  • email -- Email address

  • phone -- Phone number

  • age -- Random age between 18 and 100

  • address -- Nested object with street, city, state, and zip code

  • company -- Company name

  • jobTitle -- Job title

  • id -- UUID for unique identification

  • date -- Random date

For fields not specified in this list, null will be returned by default.


Examples

1. Single User Record with Specified Fields

const userData = generateDummyData(["name", "email", "age"]);

console.log(userData);

2. Generating Multiple User Records

const bulkData = generateDummyData(["name", "email", "phone", "address"], 5);

console.log(bulkData); // Array of 5 user data objects

3. Nested Address Object

const dataWithAddress = generateDummyData(["name", "address"]);

console.log(dataWithAddress);

// Output: { name: '...', address: { street: '...', city: '...', state: '...', zip: '...' } }

API

generateDummyData(fields: string[], count?: number): object | object[]

Generates random data based on user-defined fields.

  • fields (required): An array of field names to include in the generated data.

  • count (optional): Number of data records to generate. Defaults to 1.

Returns

  • A single object with the specified fields if count is 1.

  • An array of objects if count is greater than 1.


License

I Need Dummy Data is licensed under the ISC License. See the LICENSE file for more details.