Docs
/
goodies

Goodies

A collection neat little functions that don't belong anywhere else.

splitByWords

Link Copied!

Wraps each word, sentence or paragraph in a string with a tag.

<span class="sentence sentence-1"><span class="word word-1">Scooters</span> <span class="word word-2">are</span> <span class="word word-3">the</span> <span class="word word-4">future</span></span>
Result
Don't forget to render the HTML safely.
splitByWords(text: string)

checkPasswordStrength

Link Copied!

Check the strength of a password against a given policy.

checkPasswordStrength('Pa$$-w0rD!', { length: 8, uppercase: 1, number: 1, special: 1 })
{ "score": 4, "label": "Very Strong" }
Result
Don't forget to use our Password Generator in the Generators section
checkPasswordStrength(text: string, options?: { length?: number, uppercase?: number, number?: number, special?: number })

mergeFields

Link Copied!

Replaces placeholders in a string with values from an object.

mergeFields(Hi {{ name }}, your {{ vehicle }} is ready. Your {{ vehicle }} was missing a {{ part }}., { name: John, vehicle: scooter, part: motor })
Hi John, your scooter is ready. Your scooter was missing a motor.
Result
mergeFields(text: string, fields: Record<string | number, string | number>)

readingTime

Link Copied!

Returns the reading time of a string in Hours, Minutes, and Seconds.

1 minute
Result
readingTime(text: string, wordsPerMinute = 200)