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