@robinpath/faker
0.1.1Node.jsPublicFake 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.seedto perform this operation - Generate a random full name -- Use
faker.nameto perform this operation - Generate a random first name -- Use
faker.firstNameto perform this operation - Generate a random last name -- Use
faker.lastNameto perform this operation - Generate a random email address -- Use
faker.emailto perform this operation
Quick Reference
| Function | Description | Returns |
|---|---|---|
seed | Set the random seed for reproducible fake data generation | object |
name | Generate a random full name | object |
firstName | Generate a random first name | object |
lastName | Generate a random last name | object |
email | Generate a random email address | object |
phone | Generate a random phone number | object |
address | Generate a random street address | object |
city | Generate a random city name | object |
country | Generate a random country name | object |
zipCode | Generate a random zip code | object |
company | Generate a random company name | object |
lorem | Generate lorem ipsum text as words, sentences, or paragraphs | object |
number | Generate a random integer within a range | object |
float | Generate a random floating-point number within a range | object |
boolean | Generate a random boolean value | object |
date | Generate a random date within a range | object |
uuid | Generate a random UUID v4 | object |
pick | Pick a random element from an array | object |
shuffle | Randomly shuffle an array using Fisher-Yates algorithm | object |
paragraph | Generate a single random paragraph of lorem ipsum | object |
sentence | Generate a single random sentence of lorem ipsum | object |
word | Generate a single random lorem ipsum word | object |
color | Generate a random color in hex, rgb, or name format | object |
ip | Generate a random IP address | object |
url | Generate a random URL | object |
avatar | Generate a random avatar image URL | object |
Functions
seed
Set the random seed for reproducible fake data generation
Module: faker | Returns: object -- API response.
faker.seed
| Parameter | Type | Required | Description |
|---|---|---|---|
seed | number | No | Seed value for the PRNG |
name
Generate a random full name
Module: faker | Returns: object -- API response.
faker.name
| Parameter | Type | Required | Description |
|---|---|---|---|
| (none) | No | Call with no arguments |
firstName
Generate a random first name
Module: faker | Returns: object -- API response.
faker.firstName
| Parameter | Type | Required | Description |
|---|---|---|---|
| (none) | No | Call with no arguments |
lastName
Generate a random last name
Module: faker | Returns: object -- API response.
faker.lastName
| Parameter | Type | Required | Description |
|---|---|---|---|
| (none) | No | Call with no arguments |
Generate a random email address
Module: faker | Returns: object -- API response.
faker.email
| Parameter | Type | Required | Description |
|---|---|---|---|
| (none) | No | Call with no arguments |
phone
Generate a random phone number
Module: faker | Returns: object -- API response.
faker.phone
| Parameter | Type | Required | Description |
|---|---|---|---|
| (none) | No | Call with no arguments |
address
Generate a random street address
Module: faker | Returns: object -- API response.
faker.address
| Parameter | Type | Required | Description |
|---|---|---|---|
| (none) | No | Call with no arguments |
city
Generate a random city name
Module: faker | Returns: object -- API response.
faker.city
| Parameter | Type | Required | Description |
|---|---|---|---|
| (none) | No | Call with no arguments |
country
Generate a random country name
Module: faker | Returns: object -- API response.
faker.country
| Parameter | Type | Required | Description |
|---|---|---|---|
| (none) | No | Call with no arguments |
zipCode
Generate a random zip code
Module: faker | Returns: object -- API response.
faker.zipCode
| Parameter | Type | Required | Description |
|---|---|---|---|
format | string | No | Zip code format where # is a digit (default #####) |
company
Generate a random company name
Module: faker | Returns: object -- API response.
faker.company
| Parameter | Type | Required | Description |
|---|---|---|---|
| (none) | No | Call with no arguments |
lorem
Generate lorem ipsum text as words, sentences, or paragraphs
Module: faker | Returns: object -- API response.
faker.lorem
| Parameter | Type | Required | Description |
|---|---|---|---|
type | string | No | Type of lorem text: words, sentences, or paragraphs (default words) |
count | number | No | Number of items to generate (default 5) |
number
Generate a random integer within a range
Module: faker | Returns: object -- API response.
faker.number
| Parameter | Type | Required | Description |
|---|---|---|---|
min | number | No | Minimum value (default 0) |
max | number | No | Maximum value (default 1000) |
float
Generate a random floating-point number within a range
Module: faker | Returns: object -- API response.
faker.float
| Parameter | Type | Required | Description |
|---|---|---|---|
min | number | No | Minimum value (default 0) |
max | number | No | Maximum value (default 1) |
precision | number | No | Decimal places (default 2) |
boolean
Generate a random boolean value
Module: faker | Returns: object -- API response.
faker.boolean
| Parameter | Type | Required | Description |
|---|---|---|---|
| (none) | No | Call with no arguments |
date
Generate a random date within a range
Module: faker | Returns: object -- API response.
faker.date
| Parameter | Type | Required | Description |
|---|---|---|---|
from | string | No | Start date ISO string (default 2000-01-01) |
to | string | No | End date ISO string (default now) |
uuid
Generate a random UUID v4
Module: faker | Returns: object -- API response.
faker.uuid
| Parameter | Type | Required | Description |
|---|---|---|---|
| (none) | No | Call with no arguments |
pick
Pick a random element from an array
Module: faker | Returns: object -- API response.
faker.pick
| Parameter | Type | Required | Description |
|---|---|---|---|
array | array | No | Array to pick from |
shuffle
Randomly shuffle an array using Fisher-Yates algorithm
Module: faker | Returns: object -- API response.
faker.shuffle
| Parameter | Type | Required | Description |
|---|---|---|---|
array | array | No | Array to shuffle |
paragraph
Generate a single random paragraph of lorem ipsum
Module: faker | Returns: object -- API response.
faker.paragraph
| Parameter | Type | Required | Description |
|---|---|---|---|
| (none) | No | Call with no arguments |
sentence
Generate a single random sentence of lorem ipsum
Module: faker | Returns: object -- API response.
faker.sentence
| Parameter | Type | Required | Description |
|---|---|---|---|
| (none) | No | Call with no arguments |
word
Generate a single random lorem ipsum word
Module: faker | Returns: object -- API response.
faker.word
| Parameter | Type | Required | Description |
|---|---|---|---|
| (none) | No | Call with no arguments |
color
Generate a random color in hex, rgb, or name format
Module: faker | Returns: object -- API response.
faker.color
| Parameter | Type | Required | Description |
|---|---|---|---|
format | string | No | Color format: hex, rgb, or name (default hex) |
ip
Generate a random IP address
Module: faker | Returns: object -- API response.
faker.ip
| Parameter | Type | Required | Description |
|---|---|---|---|
version | string | No | IP version: v4 or v6 (default v4) |
url
Generate a random URL
Module: faker | Returns: object -- API response.
faker.url
| Parameter | Type | Required | Description |
|---|---|---|---|
| (none) | No | Call with no arguments |
avatar
Generate a random avatar image URL
Module: faker | Returns: object -- API response.
faker.avatar
| Parameter | Type | Required | Description |
|---|---|---|---|
size | number | No | Avatar size in pixels (default 200) |
name | string | No | Name for the avatar initials |
Error Handling
All functions throw on failure. Common errors:
| Error | Cause |
|---|---|
seed must be a number | Check the error message for details |
array must be a non-empty array | Check the error message for details |
array must be an array | Check 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)
| Version | Tag | Published |
|---|---|---|
| 0.1.1 | latest | 1 months ago |
Related Modules
@robinpathv0.1.4
SMTP email sending and address parsing for RobinPath
hash
JS@robinpathv0.1.3
Cryptographic hashing utilities: MD5, SHA family, HMAC, CRC32, file hashing, UUID v5 generation, secure random bytes, and content fingerprinting
csv
JS@robinpathv0.1.2
Parse and stringify CSV data
apollo
JS@robinpathv0.1.2
Apollo module for RobinPath.
$ robinpath add @robinpath/faker
