Lorem
Module to generate random texts and words.
Overview
Generate dummy content using traditional faux-Latin lorem ipsum (in other locales to en
, alternative words may be used).
In order of increasing size you can generate a single word()
, multiple words()
, a sentence()
, multiple sentences()
, lines()
separated by newlines, one paragraph()
, or multiple paragraphs()
.
The generic text()
method can be used to generate some text between one sentence and multiple paragraphs, while slug()
generates an URL-friendly hyphenated string.
lines
Generates the given number lines of lorem separated by '\n'
.
Available since v3.1.0
Parameters
Name | Type | Default | Description |
---|---|---|---|
lineCount | number | { ... } | { min: 1, max: 5 } | The number of lines to generate. Defaults to a random number between |
lineCount.max | number | The maximum number of lines to generate. | |
lineCount.min | number | The minimum number of lines to generate. |
Returns: string
function lines(
lineCount:
| number
| {
min: number;
max: number;
} = { min: 1, max: 5 }
): string;
Examples
faker.lorem.lines()
// 'Pax impedit curriculum sint debitis vallum vix credo.
// Eveniet minus vespillo aeneus alias accusator tristis tergo usus.
// Thermae deinde termes angustus rerum arbitro vinco enim cuppedia celo.'
faker.lorem.lines()
// 'Minus accusamus quae perspiciatis provident villa.
// Contigo debilito subiungo adulescens sopor spargo bene aperiam.
// Convoco molestiae decens voveo ambitus.
// Arx solitudo catena deleniti.'
faker.lorem.lines(2)
// 'Articulus amor sollicito aptus.
// Corporis trado alter tum.'
faker.lorem.lines({ min: 1, max: 3 }) // 'Delicate voluptatibus pecco tactus adflicto cimentarius animi clementia angustus cometes.'
Source
paragraph
Generates a paragraph with the given number of sentences.
Available since v2.0.1
Parameters
Name | Type | Default | Description |
---|---|---|---|
sentenceCount | number | { ... } | 3 | The number of sentences to generate. |
sentenceCount.max | number | The maximum number of sentences to generate. | |
sentenceCount.min | number | The minimum number of sentences to generate. |
Returns: string
function paragraph(
sentenceCount:
| number
| {
min: number;
max: number;
} = 3
): string;
Examples
faker.lorem.paragraph() // 'Sumo pax impedit curriculum sint debitis vallum. Credo textilis eveniet minus vespillo aeneus alias accusator tristis tergo. Volutabrum thermae deinde termes angustus rerum arbitro vinco enim.'
faker.lorem.paragraph(2) // 'Celo teres defleo minus accusamus quae. Provident villa statim contigo debilito subiungo adulescens.'
faker.lorem.paragraph({ min: 1, max: 3 }) // 'Bene aperiam comedo convoco molestiae decens voveo ambitus. Arx solitudo catena deleniti. Articulus amor sollicito aptus.'
Source
paragraphs
Generates the given number of paragraphs.
Available since v2.0.1
Parameters
Name | Type | Default | Description |
---|---|---|---|
paragraphCount | number | { ... } | 3 | The number of paragraphs to generate. |
paragraphCount.max | number | The maximum number of paragraphs to generate. | |
paragraphCount.min | number | The minimum number of paragraphs to generate. | |
separator | string | '\n' | The separator to use. |
Returns: string
function paragraphs(
paragraphCount:
| number
| {
min: number;
max: number;
} = 3,
separator: string = '\n'
): string;
Examples
faker.lorem.paragraphs()
// 'Sumo pax impedit curriculum sint debitis vallum. Credo textilis eveniet minus vespillo aeneus alias accusator tristis tergo. Volutabrum thermae deinde termes angustus rerum arbitro vinco enim.
// Celo teres defleo minus accusamus quae. Provident villa statim contigo debilito subiungo adulescens. Spargo bene aperiam comedo convoco molestiae decens voveo.
// Bellicus arx solitudo. Deleniti caries articulus amor sollicito. Auxilium corporis trado alter.'
faker.lorem.paragraphs(5)
// 'Alo voluptatibus delicate voluptatibus pecco tactus adflicto cimentarius animi. Angustus cometes cupio advoco stultus. Cena eos aliquid nemo vetus comis sopor.
// Sumptus clam auctus occaecati. Tricesimus abeo spiritus. Tabesco vivo carpo nemo omnis.
// Cado viridis dedecor tyrannus subnecto coadunatio torqueo. Uxor nobis uxor stultus surgo desino. Sequi curriculum pecto accusantium cogito solutio clam quae curto appositus.
// Molestiae officiis natus solitudo solio. Vel corona debeo vapulus timidus succurro. Verto summopere vulticulus.
// Ustilo ascisco possimus anser. Timor modi cum aegrus subiungo defetiscor suppono usitas voluptates. Absum contigo sustineo astrum eligendi adopto aveho accusamus textus.'
faker.lorem.paragraphs(2, '<br/>\n')
// 'Coniuratio vestrum succurro addo. Quas neque capio victus. Facilis officia sustineo color cubicularis bellum audentia.<br/>
// Tactus depraedor calcar caterva adsuesco damno color subito crapula attero. Aegre spoliatio defetiscor. Vel vulariter bis somnus celer accusator tempora.'
faker.lorem.paragraphs({ min: 1, max: 3 }) // 'Odio tripudio quo uter certus theologus. Viridis stips bibo vinitor. Catena benigne eaque acies beatus currus corrumpo delectus.'
Source
sentence
Generates a space separated list of words beginning with a capital letter and ending with a period.
Available since v2.0.1
Parameters
Name | Type | Default | Description |
---|---|---|---|
wordCount | number | { ... } | { min: 3, max: 10 } | The number of words, that should be in the sentence. Defaults to a random number between |
wordCount.max | number | The maximum number of words to generate. | |
wordCount.min | number | The minimum number of words to generate. |
Returns: string
function sentence(
wordCount:
| number
| {
min: number;
max: number;
} = { min: 3, max: 10 }
): string;
Examples
faker.lorem.sentence() // 'Sumo pax impedit curriculum sint debitis vallum.'
faker.lorem.sentence(5) // 'Vix credo textilis eveniet minus.'
faker.lorem.sentence({ min: 3, max: 5 }) // 'Aeneus alias accusator tristis tergo.'
Source
sentences
Generates the given number of sentences.
Available since v2.0.1
Parameters
Name | Type | Default | Description |
---|---|---|---|
sentenceCount | number | { ... } | { min: 2, max: 6 } | The number of sentences to generate. Defaults to a random number between |
sentenceCount.max | number | The maximum number of sentences to generate. | |
sentenceCount.min | number | The minimum number of sentences to generate. | |
separator | string | ' ' | The separator to add between sentences. |
Returns: string
function sentences(
sentenceCount:
| number
| {
min: number;
max: number;
} = { min: 2, max: 6 },
separator: string = ' '
): string;
Examples
faker.lorem.sentences() // 'Pax impedit curriculum sint debitis vallum vix credo. Eveniet minus vespillo aeneus alias accusator tristis tergo usus. Thermae deinde termes angustus rerum arbitro vinco enim cuppedia celo. Defleo minus accusamus quae perspiciatis provident villa statim contigo.'
faker.lorem.sentences(2) // 'Subiungo adulescens sopor spargo bene aperiam. Convoco molestiae decens voveo ambitus.'
faker.lorem.sentences(2, '\n')
// 'Arx solitudo catena deleniti.
// Articulus amor sollicito aptus.'
faker.lorem.sentences({ min: 1, max: 3 }) // 'Trado alter tum alo voluptatibus.'
Source
slug
Generates a slugified text consisting of the given number of hyphen separated words.
Available since v4.0.0
Parameters
Name | Type | Default | Description |
---|---|---|---|
wordCount | number | { ... } | 3 | The number of words to generate. |
wordCount.max | number | The maximum number of words to generate. | |
wordCount.min | number | The minimum number of words to generate. |
Returns: string
function slug(
wordCount:
| number
| {
min: number;
max: number;
} = 3
): string;
Examples
faker.lorem.slug() // 'inflammatio-sumo-pax'
faker.lorem.slug(5) // 'impedit-curriculum-sint-debitis-vallum'
faker.lorem.slug({ min: 1, max: 3 }) // 'credo-textilis-eveniet'
Source
text
Generates a random text based on a random lorem method.
Available since v3.1.0
Returns: string
function text(): string;
Examples
faker.lorem.text() // 'Pax impedit curriculum sint debitis vallum vix credo. Eveniet minus vespillo aeneus alias accusator tristis tergo usus. Thermae deinde termes angustus rerum arbitro vinco enim cuppedia celo.'
faker.lorem.text()
// 'Minus accusamus quae perspiciatis provident villa. Contigo debilito subiungo adulescens sopor spargo bene aperiam. Convoco molestiae decens voveo ambitus.
// Arx solitudo catena deleniti. Articulus amor sollicito aptus. Corporis trado alter tum.
// Voluptatibus delicate voluptatibus. Tactus adflicto cimentarius animi clementia angustus cometes. Advoco stultus minima cena eos aliquid.'
Source
word
Generates a word of a specified length.
Available since v3.1.0
Parameters
Name | Type | Default | Description |
---|---|---|---|
options | number | { ... } | {} | The expected length of the word or the options to use. |
options.length? | number | { min: number; max: number; } | 1 | The expected length of the word. |
options.strategy? | 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length' | 'any-length' | The strategy to apply when no words with a matching length are found. Available error handling strategies:
|
Returns: string
function word(
options:
| number
| {
length?:
| number
| {
min: number;
max: number;
};
strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length';
} = {}
): string;
Examples
faker.lorem.word() // 'inflammatio'
faker.lorem.word(5) // 'teneo'
faker.lorem.word({ strategy: 'shortest' }) // 'a'
faker.lorem.word({ length: { min: 5, max: 7 }, strategy: 'fail' }) // 'pauci'
Source
words
Generates a space separated list of words.
Available since v2.0.1
Parameters
Name | Type | Default | Description |
---|---|---|---|
wordCount | number | { ... } | 3 | The number of words to generate. |
wordCount.max | number | The maximum number of words to generate. | |
wordCount.min | number | The minimum number of words to generate. |
Returns: string
function words(
wordCount:
| number
| {
min: number;
max: number;
} = 3
): string;
Examples
faker.lorem.words() // 'inflammatio sumo pax'
faker.lorem.words(10) // 'impedit curriculum sint debitis vallum vix credo textilis eveniet minus'
faker.lorem.words({ min: 1, max: 3 }) // 'aeneus alias accusator'