What is @ngneat/falso?
@ngneat/falso is a JavaScript library that provides a wide range of fake data generators for various types of data. It is useful for testing, prototyping, and development purposes where you need to generate realistic but fake data.
What are @ngneat/falso's main functionalities?
Generate Fake Names
This feature allows you to generate random first and last names, which can be useful for populating user profiles or testing forms.
const { randFirstName, randLastName } = require('@ngneat/falso');
console.log(randFirstName()); // e.g., 'John'
console.log(randLastName()); // e.g., 'Doe'
Generate Fake Addresses
This feature allows you to generate random street addresses, cities, and countries, which can be useful for testing location-based applications.
const { randStreetAddress, randCity, randCountry } = require('@ngneat/falso');
console.log(randStreetAddress()); // e.g., '123 Main St'
console.log(randCity()); // e.g., 'New York'
console.log(randCountry()); // e.g., 'USA'
Generate Fake Dates
This feature allows you to generate random past and future dates, which can be useful for testing date-based functionalities.
const { randPastDate, randFutureDate } = require('@ngneat/falso');
console.log(randPastDate()); // e.g., '2020-01-01T00:00:00.000Z'
console.log(randFutureDate()); // e.g., '2025-01-01T00:00:00.000Z'
Generate Fake Emails
This feature allows you to generate random email addresses, which can be useful for testing email-related functionalities.
const { randEmail } = require('@ngneat/falso');
console.log(randEmail()); // e.g., 'john.doe@example.com'
Generate Fake Phone Numbers
This feature allows you to generate random phone numbers, which can be useful for testing contact forms and phone number validation.
const { randPhoneNumber } = require('@ngneat/falso');
console.log(randPhoneNumber()); // e.g., '(123) 456-7890'
Other packages similar to @ngneat/falso
faker
Faker.js is a popular library for generating fake data. It offers a wide range of data types similar to @ngneat/falso, including names, addresses, dates, emails, and phone numbers. However, Faker.js has a larger community and more extensive documentation.
chance
Chance.js is another library for generating random data. It provides a variety of data types and is highly customizable. Compared to @ngneat/falso, Chance.js offers more flexibility in generating complex data structures.
casual
Casual is a library for generating random data with a focus on simplicity and ease of use. It offers a range of data types similar to @ngneat/falso but with a simpler API. Casual is a good choice for quick and easy data generation.
All the Fake Data for All Your Real Needs 🙂
Create massive amounts of fake data in the browser and NodeJS. Tree Shakeable & Fully Typed.
✅ 203 Functions
✅ Tree Shakable
✅ Fully Typed
✅ Factory Functions
✅ Entity Functions
✅ Single and Array Result
🤓 Learn about it on the docs site
Sponsorships aid in the continued development and maintenance of ngneat libraries. Consider asking your company to sponsor ngneat as its core to their business and application development.
Elevate your support by becoming a Gold Sponsor and have your logo prominently featured on our README in the top 5 repositories.
Boost your backing by becoming a Gold Sponsor and enjoy the spotlight with your logo prominently showcased in the top 3 repositories on our README.
Become a bronze sponsor and get your logo on our README on GitHub.
StackBlitz
Installation
npm i @ngneat/falso
yarn add @ngneat/falso
Usage
import { randEmail, randFullName } from '@ngneat/falso';
const user = { email: randEmail(), name: randFullName() };
const emails = randEmail({ length: 10 });
You can specify the length of elements you want to generate. Below is an example of generating 10 emails with length equal or smaller than 20 characters.
const emails = randEmail({ length: 10, maxCharCount: 20 });
Setting a Randomness Seed
You can set your own seed if you want consistent results:
import { rand, seed } from '@ngneat/falso';
seed('some-constant-seed');
rand([1, 2, 3, 4, 5]);
seed();
Contribute
- Go over the steps in this guide
- Add a new falso
- Use
npm run c
and choose the right answers