Jump to content
Fi8sVrs

faker.js - generate massive amounts of fake data in the browser and node.js

Recommended Posts

Fi8sVrs    922

faker.js - generate massive amounts of fake data in the browser and node.js

 

logo.png

 

Demo: Please login or register to see this link.

 

Hosted API Microservice

 

Please login or register to see this link.

  • Supports all Faker API Methods
  • Full-Featured Microservice
  • Hosted by Please login or register to see this link.
curl http://faker.hook.io?property=name.findName&locale=de

Usage

Browser

<script src = "faker.js" type = "text/javascript"></script>
<script>
  var randomName = faker.name.findName(); // Caitlyn Kerluke
  var randomEmail = faker.internet.email(); // Rusty@arne.info
  var randomCard = faker.helpers.createCard(); // random contact card containing many properties
</script>

 

Node.js

var faker = require('faker');

var randomName = faker.name.findName(); // Rowan Nikolaus
var randomEmail = faker.internet.email(); // Kassandra.Haley@erich.biz
var randomCard = faker.helpers.createCard(); // random contact card containing many properties

 

API

Faker.fake()

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

 

Example

console.log(faker.fake("{{name.lastName}}, {{name.firstName}} {{name.suffix}}"));
// outputs: "Marks, Dean Sr."

 

This will interpolate the format string with the value of methods name.lastName(), name.firstName(), and name.suffix()

 

JSDoc API Browser

Please login or register to see this link.

 

API Methods

  • address
    • zipCode
    • city
    • cityPrefix
    • citySuffix
    • streetName
    • streetAddress
    • streetSuffix
    • streetPrefix
    • secondaryAddress
    • county
    • country
    • countryCode
    • state
    • stateAbbr
    • latitude
    • longitude
  • commerce
    • color
    • department
    • productName
    • price
    • productAdjective
    • productMaterial
    • product
  • company
    • suffixes
    • companyName
    • companySuffix
    • catchPhrase
    • bs
    • catchPhraseAdjective
    • catchPhraseDescriptor
    • catchPhraseNoun
    • bsAdjective
    • bsBuzz
    • bsNoun
  • database
    • column
    • type
    • collation
    • engine
  • date
    • past
    • future
    • between
    • recent
    • month
    • weekday
  • fake
  • finance
    • account
    • accountName
    • mask
    • amount
    • transactionType
    • currencyCode
    • currencyName
    • currencySymbol
    • bitcoinAddress
    • iban
    • bic
  • hacker
    • abbreviation
    • adjective
    • noun
    • verb
    • ingverb
    • phrase
  • helpers
    • randomize
    • slugify
    • replaceSymbolWithNumber
    • replaceSymbols
    • shuffle
    • mustache
    • createCard
    • contextualCard
    • userCard
    • createTransaction
  • image
    • image
    • avatar
    • imageUrl
    • abstract
    • animals
    • business
    • cats
    • city
    • food
    • nightlife
    • fashion
    • people
    • nature
    • sports
    • technics
    • transport
    • dataUri
  • internet
    • avatar
    • email
    • exampleEmail
    • userName
    • protocol
    • url
    • domainName
    • domainSuffix
    • domainWord
    • ip
    • ipv6
    • userAgent
    • color
    • mac
    • password
  • lorem
    • word
    • words
    • sentence
    • slug
    • sentences
    • paragraph
    • paragraphs
    • text
    • lines
  • name
    • firstName
    • lastName
    • findName
    • jobTitle
    • prefix
    • suffix
    • title
    • jobDescriptor
    • jobArea
    • jobType
  • phone
    • phoneNumber
    • phoneNumberFormat
    • phoneFormats
  • random
    • number
    • arrayElement
    • objectElement
    • uuid
    • boolean
    • word
    • words
    • image
    • locale
    • alphaNumeric
  • system
    • fileName
    • commonFileName
    • mimeType
    • commonFileType
    • commonFileExt
    • fileType
    • fileExt
    • directoryPath
    • filePath
    • semver

 

Localization

As of version v2.0.0 faker.js has support for multiple localities.

The default language locale is set to English.

Setting a new locale is simple:

// sets locale to de
faker.locale = "de";
  • az
  • cz
  • de
  • de_AT
  • de_CH
  • en
  • en_AU
  • en_BORK
  • en_CA
  • en_GB
  • en_IE
  • en_IND
  • en_US
  • en_au_ocker
  • es
  • es_MX
  • fa
  • fr
  • fr_CA
  • ge
  • id_ID
  • it
  • ja
  • ko
  • nb_NO
  • nep
  • nl
  • pl
  • pt_BR
  • ru
  • sk
  • sv
  • tr
  • uk
  • vi
  • zh_CN
  • zh_TW

 

Individual Localization Packages

As of vesion v3.0.0 faker.js supports incremental loading of locales.

By default, requiring faker will include all locale data.

In a production environment, you may only want to include the locale data for a specific set of locales.

// loads only de locale
var faker = require('faker/locale/de');

Setting a randomness seed

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

faker.seed(123);

var firstRandom = faker.random.number();

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

var secondRandom = faker.random.number();

console.log(firstRandom === secondRandom);

Tests

npm install .
make test

You can view a code coverage report generated in coverage/lcov-report/index.html.

 

Projects Built with faker.js

Fake JSON Schema

Use faker generators to populate JSON Schema samples. See :Please login or register to see this link.

 

CLI

Run faker generators from Command Line. See: Please login or register to see this link.

 

Want to see your project added here? Let us know!

 

Meteor

Meteor Installation

meteor add practicalmeteor:faker

Meteor Usage, both client and server

var randomName = faker.name.findName(); // Rowan Nikolaus
var randomEmail = faker.internet.email(); // Kassandra.Haley@erich.biz
var randomCard = faker.helpers.createCard(); // random contact card containing many properties

Building faker.js

faker uses Please login or register to see this link. to automate it's build process. Running the following build command will generate new browser builds, documentation, and code examples for the project.

npm run-script build

 

Building JSDocs

npm run-script doc

 

Version Release Schedule

 

faker.js is a popular project used by many organizations and individuals in production settings. Major and Minor version releases are generally on a monthly schedule. Bugs fixes are addressed by severity and fixed as soon as possible.

If you require the absolute latest version of faker.js the master branch @ Please login or register to see this link.   should always be up to date and working.

 

Maintainer

Marak Squires

faker.js - Copyright (c) 2017 Marak Squires Please login or register to see this link.  

faker.js was inspired by and has used data definitions from:

  • Please login or register to see this link.   - Copyright (c) 2007-2010 Benjamin Curtis
  • Please login or register to see this link. - Copyright 2004-2005 by Jason Kohles

 

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.

 

Download Please login or register to see this link.

Source: Please login or register to see this link.

 

   

          

        

 

  • Upvote 2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • By FoxInFox
      Salut ,
       
      Incerc sa instalez acest script : Please login or register to see this link.
      Am urmat toti pasi , insa cand execut comanda : " sudo -u sphinx indexer --config sphinx.conf.in --all " imi apare aceasta erroare:

       
      Aici cred ca ar fi problema :
       
      Fisier : sphinx.conf.in
      source mysql_all { type = mysql sql_host = localhost sql_user = dtb sql_pass = 123 sql_db = dtb sql_port = 3306 # optional, default is 3306 sql_query = \ SELECT id, title, source_id, seeds, peers, date, category, size, hash \ FROM rtindex WHERE parent = 1 sql_attr_string = hash sql_attr_uint = source_id sql_attr_uint = seeds sql_attr_uint = peers sql_attr_uint = date sql_attr_uint = category sql_attr_uint = size sql_query_pre = SET NAMES utf8 } source mysql0 : mysql_all { sql_query = \ SELECT id, title, hash, source_id, seeds, peers, date, category, size \ FROM rtindex WHERE id % 4 = 0 AND parent = 1; } source mysql1 : mysql_all { sql_query = \ SELECT id, title, hash, source_id, seeds, peers, date, category, size \ FROM rtindex WHERE id % 4 = 1 AND parent = 1; } source mysql2 : mysql_all { sql_query = \ SELECT id, title, hash, source_id, seeds, peers, date, category, size \ FROM rtindex WHERE id % 4 = 2 AND parent = 1; } source mysql3 : mysql_all { sql_query = \ SELECT id, title, hash, source_id, seeds, peers, date, category, size \ FROM rtindex WHERE id % 4 = 3 AND parent = 1; } index mysql_all { type = plain source = mysql_all path = G:\SphinxData\rivr\mysql_all } index mysql0 : mysql_all { source = mysql0 path = G:\SphinxData\rivr\mysql0 } index mysql1 : mysql_all { source = mysql1 path = G:\SphinxData\rivr\mysql1 } index mysql2 : mysql_all { source = mysql2 path = G:\SphinxData\rivr\mysql2 } index mysql3 : mysql_all { source = mysql3 path = G:\SphinxData\rivr\mysql3 } index orig { type = distributed local = mysql0 local = mysql1 local = mysql2 local = mysql3 } index rtindex { type = rt rt_mem_limit = 1024M path = G:\SphinxData\rivr\rtindex rt_field = title rt_attr_string = hash rt_attr_uint = source_id rt_attr_uint = seeds rt_attr_uint = peers rt_attr_uint = date rt_attr_uint = category rt_attr_uint = size ondisk_attrs = 1 } index rtindex0 : rtindex { path = G:\SphinxData\rivr\rtindex0 } index rtindex1 : rtindex { path = G:\SphinxData\rivr\rtindex1 } index rtindex2 : rtindex { path = G:\SphinxData\rivr\rtindex2 } index rtindex3 : rtindex { path = G:\SphinxData\rivr\rtindex3 } indexer { mem_limit = 512M } searchd { listen = 9312 listen = 9306:mysql41 log = D:\Applications\Sphinx\bin\log\searchd.log query_log = D:\Applications\Sphinx\bin\log\query.log read_timeout = 5 max_children = 30 pid_file = D:\Applications\Sphinx\bin\data\searchd.pid seamless_rotate = 1 preopen_indexes = 0 unlink_old = 1 workers = threads # for RT to work binlog_path = D:\Applications\Sphinx\bin\log dist_threads = 4 }  
       
      Incerc sa instalez pe un WHM "cP" cu acces root , cred ca ar trebuii sa modific " G: si D: " dar nu ma pricep si nu stiu ce ar trebui sa pun ?!
      Putin ajutor daca se poate ? 
    • By FoxInFox
      Salut ,
       
      Nu ma prea pricep la script-uri ... Incerc de ceva timp sa imprementez un script in "Header" si cand il adaug nu mai merge pagina , pur si simplu se vede alb pe tot site-ul 
       
      Scriptul este acesta : 
       
      <script> var OneSignal = window.OneSignal || []; OneSignal.push(["init", { appId: "dd90a839-001b-4acf-8bdb-343ca30f5856", safari_web_id: 'web.onesignal.auto.11512f5d-61af-48e1-99c6-cc09fe5cc2c2' autoRegister: true, /* Set to true to automatically prompt visitors */ subdomainName: 'https://filmeonlinefox.onesignal.com', /* subdomainName: Use the value you entered in step 1.4: http://imgur.com/a/f6hqN */ httpPermissionRequest: { enable: true }, notifyButton: { enable: true /* Set to false to hide */ } }]); </script>  
      Aici ar trebuie sa il adaug :
       

       
      Dece cand il adaug pagina " site-ul " se vede pus si simplu alb ?! Nu mai apare nimic , unde este gresala pe care o fac ?
      Am incercat sa il aduag in alta parte , dar imi apare o erroare la feed ... 
      Script-ul este pentru notoficare , platforma pe care o am este PHPVibe 
    • By FoxInFox
      Salut , 
       
      Caut un script cum este pluginul "Like Jacking Ninja" , exemple - Please login or register to see this link.
      Cand apasa "X" , defapt da like la pagina de facebook !
      Unde vreu eu sa adaug un script de genu nu am WP instalat !
      Ma intereseaza scriptul sa il adaug eu in header 
       
    • By shuttershades
      Doresc un script php care sa-mi modifice anumite chestii dintr-un landing page (titlu,meta tags,logo, cateva cuvinte cheie din index.html si altele din 3 fisiere .js).
      Atunci cand se genereazaza Landingul nou, sa se creeze si un folder pe host cu datele modificate.
      Practic am nevoie de un formular cu, campurile aferente in care trebuie sa pun date noi, si se genereaza folderul cu un nume anume pe host.Sau poate exisa alta solutie. Practic am nevoie sa generez cat mai multe Landing Pages intr-un timp cat mai scurt chiar daca e necesara si munca mea, sa stau sa modific mereu prin cod dureaza prea mult...:D
       
    • By MasterLight
      .
×