Word
Module to return various types of words.
adjective
Returns a random adjective.
Available since v6.0.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; } | 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 adjective(
options:
| number
| {
length?:
| number
| {
min: number;
max: number;
};
strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length';
} = {}
): string;
Examples
faker.word.adjective() // 'pungent'
faker.word.adjective(5) // 'slimy'
faker.word.adjective(100) // 'complete'
faker.word.adjective({ strategy: 'shortest' }) // 'icy'
faker.word.adjective({ length: { min: 5, max: 7 }, strategy: "fail" }) // 'distant'
Source
adverb
Returns a random adverb.
Available since v6.0.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; } | 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 adverb(
options:
| number
| {
length?:
| number
| {
min: number;
max: number;
};
strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length';
} = {}
): string;
Examples
faker.word.adverb() // 'quarrelsomely'
faker.word.adverb(5) // 'madly'
faker.word.adverb(100) // 'sadly'
faker.word.adverb({ strategy: 'shortest' }) // 'too'
faker.word.adverb({ length: { min: 5, max: 7 }, strategy: "fail" }) // 'sweetly'
Source
conjunction
Returns a random conjunction.
Available since v6.0.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; } | 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 conjunction(
options:
| number
| {
length?:
| number
| {
min: number;
max: number;
};
strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length';
} = {}
): string;
Examples
faker.word.conjunction() // 'in order that'
faker.word.conjunction(5) // 'since'
faker.word.conjunction(100) // 'as long as'
faker.word.conjunction({ strategy: 'shortest' }) // 'or'
faker.word.conjunction({ length: { min: 5, max: 7 }, strategy: "fail" }) // 'hence'
Source
interjection
Returns a random interjection.
Available since v6.0.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; } | 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 interjection(
options:
| number
| {
length?:
| number
| {
min: number;
max: number;
};
strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length';
} = {}
): string;
Examples
faker.word.interjection() // 'gah'
faker.word.interjection(5) // 'fooey'
faker.word.interjection(100) // 'yowza'
faker.word.interjection({ strategy: 'shortest' }) // 'hm'
faker.word.interjection({ length: { min: 5, max: 7 }, strategy: "fail" }) // 'boohoo'
Source
noun
Returns a random noun.
Available since v6.0.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; } | 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 noun(
options:
| number
| {
length?:
| number
| {
min: number;
max: number;
};
strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length';
} = {}
): string;
Examples
faker.word.noun() // 'external'
faker.word.noun(5) // 'front'
faker.word.noun(100) // 'care'
faker.word.noun({ strategy: 'shortest' }) // 'ad'
faker.word.noun({ length: { min: 5, max: 7 }, strategy: "fail" }) // 'average'
Source
preposition
Returns a random preposition.
Available since v6.0.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; } | 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 preposition(
options:
| number
| {
length?:
| number
| {
min: number;
max: number;
};
strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length';
} = {}
): string;
Examples
faker.word.preposition() // 'without'
faker.word.preposition(5) // 'abaft'
faker.word.preposition(100) // 'an'
faker.word.preposition({ strategy: 'shortest' }) // 'a'
faker.word.preposition({ length: { min: 5, max: 7 }, strategy: "fail" }) // 'given'
Source
sample
Returns a random word, that can be an adjective, adverb, conjunction, interjection, noun, preposition, or verb.
Available since v8.0.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; } | 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 sample(
options:
| number
| {
length?:
| number
| {
min: number;
max: number;
};
strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length';
} = {}
): string;
Examples
faker.word.sample() // 'incidentally'
faker.word.sample(5) // 'fruit'
Source
verb
Returns a random verb.
Available since v6.0.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; } | 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 verb(
options:
| number
| {
length?:
| number
| {
min: number;
max: number;
};
strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length';
} = {}
): string;
Examples
faker.word.verb() // 'act'
faker.word.verb(5) // 'tinge'
faker.word.verb(100) // 'mess'
faker.word.verb({ strategy: 'shortest' }) // 'do'
faker.word.verb({ length: { min: 5, max: 7 }, strategy: "fail" }) // 'vault'
Source
words
Returns a random string containing some words separated by spaces.
Available since v8.0.0
Parameters
Name | Type | Default | Description |
---|---|---|---|
options | number | { ... } | {} | The optional options object or the number of words to return. |
options.count? | number | { min: number; max: number; } | { min: 1, max: 3 } | The number of words to return. |
Returns: string
function words(
options:
| number
| {
count?:
| number
| {
min: number;
max: number;
};
} = {}
): string;
Examples
faker.word.words() // 'almost'
faker.word.words(5) // 'before hourly patiently dribble equal'
faker.word.words({ count: 5 }) // 'whoever edible um kissingly faraway'
faker.word.words({ count: { min: 5, max: 10 } }) // 'vice buoyant through apropos poised total wary boohoo'