Modules@robinpath/faker
faker

@robinpath/faker

0.1.1Node.jsPublic

Fake data generation with seedable PRNG. Generates names, emails, addresses, lorem ipsum, numbers, dates, UUIDs, colors, IPs, and more. No external dependencies.

Faker

Fake data generation with seedable PRNG. Generates names, emails, addresses, lorem ipsum, numbers, dates, UUIDs, colors, IPs, and more. No external dependencies.

Package: @robinpath/faker | Category: Utility | Type: Utility

Authentication

No authentication required. All functions are available immediately.

Use Cases

Use the faker module when you need to:

  • Set the random seed for reproducible fake data generation -- Use faker.seed to perform this operation
  • Generate a random full name -- Use faker.name to perform this operation
  • Generate a random first name -- Use faker.firstName to perform this operation
  • Generate a random last name -- Use faker.lastName to perform this operation
  • Generate a random email address -- Use faker.email to perform this operation

Quick Reference

FunctionDescriptionReturns
seedSet the random seed for reproducible fake data generationobject
nameGenerate a random full nameobject
firstNameGenerate a random first nameobject
lastNameGenerate a random last nameobject
emailGenerate a random email addressobject
phoneGenerate a random phone numberobject
addressGenerate a random street addressobject
cityGenerate a random city nameobject
countryGenerate a random country nameobject
zipCodeGenerate a random zip codeobject
companyGenerate a random company nameobject
loremGenerate lorem ipsum text as words, sentences, or paragraphsobject
numberGenerate a random integer within a rangeobject
floatGenerate a random floating-point number within a rangeobject
booleanGenerate a random boolean valueobject
dateGenerate a random date within a rangeobject
uuidGenerate a random UUID v4object
pickPick a random element from an arrayobject
shuffleRandomly shuffle an array using Fisher-Yates algorithmobject
paragraphGenerate a single random paragraph of lorem ipsumobject
sentenceGenerate a single random sentence of lorem ipsumobject
wordGenerate a single random lorem ipsum wordobject
colorGenerate a random color in hex, rgb, or name formatobject
ipGenerate a random IP addressobject
urlGenerate a random URLobject
avatarGenerate a random avatar image URLobject

Functions

seed

Set the random seed for reproducible fake data generation

Module: faker | Returns: object -- API response.

faker.seed
ParameterTypeRequiredDescription
seednumberNoSeed value for the PRNG

name

Generate a random full name

Module: faker | Returns: object -- API response.

faker.name
ParameterTypeRequiredDescription
(none)NoCall with no arguments

firstName

Generate a random first name

Module: faker | Returns: object -- API response.

faker.firstName
ParameterTypeRequiredDescription
(none)NoCall with no arguments

lastName

Generate a random last name

Module: faker | Returns: object -- API response.

faker.lastName
ParameterTypeRequiredDescription
(none)NoCall with no arguments

email

Generate a random email address

Module: faker | Returns: object -- API response.

faker.email
ParameterTypeRequiredDescription
(none)NoCall with no arguments

phone

Generate a random phone number

Module: faker | Returns: object -- API response.

faker.phone
ParameterTypeRequiredDescription
(none)NoCall with no arguments

address

Generate a random street address

Module: faker | Returns: object -- API response.

faker.address
ParameterTypeRequiredDescription
(none)NoCall with no arguments

city

Generate a random city name

Module: faker | Returns: object -- API response.

faker.city
ParameterTypeRequiredDescription
(none)NoCall with no arguments

country

Generate a random country name

Module: faker | Returns: object -- API response.

faker.country
ParameterTypeRequiredDescription
(none)NoCall with no arguments

zipCode

Generate a random zip code

Module: faker | Returns: object -- API response.

faker.zipCode
ParameterTypeRequiredDescription
formatstringNoZip code format where # is a digit (default #####)

company

Generate a random company name

Module: faker | Returns: object -- API response.

faker.company
ParameterTypeRequiredDescription
(none)NoCall with no arguments

lorem

Generate lorem ipsum text as words, sentences, or paragraphs

Module: faker | Returns: object -- API response.

faker.lorem
ParameterTypeRequiredDescription
typestringNoType of lorem text: words, sentences, or paragraphs (default words)
countnumberNoNumber of items to generate (default 5)

number

Generate a random integer within a range

Module: faker | Returns: object -- API response.

faker.number
ParameterTypeRequiredDescription
minnumberNoMinimum value (default 0)
maxnumberNoMaximum value (default 1000)

float

Generate a random floating-point number within a range

Module: faker | Returns: object -- API response.

faker.float
ParameterTypeRequiredDescription
minnumberNoMinimum value (default 0)
maxnumberNoMaximum value (default 1)
precisionnumberNoDecimal places (default 2)

boolean

Generate a random boolean value

Module: faker | Returns: object -- API response.

faker.boolean
ParameterTypeRequiredDescription
(none)NoCall with no arguments

date

Generate a random date within a range

Module: faker | Returns: object -- API response.

faker.date
ParameterTypeRequiredDescription
fromstringNoStart date ISO string (default 2000-01-01)
tostringNoEnd date ISO string (default now)

uuid

Generate a random UUID v4

Module: faker | Returns: object -- API response.

faker.uuid
ParameterTypeRequiredDescription
(none)NoCall with no arguments

pick

Pick a random element from an array

Module: faker | Returns: object -- API response.

faker.pick
ParameterTypeRequiredDescription
arrayarrayNoArray to pick from

shuffle

Randomly shuffle an array using Fisher-Yates algorithm

Module: faker | Returns: object -- API response.

faker.shuffle
ParameterTypeRequiredDescription
arrayarrayNoArray to shuffle

paragraph

Generate a single random paragraph of lorem ipsum

Module: faker | Returns: object -- API response.

faker.paragraph
ParameterTypeRequiredDescription
(none)NoCall with no arguments

sentence

Generate a single random sentence of lorem ipsum

Module: faker | Returns: object -- API response.

faker.sentence
ParameterTypeRequiredDescription
(none)NoCall with no arguments

word

Generate a single random lorem ipsum word

Module: faker | Returns: object -- API response.

faker.word
ParameterTypeRequiredDescription
(none)NoCall with no arguments

color

Generate a random color in hex, rgb, or name format

Module: faker | Returns: object -- API response.

faker.color
ParameterTypeRequiredDescription
formatstringNoColor format: hex, rgb, or name (default hex)

ip

Generate a random IP address

Module: faker | Returns: object -- API response.

faker.ip
ParameterTypeRequiredDescription
versionstringNoIP version: v4 or v6 (default v4)

url

Generate a random URL

Module: faker | Returns: object -- API response.

faker.url
ParameterTypeRequiredDescription
(none)NoCall with no arguments

avatar

Generate a random avatar image URL

Module: faker | Returns: object -- API response.

faker.avatar
ParameterTypeRequiredDescription
sizenumberNoAvatar size in pixels (default 200)
namestringNoName for the avatar initials

Error Handling

All functions throw on failure. Common errors:

ErrorCause
seed must be a numberCheck the error message for details
array must be a non-empty arrayCheck the error message for details
array must be an arrayCheck the error message for details
@desc "Seed and validate result"
do
  set $result as faker.seed
  if $result != null
    print "Success"
  else
    print "No result"
  end
enddo

Recipes

1. Create a new item with address

Create a new resource and capture the result.

set $result as faker.address
print "Created: " + $result

2. Multi-step Faker workflow

Chain multiple faker operations together.

@desc "Seed, name, and more"
do
  set $r_seed as faker.seed
  set $r_name as faker.name
  set $r_firstName as faker.firstName
  print "All operations complete"
enddo

3. Safe seed with validation

Check results before proceeding.

@desc "Seed and validate result"
do
  set $result as faker.seed
  if $result != null
    print "Success: " + $result
  else
    print "Operation returned no data"
  end
enddo

Related Modules

  • json -- JSON module for complementary functionality

Versions (1)

VersionTagPublished
0.1.1latest1 months ago
Install
$ robinpath add @robinpath/faker

Collaborators

Dumitru Balaban
Dumitru Balaban
@dumitru
View all @robinpath modules
Version0.1.1
LicenseMIT
Unpacked Size9.6 KB
Versions1
Weekly Downloads26
Total Downloads26
Stars0
Last Publish1 months ago
Created1 months ago

Category

utilities