string.ts

Declarations
#

12 declarations

view source

count_graphemes
#

string.ts view source

(str: string): number

Returns the count of graphemes in a string, the individually rendered characters.

str

type string

returns

number

deindent
#

string.ts view source

(str: string): string

Removes leading and trailing spaces from each line of a string.

str

type string

returns

string

ensure_end
#

string.ts view source

(source: string, ensured: string): string

Adds the substring ensured to the end of the source string if it's not already present.

source

type string

ensured

type string

returns

string

ensure_start
#

string.ts view source

(source: string, ensured: string): string

Adds the substring ensured to the start of the source string if it's not already present.

source

type string

ensured

type string

returns

string

plural
#

string.ts view source

(count: number | null | undefined, suffix?: string): string

Returns a plural suffix based on a count.

count

type number | null | undefined

suffix

type string
default 's'

returns

string

stringify
#

string.ts view source

(value: unknown): string

Stringifies a value like JSON.stringify but with some corner cases handled better.

value

type unknown

returns

string

strip_after
#

string.ts view source

(source: string, stripped: string): string

Removes characters inclusive of stripped.

source

type string

stripped

type string

returns

string

strip_ansi
#

string.ts view source

(str: string): string

Strips ANSI escape sequences from a string

str

type string

returns

string

strip_before
#

string.ts view source

(source: string, stripped: string): string

Removes characters inclusive of stripped.

source

type string

stripped

type string

returns

string

strip_end
#

string.ts view source

(source: string, stripped: string): string

Removes characters inclusive of stripped.

source

type string

stripped

type string

returns

string

strip_start
#

string.ts view source

(source: string, stripped: string): string

Removes characters inclusive of stripped.

source

type string

stripped

type string

returns

string

truncate
#

string.ts view source

(str: string, maxLength: number, suffix?: string): string

Truncates a string to a maximum length, adding a suffix if needed that defaults to ....

str

type string

maxLength

type number

suffix

type string
default '...'

returns

string

Depends on
#

Imported by
#