(str: string): number import {count_graphemes} from '@fuzdev/fuz_util/string.js'; Returns the count of graphemes in a string, the individually rendered characters.
str
stringreturns
number 17 declarations
(str: string): number import {count_graphemes} from '@fuzdev/fuz_util/string.js'; Returns the count of graphemes in a string, the individually rendered characters.
strstringnumber (str: string): string import {deindent} from '@fuzdev/fuz_util/string.js'; Removes leading and trailing spaces from each line of a string.
strstringstring (source: string, ensured: string): string import {ensure_end} from '@fuzdev/fuz_util/string.js'; Adds the substring ensured to the end of the source string if it's not already present.
sourcestringensuredstringstring (source: string, ensured: string): string import {ensure_start} from '@fuzdev/fuz_util/string.js'; Adds the substring ensured to the start of the source string if it's not already present.
sourcestringensuredstringstring (value: string): string import {escape_js_string} from '@fuzdev/fuz_util/string.js'; Escapes a string for use inside a single-quoted JS string literal.
Uses a single-pass regex replacement to escape backslashes, single quotes, newlines, carriage returns, and Unicode line/paragraph separators.
valuestringstring (a: string, b: string): number import {levenshtein_distance} from '@fuzdev/fuz_util/string.js'; Calculates the Levenshtein distance between two strings. Useful for typo detection and fuzzy matching.
astringbstringnumber the edit distance between the strings
(str: string, target_width: number, align?: "left" | "right"): string import {pad_width} from '@fuzdev/fuz_util/string.js'; Pad a string to a target display width (accounting for wide characters).
strstringtarget_widthnumberalign"left" | "right"'left'string (count: number | null | undefined, suffix?: string): string import {plural} from '@fuzdev/fuz_util/string.js'; Returns a plural suffix based on a count.
countnumber | null | undefinedsuffixstring's'string (str: string): number import {string_display_width} from '@fuzdev/fuz_util/string.js'; Calculate the display width of a string in terminal columns.
Intl.Segmenter to properly handle grapheme clusters (e.g., family emoji "๐จโ๐ฉโ๐งโ๐ฆ")strstringnumber (content: string): boolean import {string_is_binary} from '@fuzdev/fuz_util/string.js'; Check if content appears to be binary.
Checks for null bytes in the first 8KB of content.
contentstringboolean (value: unknown): string import {stringify} from '@fuzdev/fuz_util/string.js'; Stringifies a value like JSON.stringify but with some corner cases handled better.
valueunknownstring (source: string, stripped: string): string import {strip_after} from '@fuzdev/fuz_util/string.js'; Removes characters inclusive of stripped.
sourcestringstrippedstringstring (str: string): string import {strip_ansi} from '@fuzdev/fuz_util/string.js'; Strips ANSI escape sequences from a string.
strstringstring (source: string, stripped: string): string import {strip_before} from '@fuzdev/fuz_util/string.js'; Removes characters inclusive of stripped.
sourcestringstrippedstringstring (source: string, stripped: string): string import {strip_end} from '@fuzdev/fuz_util/string.js'; Removes characters inclusive of stripped.
sourcestringstrippedstringstring (source: string, stripped: string): string import {strip_start} from '@fuzdev/fuz_util/string.js'; Removes characters inclusive of stripped.
sourcestringstrippedstringstring (str: string, maxLength: number, suffix?: string): string import {truncate} from '@fuzdev/fuz_util/string.js'; Truncates a string to a maximum length, adding a suffix if needed that defaults to ....
strstringmaxLengthnumbersuffixstring'...'string