Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ahmedrowaihi/faker-ar

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ahmedrowaihi/faker-ar

Generate massive amounts of fake contextual data

  • 8.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
increased by20%
Maintainers
1
Weekly downloads
 
Created
Source

This repo was forked from @ahmedrowaihi/faker-ar

it supports AR only for Lorem-Ipsum-like text

Faker

Generate massive amounts of fake (but realistic) data for testing and development.

npm version npm downloads

API Documentation

🚀 Features | WIP

  • 💌 Locations - Generate valid looking Addresses, Zip Codes, Street Names, States, and Countries!
  • ⏰ Time-based Data - Past, present, future, recent, soon... whenever!
  • 🌏 Localization - Set a locale to generate realistic looking Names, Addresses, and Phone Numbers.
  • 💸 Finance - Create stubbed out Account Details, Transactions, and Crypto Addresses.
  • 👠 Products - Generate Prices, Product Names, Adjectives, and Descriptions.
  • 👾 Hacker Jargon - “Try to reboot the SQL bus, maybe it will bypass the virtual application!”
  • 🧍 Names - Generate virtual humans with a complete online and offline identity.
  • 🔢 Numbers - Of course, we can also generate random numbers and strings.

Note: Faker tries to generate realistic data and not obvious fake data. The generated names, addresses, emails, phone numbers, and/or other data might be coincidentally valid information. Please do not send any of your messages/calls to them from your test setup.

📦 Install

npm install --save-dev @ahmedrowaihi/faker-ar

🪄 Usage

import { faker } from '@ahmedrowaihi/faker-ar';
// import { faker } from '@ahmedrowaihi/faker-ar/locale/ar';

export const USERS: User[] = [];

export function createRandomUser(): User {
  return {
    userId: faker.datatype.uuid(),
    username: faker.internet.userName(),
    email: faker.internet.email(),
    avatar: faker.image.avatar(),
    password: faker.internet.password(),
    birthdate: faker.date.birthdate(),
    registeredAt: faker.date.past(),
  };
}

Array.from({ length: 10 }).forEach(() => {
  USERS.push(createRandomUser());
});

The above code indicates a basic usage of Faker. The point of interest is the import statements at the top. The first import indicates how one can import the entirety of Faker, which includes every locale, while the commented-out import showcases how to import only a single locale. In most situations, importing a single locale is preferable for performance because some testing frameworks reload imports for every test file, which causes startup latencies to add up quickly. Thus, limiting the import to a single locale can speed up startup times.

💎 Modules

An in-depth overview of the API methods is available in the documentation.
The API covers the following modules:

ModuleExampleOutput
Airlinefaker.airline.airport(){ name: 'Dallas Fort Worth International Airport', iataCode: 'DFW' }
Animalfaker.animal.cat()Norwegian Forest Cat
Colorfaker.color.rgb()#cdfcdc
Commercefaker.commerce.product()Polo t-shirt
Companyfaker.company.companyName()Zboncak and Sons
Databasefaker.database.engine()MyISAM
Datatypefaker.datatype.uuid()7b16dd12-935e-4acc-8381-b1e457bf0176
Datefaker.date.past()Sat Oct 20 2018 04:19:38 GMT-0700 (Pacific Daylight Time)
Financefaker.finance.amount()¥23400 (After setting locale)
Gitfaker.git.commitMessage()feat: add products list page
Hackerfaker.hacker.phrase()Try to reboot the SQL bus, maybe it will bypass the virtual application!
Helpersfaker.helpers.arrayElement(['a', 'b', 'c'])b
Imagefaker.image.url()https://picsum.photos/id/165/640/480
Internetfaker.internet.domainName()muddy-neuropathologist.net
Locationfaker.location.city()Lake Raoulfort
Loremfaker.lorem.paragraph()Porro nulla id vero perspiciatis nulla nihil. ...
Musicfaker.music.genre()R&B
Personfaker.person.firstName()Cameron
Phonefaker.phone.phoneNumber()+1 291-299-0192
Randomfaker.random.locale()fr_CA
Sciencefaker.science.unit(){ name: 'meter', symbol: 'm' }
Systemfaker.system.directoryPath()/root
Vehiclefaker.vehicle.vehicle()Lamborghini Camry
Wordfaker.word.adjective()adorable

Templates

Faker contains a generator method faker.helpers.fake for combining faker API methods using a mustache string format.

console.log(faker.helpers.fake('Hello {{person.prefix}} {{person.lastName}}, how are you today?'));

🌏 Localization

Faker has support for multiple locales.

The default language locale is set to English.

Setting a new locale is simple:

// sets locale to de
faker.locale = 'de';

See our documentation for a list of provided languages

Please note: not every locale provides data for every module. In our pre-made locales, we fallback to English in such a case as this is the most complete and most commonly used language.

⚙️ Setting a randomness seed

If you want consistent results, you can set your own seed:

faker.seed(123);

const firstRandom = faker.number.int();

// Setting the seed again resets the sequence.
faker.seed(123);

const secondRandom = faker.number.int();

console.log(firstRandom === secondRandom);

🤝 Sponsors

Faker is an MIT-licensed open source project with its ongoing development made possible entirely by the support of these awesome backers

Sponsors

Backers

✨ Contributing

Please make sure to read the Contributing Guide before making a pull request.

📘 Credits

Thanks to all the people who already contributed to Faker!

The fakerjs.dev website is kindly hosted by the Netlify Team. Also the search functionality is powered by algolia.

📝 Changelog

Detailed changes for each release are documented in the release notes.

📜 What happened to the original faker.js?

Read the team update (January 14th, 2022).

🔑 License

MIT

Keywords

FAQs

Package last updated on 10 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc