Contains utility functions for string operations.
| Function | Description |
|---|
| ensureEndsWith | Ensures that a string ends with the specified suffix, adding it if necessary. |
| ensureLfEndings | Ensures that a string has LF line endings. It replaces CRLF line endings with LF. |
| ensureStartsWith | Ensures that a string starts with the specified prefix, adding it if necessary. |
| escape | Escapes special characters in a string. |
| getLfNormalizedOffsetToOriginalOffsetMapper | Returns a function that maps LF-normalized offsets to original offsets. |
| hasSingleOccurrence | Checks if a string has a single occurrence of a search value. |
| indent | Indents a string by adding a prefix to each line. |
| insertAt | Inserts a substring at a specified position in a string. |
| makeValidVariableName | Converts a string into a valid JavaScript variable name by replacing invalid characters with underscores. |
| normalizeString | Normalizes a string by converting it to the NFC form and replacing non-breaking spaces with regular spaces. |
| replace | Replaces occurrences of strings in a given string based on a replacements map. |
| replaceAll | Replaces all occurrences of a search string or pattern with the results of an replacer function. |
| replaceAllAsync | Asynchronously replaces all occurrences of a search string or pattern with the results of an asynchronous replacer function. |
| trimEnd | Trims the specified suffix from the end of a string. |
| trimStart | Trims the specified prefix from the start of a string. |
| unescape | Unescapes a string by replacing escape sequences with their corresponding characters. |
| unindent | Unindents a string by removing a prefix from each line. |
| Type | Description |
|---|
| AsyncReplacer | A synchronous/asynchronous function that generates replacement strings, or a string to replace with. |
| Replacer | A synchronous function that generates replacement strings, or a string to replace with. |
| Variable | Description |
|---|
| EMPTY | An empty string constant. A shared sentinel for the $\{EMPTY\} prefix that silences the obsidianmd/ui/sentence-case ESLint false positive on legitimate lower-case UI text (e.g. cursor colliding with the Cursor brand). setName(${EMPTY}…at cursor…) renders byte-identical '' at runtime while the \{...\} placeholder makes the rule skip the string. Consumers import this instead of redefining a per-file const EMPTY = ''. |