node-lib

@wtasnorg/node-lib


@wtasnorg/node-lib / cutSuffixString

Function: cutSuffixString()

cutSuffixString(s, suffix): object

Defined in: src/strings.ts:303

CutSuffix returns s without the provided ending suffix string and reports whether it found the suffix.

Parameters

s

string

Input string.

suffix

string

Suffix to remove.

Returns

object

before

before: string

found

found: boolean

Example

cutSuffix("Gopher", "er"); // { before: "Goph", found: true }
cutSuffix("Gopher", "X");  // { before: "Gopher", found: false }
cutSuffix("ab", "abc");    // { before: "ab", found: false } — suffix longer than s