string/generateText

Generates a string with a minimum and a maximum number of random words picking from a dictionary.

Source:

Methods

(static) generateText(object) → {string}

Source:
Example
import { generateText } from '@untemps/utils/string/generateText'

const minWords = 5;
const maxWords = 10;
const dictionary = ['foo', 'bar', 'gag'];
generateText({minWords, maxWords, dictionary}) // bar foo foo gag gag bar gag gag
Parameters:
Name Type Description
object object

The configuration object for the text generation.

Properties
Name Type Attributes Default Description
minWords number <optional>
10

The minimum number of words to pick.

maxWords number <optional>
50

The maximum number of words to pick.

dictionary Array.<string> <optional>
[...]

A list of words from which picking the words.

Returns:

The generated string.

Type
string