@kaelyx/ts-kit / string / exclamationmark
Function: exclamationmark()
exclamationmark(
input,options?):string
Defined in: string/exclamationmark/exclamationmark.ts:26
Ensures that the input string ends with an exclamation mark.
Parameters
input
string
Takes a string, considered to be a sentence, and ensures it ends in an exclamation mark. Use the options to customize the behaviour.
options?
Optional. See ExclamationmarkOptions.
Returns
string
The string with the punctuation added at the end.
Example
exclamationmark('watch out') // 'watch out!'
exclamationmark('watch out.') // 'watch out!'
exclamationmark('no way?.') // 'no way!'
exclamationmark('no way?.', { collapse: false }) // 'no way?!'
exclamationmark('watch out ', { trim: false }) // 'watch out !'
exclamationmark('', { skipEmpty: false }) // '!'Types
ExclamationmarkOptions interface
Defined in: string/exclamationmark/exclamationmark.types.ts:5
Options for exclamationmark.
Properties
collapse?
readonlyoptionalcollapse?:boolean
Defined in: string/exclamationmark/exclamationmark.types.ts:12
Treat a run of replacement characters as one: "What.?" -> "What!"
replacementCharacters?
readonlyoptionalreplacementCharacters?: readonlystring[]
Defined in: string/exclamationmark/exclamationmark.types.ts:8
The characters that should be replaced when found at the end. Defaults to ., ! and ?.
skipEmpty?
readonlyoptionalskipEmpty?:boolean
Defined in: string/exclamationmark/exclamationmark.types.ts:14
Leave a string with no content alone instead of returning bare punctuation.
trim?
readonlyoptionaltrim?:boolean
Defined in: string/exclamationmark/exclamationmark.types.ts:10
Strip trailing whitespace before deciding, and drop it from the result.