Docs
/
modifiers

Modifiers

Modify and transform your content with our collection of efficient and easy-to-use functions designed to dicipher, manipulate, and transform strings.

startWith

Link Copied!

Adds a prefix to a string if it doesn't already start with the prefix.

startWith('usemods.com', 'https://')
https://usemods.com
Result
startWith(value: string, start: string)

startWithout

Link Copied!

Removes a prefix from a string if it starts with the prefix.

startWithout('https://usemods.com', 'https://')
usemods.com
Result
startWithout(value: string, start: string)

endWith

Link Copied!

Adds a suffix to a string if it doesn't already end with the suffix.

endWith('https://usemods', '.com')
https://usemods.com
Result
endWith(text: string, end: string)

endWithout

Link Copied!

Removes a suffix from a string if it ends with the suffix.

endWithout('https://usemods.com/rocks', 'rocks')
https://usemods.com/
Result
endWithout(text: string, end: string)

surroundWith

Link Copied!

Adds a prefix and suffix to a string if it doesn't already start and end with them.

surroundWith('usemods', 'https://', '.com')
https://usemods.com
Result
surroundWith(text: string, start: string, end: string)

pluralize

Link Copied!

Adds plurals to a string except for excluded words.

pluralize('knife', 2)
knives
Result
This handles most english pluralisation rules, but there are exceptions.
pluralize(word: string, count: number)

singularize

Link Copied!

Removes plurals from a string.

singularize('knives')
knife
Result
This handles most english pluralisation rules, but there are exceptions.
singularize(value: string)

ordinalize

Link Copied!

Converts a number to a string with ordinal suffix.

ordinalize(1)
1st
Result
ordinalize(value: number)

stripHtml

Link Copied!

Strip HTML tags from a string.

Some HTML content
Result
stripHtml(text: string)

stripWhitespace

Link Copied!

Strips whitespace from a string.

Scootersarethepastandourfuture
Result
stripWhitespace(text: string)

stripNumbers

Link Copied!

Strips numbers from a string.

Scooters
Result
stripNumbers(text: string)

stripPunctuation

Link Copied!

Strips punctuation from a string.

Scooters
Result
stripPunctuation(text: string)

stripSymbols

Link Copied!

Strips symbols from a string.

Scooters
Result
stripSymbols(text: string)

stripEmojis

Link Copied!

Strips emojis from a string (requires ES6 Unicode support) 🦊.

S‍erious Business
Result
stripEmojis(text: string)

slugify

Link Copied!

Converts a string to-a-slug.

scooters-are-the-future
Result
slugify(text: string)

deslugify

Link Copied!

Converts a slug to a string.

scooters are the future
Result
deslugify(text: string)

camelCase

Link Copied!

Removes spaces and capitalizes the first letter of each word except for the first word.

scootsAndScooters
Result
camelCase(text: string)

pascalCase

Link Copied!

Removes spaces and capitalizes the first letter of each word.

ScootsAndScooters
Result
pascalCase(text: string)

snakeCase

Link Copied!

Replaces spaces with underscores and converts to lowercase.

scoots_and_scooters
Result
snakeCase(text: string)

kebabCase

Link Copied!

Replaces spaces with hyphens and converts to lowercase.

scoots-and-scooters
Result
kebabCase(text: string)

titleCase

Link Copied!

Converts to title case by capitalizing the first letter of each word.

Scooters
Result
titleCase(text: string)

escapeHtml

Link Copied!

Escape HTML entities in a string.

<p>Hello World</p>
Result
escapeHtml(text: string)

unescapeHtml

Link Copied!

Unescape HTML entities in a string.

<p>Hello World</p>
Result
unescapeHtml(text: string)