add core docs

This commit is contained in:
2025-02-10 09:48:59 -06:00
parent 7283ced1ca
commit 375a6ad3a4
74 changed files with 5148 additions and 643 deletions

793
docs/dull/String.md Normal file
View File

@@ -0,0 +1,793 @@
# String
### length <sub>number</sub>
### at(index) <sub>function</sub>
Return the character (or surrogate pair) at the specified index, with support
for negative indices (counting from the end). If the index is out of range,
returns undefined.
**index**: The position of the character to return (can be negative).
**Returns**: A string of length 1 representing the character, or undefined if out of range.
### charCodeAt(index) <sub>function</sub>
Return a number indicating the UTF-16 code unit value at the given index.
If the index is out of range, returns NaN.
**index**: An integer between 0 and string length - 1.
**Returns**: An integer in the range [0, 65535] or NaN if out of range.
### charAt(index) <sub>function</sub>
Return a string consisting of the single UTF-16 code unit at the given index.
If the index is out of range, returns an empty string.
**index**: The zero-based index of the desired character.
**Returns**: The single-character string at the specified index, or '' if out of range.
### concat(stringN) <sub>function</sub>
Concatenate the provided string arguments to the current string and return a
new string.
**stringN**: One or more strings to concatenate.
**Returns**: A new string formed by joining the caller with the provided arguments.
### codePointAt(position) <sub>function</sub>
Return a non-negative integer that is the Unicode code point value at the
given position. Supports code points above 0xFFFF. Returns undefined if index
is out of range.
**position**: The index in the string (can be surrogate pairs).
**Returns**: The code point value, or undefined if out of range.
### isWellFormed() <sub>function</sub>
Return a boolean indicating whether the string is valid Unicode.
If it contains unpaired surrogate code points, return false.
**Returns**: True if the string is well-formed UTF-16, otherwise false.
### toWellFormed() <sub>function</sub>
Return a new string in which any unpaired surrogate code points have been
replaced by the Unicode replacement character U+FFFD.
**Returns**: A well-formed UTF-16 version of the string.
### indexOf(searchValue, fromIndex) <sub>function</sub>
Return the zero-based index of the first occurrence of 'searchValue' in the
string, starting at 'fromIndex'. If not found, return -1.
**searchValue**: The substring to search for.
**fromIndex**: The index at which to begin searching (default 0).
**Returns**: The index of the first match, or -1 if not found.
### lastIndexOf(searchValue, fromIndex) <sub>function</sub>
Return the zero-based index of the last occurrence of 'searchValue' in the
string, searching backwards from 'fromIndex'. If not found, return -1.
**searchValue**: The substring to search for.
**fromIndex**: The index at which to begin the backward search (defaults to string length - 1).
**Returns**: The index of the last match, or -1 if not found.
### includes(searchString, position) <sub>function</sub>
Return a boolean indicating whether 'searchString' appears within this string.
An optional position can be provided to start searching.
**searchString**: The substring to search for.
**position**: The position from which to begin searching (default 0).
**Returns**: True if the substring is found, otherwise false.
### endsWith(searchString, length) <sub>function</sub>
Return a boolean indicating whether the string ends with 'searchString'.
An optional 'length' can be provided to treat the string as if it were only
that long.
**searchString**: The substring to search for at the end.
**length**: An optional length to truncate the string before testing.
**Returns**: True if the string ends with 'searchString', otherwise false.
### startsWith(searchString, position) <sub>function</sub>
Return a boolean indicating whether the string begins with 'searchString'.
An optional position can be provided to start checking at that index.
**searchString**: The substring to search for at the start.
**position**: The index in the string to start searching (default 0).
**Returns**: True if the string starts with 'searchString', otherwise false.
### match(regexp) <sub>function</sub>
Use a regular expression to match the string. If 'regexp' is not a RegExp, it
is converted to one. Return an array of matches or null if none found.
**regexp**: The pattern to match (RegExp or string).
**Returns**: An array of matches or null.
### matchAll(regexp) <sub>function</sub>
Return an iterator of all RegExp match objects found within the string.
If 'regexp' is not a global or sticky RegExp, a TypeError is thrown.
**regexp**: The global/sticky RegExp to match over this string.
**Returns**: An iterator of match arrays.
### search(regexp) <sub>function</sub>
Use a regular expression to search for a match within the string. Return the
index of the first match, or -1 if no match is found.
**regexp**: A RegExp or string. If a string, it is converted to RegExp.
**Returns**: The index of the first match, or -1 if not found.
### split(separator, limit) <sub>function</sub>
Split the string into an array of substrings using 'separator' (RegExp or
string). An optional 'limit' can be provided to limit the number of splits.
**separator**: A string or RegExp used to divide the string.
**limit**: Maximum number of splits to include in the result array.
**Returns**: An array of the split substrings.
### substring(start, end) <sub>function</sub>
Return the substring between 'start' and 'end'. Indices outside the range
are clamped. If 'end' < 'start', they swap.
**start**: The starting index (0-based).
**end**: The ending index (exclusive).
**Returns**: The extracted substring.
### substr(start, length) <sub>function</sub>
Return the substring from 'start' for 'length' characters. Negative 'start'
counts from the end. This method is deprecated but still supported in many
engines.
**start**: The starting index.
**length**: The number of characters to extract.
**Returns**: The extracted substring.
### slice(start, end) <sub>function</sub>
Extract a section of the string from 'start' up to (but not including) 'end',
and return it as a new string. Supports negative indices.
**start**: The starting index. Negative values count from the end.
**end**: The ending index (exclusive). Negative values count from the end.
**Returns**: The extracted slice.
### repeat(count) <sub>function</sub>
Construct and return a new string which contains the specified number of copies
of the calling string, concatenated together.
**count**: The number of times to repeat the string (must be >= 0).
**Returns**: A new repeated string.
### replace(searchValue, replaceValue) <sub>function</sub>
Return a new string where the first match (or all matches if 'searchValue'
is a global RegExp) of 'searchValue' is replaced by 'replaceValue'.
If 'searchValue' is a string, only the first occurrence is replaced.
**searchValue**: A string or RegExp to match.
**replaceValue**: The replacement string or function.
**Returns**: A new string with the matched substring(s) replaced.
### replaceAll(searchValue, replaceValue) <sub>function</sub>
Return a new string where all (non-overlapping) occurrences of 'searchValue'
are replaced by 'replaceValue'. If 'searchValue' is a string, each exact match
is replaced.
**searchValue**: A string or RegExp with the 'g' flag.
**replaceValue**: The replacement string or function.
**Returns**: A new string with all matches replaced.
### padEnd(maxLength, padString) <sub>function</sub>
Pad the string from the end with the given 'padString' so its length reaches
'maxLength'. The result is a new string.
**maxLength**: The desired length of the resulting string.
**padString**: The string to pad with (default ' ').
**Returns**: A new string padded at the end.
### padStart(maxLength, padString) <sub>function</sub>
Pad the string from the start with the given 'padString' so its length reaches
'maxLength'. The result is a new string.
**maxLength**: The desired length of the resulting string.
**padString**: The string to pad with (default ' ').
**Returns**: A new string padded at the start.
### trim() <sub>function</sub>
Return a new string with whitespace trimmed from the start and end of this
string.
**Returns**: The trimmed string.
### trimEnd() <sub>function</sub>
Alias for trimEnd(). Remove trailing whitespace from the string.
**Returns**: The string without trailing whitespace.
### trimRight() <sub>function</sub>
Alias for trimEnd(). Remove trailing whitespace from the string.
**Returns**: The string without trailing whitespace.
### trimStart() <sub>function</sub>
Alias for trimStart(). Remove leading whitespace from the string.
**Returns**: The string without leading whitespace.
### trimLeft() <sub>function</sub>
Alias for trimStart(). Remove leading whitespace from the string.
**Returns**: The string without leading whitespace.
### toString() <sub>function</sub>
Return a string representing the specified object (itself). Usually called
implicitly. Overrides Object.prototype.toString.
**Returns**: The string itself.
### valueOf() <sub>function</sub>
Return the primitive string value of this String object.
**Returns**: The primitive string value.
### __quote() <sub>function</sub>
(Non-standard) Return a quoted representation of the string, typically for
debug or serialization. Implementation details may vary.
**Returns**: A quoted version of the string.
### localeCompare(compareString) <sub>function</sub>
Return a number indicating whether this string is less than, equal to, or
greater than 'compareString' in sort order, according to the current locale.
**compareString**: The string to compare against.
**Returns**: A negative number if less, 0 if the same, or a positive number if greater.
### toLowerCase() <sub>function</sub>
Return a new string with all alphabetic characters converted to lowercase.
**Returns**: The lowercase version of this string.
### toUpperCase() <sub>function</sub>
Return a new string with all alphabetic characters converted to uppercase.
**Returns**: The uppercase version of this string.
### toLocaleLowerCase() <sub>function</sub>
Return a locale-aware lowercase version of this string, using the host's
current locale or the specified locale if supported.
**Returns**: The locale-sensitive lowercase string.
### toLocaleUpperCase() <sub>function</sub>
Return a locale-aware uppercase version of this string, using the host's
current locale or the specified locale if supported.
**Returns**: The locale-sensitive uppercase string.
### anchor(name) <sub>function</sub>
Return a string representing an HTML <a> element with a 'name' attribute
set to the current string.
**name**: The name attribute for the anchor.
**Returns**: An HTML <a name="...">...</a> string.
### big() <sub>function</sub>
Return a string representing an HTML <big> element containing the current
string.
**Returns**: An HTML <big>...</big> string.
### blink() <sub>function</sub>
Return a string representing an HTML <blink> element containing the current
string (historical, not recommended).
**Returns**: An HTML <blink>...</blink> string.
### bold() <sub>function</sub>
Return a string representing an HTML <b> element containing the current
string in bold.
**Returns**: An HTML <b>...</b> string.
### fixed() <sub>function</sub>
Return a string representing an HTML <tt> element containing the current
string in fixed-width font.
**Returns**: An HTML <tt>...</tt> string.
### fontcolor(color) <sub>function</sub>
Return a string representing an HTML <font> element with a 'color' attribute,
containing the current string.
**color**: The color value for the 'font' element.
**Returns**: An HTML <font color="...">...</font> string.
### fontsize(size) <sub>function</sub>
Return a string representing an HTML <font> element with a 'size' attribute,
containing the current string.
**size**: The size value for the 'font' element.
**Returns**: An HTML <font size="...">...</font> string.
### italics() <sub>function</sub>
Return a string representing an HTML <i> element containing the current
string in italics.
**Returns**: An HTML <i>...</i> string.
### link(url) <sub>function</sub>
Return a string representing an HTML <a> element with an 'href' attribute set
to the current string.
**url**: The URL for the 'href' attribute.
**Returns**: An HTML <a href="...">...</a> string.
### small() <sub>function</sub>
Return a string representing an HTML <small> element containing the current
string.
**Returns**: An HTML <small>...</small> string.
### strike() <sub>function</sub>
Return a string representing an HTML <strike> element containing the current
string with strike-through.
**Returns**: An HTML <strike>...</strike> string.
### sub() <sub>function</sub>
Return a string representing an HTML <sub> element containing the current
string as subscript.
**Returns**: An HTML <sub>...</sub> string.
### sup() <sub>function</sub>
Return a string representing an HTML <sup> element containing the current
string as superscript.
**Returns**: An HTML <sup>...</sup> string.
### rm(index, endidx) <sub>function</sub>
Remove characters from this string between 'index' (inclusive)
and 'endidx' (exclusive). If 'endidx' is omitted, it defaults to 'index + 1'.
**index**: The starting index to remove.
**endidx**: The ending index (exclusive).
**Returns**: A new string with the specified characters removed.
### tolast(val) <sub>function</sub>
Return the substring of this string up to the last occurrence of 'val'.
If 'val' is not found, the entire string is returned.
**val**: The substring to locate from the end.
**Returns**: A substring up to the last occurrence of 'val'.
### dir() <sub>function</sub>
Return everything before the last slash ('/') in the string.
If no slash is found, return an empty string.
**Returns**: The directory portion of the path.
### next(char, from) <sub>function</sub>
Search for the next occurrence of 'char' in this string, starting at 'from'.
If 'char' is an array, any of those characters qualifies. Return the matching index,
or -1 if none is found.
**char**: A character (or array of characters) to locate.
**from**: The index to start from.
**Returns**: The index of the next occurrence, or -1 if not found.
### prev(char, from, count) <sub>function</sub>
Search for the previous occurrence of 'char' before index 'from'.
If 'count' is greater than 1, skip multiple occurrences going backward.
Return the found index or 0 if not found.
**char**: The character to locate.
**from**: The index to start from (defaults to the end of the string).
**count**: How many occurrences to skip backward (default 0).
**Returns**: The index of the previous occurrence, or 0 if not found.
### strip_ext() <sub>function</sub>
Return the string up to (but not including) the last '.' character.
If '.' is not found, the entire string is returned.
**Returns**: The string without its last extension.
### ext() <sub>function</sub>
Return the substring after the last '.' in this string.
If '.' is not found, return an empty string.
**Returns**: The file extension or an empty string.
### up_path() <sub>function</sub>
Go up one directory level from the current path, preserving the file name at the end.
**Returns**: A new path string one directory up, with the base filename preserved.
### fromlast(val) <sub>function</sub>
Return the substring that appears after the last occurrence of 'val'.
If 'val' is not found, an empty string is returned.
**val**: The substring to locate.
**Returns**: The substring after the last occurrence of 'val'.
### tofirst(val) <sub>function</sub>
Return the substring from the start of this string up to the first occurrence
of 'val' (excluded). If 'val' is not found, the entire string is returned.
**val**: The substring to locate.
**Returns**: A substring up to the first occurrence of 'val'.
### fromfirst(val) <sub>function</sub>
Return the substring after the first occurrence of 'val'.
If 'val' is not found, the entire string is returned.
**val**: The substring to locate.
**Returns**: The substring after 'val', or the entire string if 'val' not found.
### name() <sub>function</sub>
Return the "name" portion of the path without extension.
If no slash is found, it's up to the last '.' in the entire string.
If there is a slash, it's from the last slash up to (but not including) the last '.'.
**Returns**: The name portion of the path without extension.
### set_name(name) <sub>function</sub>
Set the base name (excluding extension) of the path to 'name', preserving
the original directory and extension.
**name**: The new name to use.
**Returns**: A new path string with the updated name.
### base() <sub>function</sub>
Return the portion of this string after the last '/' character.
If no '/' is present, the entire string is returned.
**Returns**: The base name of the path.
### updir() <sub>function</sub>
Go up one directory from the current path, removing the last directory name.
If the path ends with a slash, remove it first. Then remove the final directory.
**Returns**: A new string representing one directory level up.