Module to return various types of words.Module Overview#
This module provides methods to generate random words of different parts of speech, including adjectives, adverbs, conjunctions, interjections, prepositions, verbs, and nouns (via sample).You can control the length of the generated word using the length or min/max parameters, and specify a strategy (fail, closest, longest, shortest, any-length) to handle cases where no exact match is found.
adjective#
Returns a random adjective.| Name | Type | Default | Description |
|---|
| length | number | | The expected length of the word. |
| min | number | | The minimum length of the word. |
| max | number | | The maximum length of the word. |
| 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:- fail: Throws an error if no words with the given length are found.- shortest: Returns any of the shortest words.- closest: Returns any of the words closest to the given length.- longest: Returns any of the longest words.- any-length: Returns a word with any length. |
adverb#
| Name | Type | Default | Description |
|---|
| length | number | | The expected length of the word. |
| min | number | | The minimum length of the word. |
| max | number | | The maximum length of the word. |
| 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:- fail: Throws an error if no words with the given length are found.- shortest: Returns any of the shortest words.- closest: Returns any of the words closest to the given length.- longest: Returns any of the longest words.- any-length: Returns a word with any length. |
conjunction#
Returns a random conjunction.| Name | Type | Default | Description |
|---|
| length | number | | The expected length of the word. |
| min | number | | The minimum length of the word. |
| max | number | | The maximum length of the word. |
| 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:- fail: Throws an error if no words with the given length are found.- shortest: Returns any of the shortest words.- closest: Returns any of the words closest to the given length.- longest: Returns any of the longest words.- any-length: Returns a word with any length. |
interjection#
Returns a random interjection.| Name | Type | Default | Description |
|---|
| length | number | | The expected length of the word. |
| min | number | | The minimum length of the word. |
| max | number | | The maximum length of the word. |
| 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:- fail: Throws an error if no words with the given length are found.- shortest: Returns any of the shortest words.- closest: Returns any of the words closest to the given length.- longest: Returns any of the longest words.- any-length: Returns a word with any length. |
preposition#
Returns a random preposition.| Name | Type | Default | Description |
|---|
| length | number | | The expected length of the word. |
| min | number | | The minimum length of the word. |
| max | number | | The maximum length of the word. |
| 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:- fail: Throws an error if no words with the given length are found.- shortest: Returns any of the shortest words.- closest: Returns any of the words closest to the given length.- longest: Returns any of the longest words.- any-length: Returns a word with any length. |
sample#
Returns a random word, that can be an adjective, adverb, conjunction, interjection, noun, preposition, or verb.| Name | Type | Default | Description |
|---|
| length | number | | The expected length of the word. |
| min | number | | The minimum length of the word. |
| max | number | | The maximum length of the word. |
| 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:- fail: Throws an error if no words with the given length are found.- shortest: Returns any of the shortest words.- closest: Returns any of the words closest to the given length.- longest: Returns any of the longest words.- any-length: Returns a word with any length. |
verb#
| Name | Type | Default | Description |
|---|
| length | number | | The expected length of the word. |
| min | number | | The minimum length of the word. |
| max | number | | The maximum length of the word. |
| 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:- fail: Throws an error if no words with the given length are found.- shortest: Returns any of the shortest words.- closest: Returns any of the words closest to the given length.- longest: Returns any of the longest words.- any-length: Returns a word with any length. |
words#
Returns a random string containing some words separated by spaces.| Name | Type | Default | Description |
|---|
| count | number | { min: 1, max: 3 } | The number of words to return. |
| min | number | | The minimum length of the word. |
| max | number | | The maximum length of the word. |
Modified atΒ 2026-01-14 09:10:00