7.0.0 β€’ Published 4 years ago

faker-es6 v7.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

faker-es6 - Massive realistic fake data generation tool for ES6+ projects, fully tree-shakable for a smaller package size

A heavily inspired lib to generate massive amounts of realistic fake data.

This lib was inspired by what I would like to see in Marak/faker.js plus what I thought that could be a good exercise for myself.

Build Status Coverage Status npm version

Table of contents

Installation

Install faker-es6

yarn add --dev faker-es6

or

npm install --dev faker-es6

Getting started

First name example

import { firstName } from 'faker-es6/lib/name/firstName';

const name = firstName(); // Random first name: Yessenia
const anotherName = firstName(); // Random first name: Marilyne

First name with locale example

import { firstName } from 'faker-es6/lib/name/firstName';
import { Locale } from 'faker-es6/lib/types/locale';

const name = firstName(Locale.PT_BR); // Random first name in pt_BR: Bruna
const anotherName = firstName(Locale.PT_BR); // Random first name in pt_BR: Paula

Importing the whole lib example

import faker from 'faker-es6';

const name = faker.name.firstName(); // Random first name: Yessenia
const anotherName = faker.name.firstName(); // Random first name: Marilyne

Available methods

  • name
    • firstName
    • lastName
    • prefix
    • suffix
  • helpers
    • getLocale
    • randomArrayElement
    • randomArrayElements
    • randomNumber
    • parseRegex

Upcoming methods

  • address
    • city
    • cityPrefix
    • citySuffix
    • country
    • countryCode
    • county
    • latitude
    • longitude
    • secondaryAddress
    • state
    • stateAbbreviation
    • streetAddress
    • streetName
    • streetPrefix
    • streetSuffix
    • zipCode
  • commerce
    • color
    • department
    • price
    • productAdjective
    • productMaterial
    • productName
  • company
    • catchPhrase
    • catchPhraseAdjective
    • catchPhraseDescriptor
    • catchPhraseNoun
    • companyName
    • companySuffix
    • jobArea
    • jobDescriptor
    • jobTitle
    • jobType
  • date
    • between
    • future
    • month
    • past
    • recent
    • soon
    • weekday
  • database
    • collation
    • column
    • engine
    • type
  • finance
    • account
    • accountName
    • amount
    • bic
    • bitcoinAddress
    • currencyCode
    • currencyName
    • currencySymbol
    • ethereumAddress
    • iban
    • mask
    • transactionType
  • hacker
    • abbreviation
    • adjective
    • ingverb
    • noun
    • phrase
    • verb
  • helpers
    • shuffle
    • slugify
  • internet
    • avatar
    • color
    • domainName
    • domainSuffix
    • domainWord
    • email
    • ip
    • ipv6
    • mac
    • password
    • protocol
    • url
    • userAgent
    • userName
  • lorem
    • lines
    • paragraph
    • paragraphs
    • sentence
    • sentences
    • slug
    • text
    • word
    • words
    • homer
    • mussum (available only in pt_BR)
    • ronSwanson
    • theOffice
  • name
    • title
  • phone
    • phoneFormats
    • phoneNumber
    • phoneNumberFormat
  • system
    • commonFileExt
    • commonFileName
    • commonFileType
    • directoryPath
    • fileExt
    • fileName
    • filePath
    • fileType
    • mimeType
    • semver

Localization

faker-es6 supports any ISO valid locale.

To use a locale, just pass it as a parameter in the method you want to use.

Current available locales

Since this is lib is a WIP, at the time of development it only supports:

  • en πŸ‡ΊπŸ‡Έ
  • ja πŸ‡―πŸ‡΅ (partial support for now)
  • pt_BR πŸ‡§πŸ‡·

Localization example with TypeScript

import { firstName } from 'faker-es6/lib/name/firstName';
import { Locale } from 'faker-es6/lib/types/locale';

const name = firstName(Locale.PT_BR); // Random first name in pt_BR: Bruna
const anotherName = firstName(Locale.PT_BR); // Random first name in pt_BR: Paula

Locale is an TS enum object with all valid ISO language codes

Localization example without TypeScript

import { firstName } from 'faker-es6/lib/name/firstName';

const name = firstName('pt_BR'); // Random first name in pt_BR: Bruna
const anotherName = firstName('pt_BR'); // Random first name in pt_BR: Paula

For further information on the available language codes, see ISO Language Code Table section

ISO Language Code Table

Credits to http://www.lingoes.net/en/translator/langcode.htm

CodeName
afAfrikaans
af_ZAAfrikaans (South Africa)
arArabic
ar_AEArabic (U.A.E.)
ar_BHArabic (Bahrain)
ar_DZArabic (Algeria)
ar_EGArabic (Egypt)
ar_IQArabic (Iraq)
ar_JOArabic (Jordan)
ar_KWArabic (Kuwait)
ar_LBArabic (Lebanon)
ar_LYArabic (Libya)
ar_MAArabic (Morocco)
ar_OMArabic (Oman)
ar_QAArabic (Qatar)
ar_SAArabic (Saudi Arabia)
ar_SYArabic (Syria)
ar_TNArabic (Tunisia)
ar_YEArabic (Yemen)
azAzeri (Latin)
az_AZAzeri (Cyrillic) (Azerbaijan)
az_AZAzeri (Latin) (Azerbaijan)
beBelarusian
be_BYBelarusian (Belarus)
bgBulgarian
bg_BGBulgarian (Bulgaria)
bs_BABosnian (Bosnia and Herzegovina)
caCatalan
ca_ESCatalan (Spain)
csCzech
cs_CZCzech (Czech Republic)
cyWelsh
cy_GBWelsh (United Kingdom)
daDanish
da_DKDanish (Denmark)
deGerman
de_ATGerman (Austria)
de_CHGerman (Switzerland)
de_DEGerman (Germany)
de_LIGerman (Liechtenstein)
de_LUGerman (Luxembourg)
dvDivehi
dv_MVDivehi (Maldives)
elGreek
el_GRGreek (Greece)
enEnglish
en_AUEnglish (Australia)
en_BZEnglish (Belize)
en_CAEnglish (Canada)
en_CBEnglish (Caribbean)
en_GBEnglish (United Kingdom)
en_IEEnglish (Ireland)
en_JMEnglish (Jamaica)
en_NZEnglish (New Zealand)
en_PHEnglish (Republic of the Philippines)
en_TTEnglish (Trinidad and Tobago)
en_USEnglish (United States)
en_ZAEnglish (South Africa)
en_ZWEnglish (Zimbabwe)
eoEsperanto
esSpanish
es_ARSpanish (Argentina)
es_BOSpanish (Bolivia)
es_CLSpanish (Chile)
es_COSpanish (Colombia)
es_CRSpanish (Costa Rica)
es_DOSpanish (Dominican Republic)
es_ECSpanish (Ecuador)
es_ESSpanish (Castilian)
es_GTSpanish (Guatemala)
es_HNSpanish (Honduras)
es_MXSpanish (Mexico)
es_NISpanish (Nicaragua)
es_PASpanish (Panama)
es_PESpanish (Peru)
es_PRSpanish (Puerto Rico)
es_PYSpanish (Paraguay)
es_SVSpanish (El Salvador)
es_UYSpanish (Uruguay)
es_VESpanish (Venezuela)
etEstonian
et_EEEstonian (Estonia)
euBasque
eu_ESBasque (Spain)
faFarsi
fa_IRFarsi (Iran)
fiFinnish
fi_FIFinnish (Finland)
foFaroese
fo_FOFaroese (Faroe Islands)
frFrench
fr_BEFrench (Belgium)
fr_CAFrench (Canada)
fr_CHFrench (Switzerland)
fr_FRFrench (France)
fr_LUFrench (Luxembourg)
fr_MCFrench (Principality of Monaco)
glGalician
gl_ESGalician (Spain)
guGujarati
gu_INGujarati (India)
heHebrew
he_ILHebrew (Israel)
hiHindi
hi_INHindi (India)
hrCroatian
hr_BACroatian (Bosnia and Herzegovina)
hr_HRCroatian (Croatia)
huHungarian
hu_HUHungarian (Hungary)
hyArmenian
hy_AMArmenian (Armenia)
idIndonesian
id_IDIndonesian (Indonesia)
isIcelandic
is_ISIcelandic (Iceland)
itItalian
it_CHItalian (Switzerland)
it_ITItalian (Italy)
jaJapanese
ja_JPJapanese (Japan)
kaGeorgian
ka_GEGeorgian (Georgia)
kkKazakh
kk_KZKazakh (Kazakhstan)
knKannada
kn_INKannada (India)
koKorean
ko_KRKorean (Korea)
kokKonkani
kok_INKonkani (India)
kyKyrgyz
ky_KGKyrgyz (Kyrgyzstan)
ltLithuanian
lt_LTLithuanian (Lithuania)
lvLatvian
lv_LVLatvian (Latvia)
miMaori
mi_NZMaori (New Zealand)
mkFYRO Macedonian
mk_MKFYRO Macedonian (Former Yugoslav Republic of Macedonia)
mnMongolian
mn_MNMongolian (Mongolia)
mrMarathi
mr_INMarathi (India)
msMalay
ms_BNMalay (Brunei Darussalam)
ms_MYMalay (Malaysia)
mtMaltese
mt_MTMaltese (Malta)
nbNorwegian (Bokm?l)
nb_NONorwegian (Bokm?l) (Norway)
nlDutch
nl_BEDutch (Belgium)
nl_NLDutch (Netherlands)
nn_NONorwegian (Nynorsk) (Norway)
nsNorthern Sotho
ns_ZANorthern Sotho (South Africa)
paPunjabi
pa_INPunjabi (India)
plPolish
pl_PLPolish (Poland)
psPashto
ps_ARPashto (Afghanistan)
ptPortuguese
pt_BRPortuguese (Brazil)
pt_PTPortuguese (Portugal)
quQuechua
qu_BOQuechua (Bolivia)
qu_ECQuechua (Ecuador)
qu_PEQuechua (Peru)
roRomanian
ro_RORomanian (Romania)
ruRussian
ru_RURussian (Russia)
saSanskrit
sa_INSanskrit (India)
seSami (Northern)
se_FISami (Inari) (Finland)
se_NOSami (Lule) (Norway)
se_SESami (Lule) (Sweden)
skSlovak
sk_SKSlovak (Slovakia)
slSlovenian
sl_SISlovenian (Slovenia)
sqAlbanian
sq_ALAlbanian (Albania)
sr_BASerbian (Cyrillic) (Bosnia and Herzegovina)
sr_SPSerbian (Cyrillic) (Serbia and Montenegro)
svSwedish
sv_FISwedish (Finland)
sv_SESwedish (Sweden)
swSwahili
sw_KESwahili (Kenya)
syrSyriac
syr_SYSyriac (Syria)
taTamil
ta_INTamil (India)
teTelugu
te_INTelugu (India)
thThai
th_THThai (Thailand)
tlTagalog
tl_PHTagalog (Philippines)
tnTswana
tn_ZATswana (South Africa)
trTurkish
tr_TRTurkish (Turkey)
tsTsonga
ttTatar
tt_RUTatar (Russia)
ukUkrainian
uk_UAUkrainian (Ukraine)
urUrdu
ur_PKUrdu (Islamic Republic of Pakistan)
uzUzbek (Latin)
uz_UZUzbek (Cyrillic) (Uzbekistan)
uz_UZUzbek (Latin) (Uzbekistan)
viVietnamese
vi_VNVietnamese (Viet Nam)
xhXhosa
xh_ZAXhosa (South Africa)
zhChinese
zh_CNChinese (S)
zh_HKChinese (Hong Kong)
zh_MOChinese (Macau)
zh_SGChinese (Singapore)
zh_TWChinese (T)
zuZulu
zu_ZAZulu (South Africa)

Maintainer

Samir J M Araujo

faker-es6 - Copyright (c) 2020 Samir J M Araujo - https://github.com/samir-araujo

If you ever think about copying, distributing, changing or anything related, please DO.

It would be awesome to see other people participating in this project in any possible ways.

All I ask is to leave some credit back to this repository :grin:

Credits

This lib was inspired mostly by how I wanted to use Marak/faker.js, but I also have to thanks a lot these guys:

License

MIT License

Copyright (c) 2020 Samir J M Araujo samir.blanc@gmail.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.