Skip to content

String

capitalizeFirstLetter(string): string

Defined in: packages/isaacscript-common/src/functions/string.ts:5

string

string


getMapPartialMatch<T>(searchText, map): [string, T] | undefined

Defined in: packages/isaacscript-common/src/functions/string.ts:40

Helper function to get the closest key from a map based on partial search text. (It only searches through the keys, not the values.)

Note that:

  • Spaces are automatically removed from the search text.
  • Both the search text and the strings to search through are converted to lowercase before attempting to find a match.

For example:

const map = new <string, number>Map([
["foo", 123],
["bar", 456],
]);
const searchText = "f";
const match = getMapPartialMatch(map, searchText); // match is now equal to ["foo", 123]

T

string

ReadonlyMap<string, T>

[string, T] | undefined

If a match was found, returns a tuple of the map key and value. If a match was not found, returns undefined.


getObjectPartialMatch<T>(searchText, object): [string, T] | undefined

Defined in: packages/isaacscript-common/src/functions/string.ts:83

Helper function to get the closest key from an object based on partial search text. (It only searches through the keys, not the values.)

Note that:

  • Spaces are automatically removed from the search text.
  • Both the search text and the strings to search through are converted to lowercase before attempting to find a match.

For example:

const object = {
foo: 123,
bar: 456,
};
const searchText = "f";
const match = getObjectPartialMatch(object, searchText); // match is now equal to ["foo", 123]

T

string

ReadonlyRecord<string, T>

[string, T] | undefined

If a match was found, returns a tuple of the map key and value. If a match was not found, returns undefined.


getPartialMatch(searchText, array): string | undefined

Defined in: packages/isaacscript-common/src/functions/string.ts:122

Helper function to get the closest value from an array of strings based on partial search text.

Note that:

  • Spaces are automatically removed from the search text.
  • Both the search text and the strings to search through are converted to lowercase before attempting to find a match.

For example:

const array = ["foo", "bar"];
const searchText = "f";
const match = getPartialMatch(array, searchText); // match is now equal to "foo"

string

readonly string[]

string | undefined

If a match was found, returns the array element. If a match was not found, returns undefined.


parseSemanticVersion(versionString): { majorVersion: int; minorVersion: int; patchVersion: int; } | undefined

Defined in: packages/isaacscript-common/src/functions/string.ts:145

Helper function to parse a Semantic Versioning string into its individual constituents. Returns undefined if the submitted string was not a proper Semantic Version string.

string

{ majorVersion: int; minorVersion: int; patchVersion: int; } | undefined

https://semver.org/


removeAllCharacters(string, character): string

Defined in: packages/isaacscript-common/src/functions/string.ts:182

string

string

string


removeCharactersBefore(string, substring): string

Defined in: packages/isaacscript-common/src/functions/string.ts:190

Helper function to remove all of the characters in a string before a given substring. Returns the modified string.

string

string

string


removeNonAlphanumericCharacters(str): string

Defined in: packages/isaacscript-common/src/functions/string.ts:199

Helper function to remove all characters from a string that are not letters or numbers.

string

string


removeSubstring(string, …substrings): string

Defined in: packages/isaacscript-common/src/functions/string.ts:210

Helper function to remove one or more substrings from a string, if they exist. Returns the modified string.

This function is variadic, meaning that you can pass as many substrings as you want to remove.

string

…readonly string[]

string


trimPrefix(string, prefix): string

Defined in: packages/isaacscript-common/src/functions/string.ts:222

Helper function to trim a prefix from a string, if it exists. Returns the trimmed string.

string

string

string


trimSuffix(string, prefix): string

Defined in: packages/isaacscript-common/src/functions/string.ts:231

Helper function to trim a suffix from a string, if it exists. Returns the trimmed string.

string

string

string


uncapitalizeFirstLetter(string): string

Defined in: packages/isaacscript-common/src/functions/string.ts:240

string

string