Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@ahmedrowaihi/faker-ar
Advanced tools
Please select the version of the documentation you are looking for.
Version | Github | Website |
---|---|---|
release | releases | https://fakerjs.dev/ |
dev | next | https://next.fakerjs.dev/ |
v8.x.x | v8 | https://v8.fakerjs.dev/ |
v7.x.x | v7 | https://v7.fakerjs.dev/ |
v6.x.x | v6 | https://v6.fakerjs.dev/ |
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.
npm install --save-dev @faker-js/faker
import { faker } from '@faker-js/faker';
// import { faker } from '@faker-js/faker/locale/de';
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.
An in-depth overview of the API methods is available in the documentation.
The API covers the following modules:
Module | Example | Output |
---|---|---|
Airline | faker.airline.airport() | { name: 'Dallas Fort Worth International Airport', iataCode: 'DFW' } |
Animal | faker.animal.cat() | Norwegian Forest Cat |
Color | faker.color.rgb() | #cdfcdc |
Commerce | faker.commerce.product() | Polo t-shirt |
Company | faker.company.companyName() | Zboncak and Sons |
Database | faker.database.engine() | MyISAM |
Datatype | faker.datatype.uuid() | 7b16dd12-935e-4acc-8381-b1e457bf0176 |
Date | faker.date.past() | Sat Oct 20 2018 04:19:38 GMT-0700 (Pacific Daylight Time) |
Finance | faker.finance.amount() | Β₯23400 (After setting locale) |
Git | faker.git.commitMessage() | feat: add products list page |
Hacker | faker.hacker.phrase() | Try to reboot the SQL bus, maybe it will bypass the virtual application! |
Helpers | faker.helpers.arrayElement(['a', 'b', 'c']) | b |
Image | faker.image.url() | https://picsum.photos/id/165/640/480 |
Internet | faker.internet.domainName() | muddy-neuropathologist.net |
Location | faker.location.city() | Lake Raoulfort |
Lorem | faker.lorem.paragraph() | Porro nulla id vero perspiciatis nulla nihil. ... |
Music | faker.music.genre() | R&B |
Person | faker.person.firstName() | Cameron |
Phone | faker.phone.phoneNumber() | +1 291-299-0192 |
Random | faker.random.locale() | fr_CA |
Science | faker.science.unit() | { name: 'meter', symbol: 'm' } |
System | faker.system.directoryPath() | /root |
Vehicle | faker.vehicle.vehicle() | Lamborghini Camry |
Word | faker.word.adjective() | adorable |
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?'
)
);
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.
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);
Faker is an MIT-licensed open source project with its ongoing development made possible entirely by the support of these awesome backers
Please make sure to read the Contributing Guide before making a pull request.
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.
Detailed changes for each release are documented in the release notes.
Read the team update (January 14th, 2022).
8.0.0-alpha.0 (2023-02-08)
allowLeadingZeros
default to true
(#1602)latitude
/longitude
returns number (#1064)nearbyGPSCoordinate
returns number tuple (#1061)datatype.hexadecimal
signature change (#1238) (8cb6027)hacker.abbreviation()
in the en
locale (#1086) (c5d8934)id
, ponpes.id
and net.id
domains for id_ID (#137) (ce4d48e)arrayElements
(#1772) (b86638d)multiple
method (#1545) (f06126a)latitude
/longitude
returns number (#1064) (dac6be3)nearbyGPSCoordinate
returns number tuple (#1061) (4765336)zodiacSign()
(#182) (7e00d17)domainWord()
(#1520) (cf764b9)allowLeadingZeros
tests (#1638) (97dbfa1)refDate
in soon()
, recent()
(816b658), closes #686git log
output (#1539) (99b6fb2)Indonesian
(#1401) (ec0181e)\n
as default separator for lorem.paragraphs() (#783) (6a2d8fc)company: remove hardcoded name fallback pattern (#1451) (b99ff71)
string: swap allowLeadingZeros
default to true
(#1602) (c4b7ce8)
FAQs
Generate massive amounts of fake contextual data
The npm package @ahmedrowaihi/faker-ar receives a total of 4 weekly downloads. As such, @ahmedrowaihi/faker-ar popularity was classified as not popular.
We found that @ahmedrowaihi/faker-ar demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.Β It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socketβs threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.