1662 lines
61 KiB
Plaintext
1662 lines
61 KiB
Plaintext
Object.mixin = function (target, source) {
|
||
if (typeof source !== "object") return target;
|
||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
||
return target;
|
||
};
|
||
|
||
Object.mixin[cell.DOC] = `Copy all property descriptors from 'source' into 'target'.
|
||
|
||
:param target: The object that will receive properties.
|
||
:param source: The object whose properties are to be copied.
|
||
:return: The updated 'target' object.
|
||
`;
|
||
|
||
Object.defineProperty(Object.prototype, "mixin", {
|
||
value: function mixin(obj) {
|
||
if (typeof obj === "string") obj = use(obj);
|
||
if (obj) Object.mixin(this, obj);
|
||
},
|
||
});
|
||
|
||
(Object.prototype.mixin)[cell.DOC] = `Mix properties from 'obj' into the current object. If 'obj' is a string,
|
||
it first calls 'use(obj)' to retrieve the object.
|
||
|
||
:param obj: The object (or string reference to an object) to mix in.
|
||
:return: None
|
||
`;
|
||
|
||
/* STRING DEFS */
|
||
Object.defineProperty(String.prototype, "rm", {
|
||
value: function (index, endidx = index + 1) {
|
||
return this.slice(0, index) + this.slice(endidx);
|
||
},
|
||
});
|
||
|
||
(String.prototype.rm)[cell.DOC] = `Remove characters from this string between 'index' (inclusive)
|
||
and 'endidx' (exclusive). If 'endidx' is omitted, it defaults to 'index + 1'.
|
||
|
||
:param index: The starting index to remove.
|
||
:param endidx: The ending index (exclusive).
|
||
:return: A new string with the specified characters removed.
|
||
`;
|
||
|
||
Object.defineProperty(String.prototype, "tolast", {
|
||
value: function (val) {
|
||
var idx = this.lastIndexOf(val);
|
||
if (idx === -1) return this.slice();
|
||
return this.slice(0, idx);
|
||
},
|
||
});
|
||
|
||
(String.prototype.tolast)[cell.DOC] = `Return the substring of this string up to the last occurrence of 'val'.
|
||
If 'val' is not found, the entire string is returned.
|
||
|
||
:param val: The substring to locate from the end.
|
||
:return: A substring up to the last occurrence of 'val'.
|
||
`;
|
||
|
||
Object.defineProperty(String.prototype, "dir", {
|
||
value: function () {
|
||
if (!this.includes("/")) return "";
|
||
return this.tolast("/");
|
||
},
|
||
});
|
||
|
||
(String.prototype.dir)[cell.DOC] = `Return everything before the last slash ('/') in the string.
|
||
If no slash is found, return an empty string.
|
||
|
||
:return: The directory portion of the path.
|
||
`;
|
||
|
||
Object.defineProperty(String.prototype, "next", {
|
||
value: function (char, from) {
|
||
if (!Array.isArray(char)) char = [char];
|
||
if (from > this.length - 1) return -1;
|
||
else if (!from) from = 0;
|
||
|
||
var find = this.slice(from).search(char[0]);
|
||
if (find === -1) return -1;
|
||
else return from + find;
|
||
|
||
var i = 0;
|
||
var c = this.charAt(from + i);
|
||
while (!char.includes(c)) {
|
||
i++;
|
||
if (from + i > this.length - 1) return -1;
|
||
c = this.charAt(from + i);
|
||
}
|
||
return from + i;
|
||
},
|
||
});
|
||
|
||
(String.prototype.next)[cell.DOC] = `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.
|
||
|
||
:param char: A character (or array of characters) to locate.
|
||
:param from: The index to start from.
|
||
:return: The index of the next occurrence, or -1 if not found.
|
||
`;
|
||
|
||
Object.defineProperty(String.prototype, "prev", {
|
||
value: function (char, from, count = 0) {
|
||
if (from > this.length - 1) return -1;
|
||
else if (!from) from = this.length - 1;
|
||
|
||
var find = this.slice(0, from).lastIndexOf(char);
|
||
|
||
while (count > 1) {
|
||
find = this.slice(0, find).lastIndexOf(char);
|
||
count--;
|
||
}
|
||
|
||
if (find === -1) return 0;
|
||
else return find;
|
||
},
|
||
});
|
||
|
||
(String.prototype.prev)[cell.DOC] = `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.
|
||
|
||
:param char: The character to locate.
|
||
:param from: The index to start from (defaults to the end of the string).
|
||
:param count: How many occurrences to skip backward (default 0).
|
||
:return: The index of the previous occurrence, or 0 if not found.
|
||
`;
|
||
|
||
Object.defineProperty(String.prototype, "strip_ext", {
|
||
value: function () {
|
||
return this.tolast(".");
|
||
},
|
||
});
|
||
|
||
(String.prototype.strip_ext)[cell.DOC] = `Return the string up to (but not including) the last '.' character.
|
||
If '.' is not found, the entire string is returned.
|
||
|
||
:return: The string without its last extension.
|
||
`;
|
||
|
||
Object.defineProperty(String.prototype, "ext", {
|
||
value: function () {
|
||
return this.fromlast(".");
|
||
},
|
||
});
|
||
|
||
(String.prototype.ext)[cell.DOC] = `Return the substring after the last '.' in this string.
|
||
If '.' is not found, return an empty string.
|
||
|
||
:return: The file extension or an empty string.
|
||
`;
|
||
|
||
Object.defineProperty(String.prototype, "up_path", {
|
||
value: function () {
|
||
var base = this.base();
|
||
var dirs = this.dir().split("/");
|
||
dirs.pop();
|
||
return dirs.join("/") + base;
|
||
},
|
||
});
|
||
|
||
(String.prototype.up_path)[cell.DOC] = `Go up one directory level from the current path, preserving the file name at the end.
|
||
|
||
:return: A new path string one directory up, with the base filename preserved.
|
||
`;
|
||
|
||
Object.defineProperty(String.prototype, "fromlast", {
|
||
value: function (val) {
|
||
var idx = this.lastIndexOf(val);
|
||
if (idx === -1) return "";
|
||
return this.slice(idx + 1);
|
||
},
|
||
});
|
||
|
||
(String.prototype.fromlast)[cell.DOC] = `Return the substring that appears after the last occurrence of 'val'.
|
||
If 'val' is not found, an empty string is returned.
|
||
|
||
:param val: The substring to locate.
|
||
:return: The substring after the last occurrence of 'val'.
|
||
`;
|
||
|
||
Object.defineProperty(String.prototype, "tofirst", {
|
||
value: function (val) {
|
||
var idx = this.indexOf(val);
|
||
if (idx === -1) return this.slice();
|
||
return this.slice(0, idx);
|
||
},
|
||
});
|
||
|
||
(String.prototype.tofirst)[cell.DOC] = `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.
|
||
|
||
:param val: The substring to locate.
|
||
:return: A substring up to the first occurrence of 'val'.
|
||
`;
|
||
|
||
Object.defineProperty(String.prototype, "fromfirst", {
|
||
value: function (val) {
|
||
var idx = this.indexOf(val);
|
||
if (idx === -1) return this;
|
||
return this.slice(idx + val.length);
|
||
},
|
||
});
|
||
|
||
(String.prototype.fromfirst)[cell.DOC] = `Return the substring after the first occurrence of 'val'.
|
||
If 'val' is not found, the entire string is returned.
|
||
|
||
:param val: The substring to locate.
|
||
:return: The substring after 'val', or the entire string if 'val' not found.
|
||
`;
|
||
|
||
Object.defineProperty(String.prototype, "name", {
|
||
value: function () {
|
||
var idx = this.indexOf("/");
|
||
if (idx === -1) return this.tolast(".");
|
||
return this.fromlast("/").tolast(".");
|
||
},
|
||
});
|
||
|
||
(String.prototype.name)[cell.DOC] = `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 '.'.
|
||
|
||
:return: The name portion of the path without extension.
|
||
`;
|
||
|
||
Object.defineProperty(String.prototype, "set_name", {
|
||
value: function (name) {
|
||
var dir = this.dir();
|
||
return this.dir() + "/" + name + "." + this.ext();
|
||
},
|
||
});
|
||
|
||
(String.prototype.set_name)[cell.DOC] = `Set the base name (excluding extension) of the path to 'name', preserving
|
||
the original directory and extension.
|
||
|
||
:param name: The new name to use.
|
||
:return: A new path string with the updated name.
|
||
`;
|
||
|
||
Object.defineProperty(String.prototype, "base", {
|
||
value: function () {
|
||
return this.fromlast("/");
|
||
},
|
||
});
|
||
|
||
(String.prototype.base)[cell.DOC] = `Return the portion of this string after the last '/' character.
|
||
If no '/' is present, the entire string is returned.
|
||
|
||
:return: The base name of the path.
|
||
`;
|
||
|
||
Object.defineProperty(String.prototype, "updir", {
|
||
value: function () {
|
||
if (this.lastIndexOf("/") === this.length - 1) return this.slice(0, this.length - 1);
|
||
var dir = (this + "/").dir();
|
||
return dir.dir();
|
||
},
|
||
});
|
||
|
||
(String.prototype.updir)[cell.DOC] = `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.
|
||
|
||
:return: A new string representing one directory level up.
|
||
`;
|
||
|
||
/* ARRAY DEFS */
|
||
Object.defineProperty(Array.prototype, "filter!", {
|
||
value: function array_dofilter(fn) {
|
||
for (let i = 0; i < this.length; i++) {
|
||
if (!fn.call(this, this[i], i, this)) {
|
||
this.splice(i, 1);
|
||
i--;
|
||
}
|
||
}
|
||
return this;
|
||
},
|
||
});
|
||
|
||
(Array.prototype["filter!"])[cell.DOC] = `Perform an in-place filter of this array using the provided callback 'fn'.
|
||
Any element for which 'fn' returns a falsy value is removed. The array is modified
|
||
and then returned.
|
||
|
||
:param fn: A callback function(element, index, array) => boolean.
|
||
:return: The filtered (modified) array.
|
||
`;
|
||
|
||
Object.defineProperty(Array.prototype, "delete", {
|
||
value: function(item) {
|
||
var idx = this.indexOf(item);
|
||
if (idx > -1) this.splice(idx,1);
|
||
return undefined;
|
||
}
|
||
});
|
||
|
||
(Array.prototype.delete)[cell.DOC] = `Remove the first occurrence of 'item' from the array, if it exists.
|
||
Returns undefined.
|
||
|
||
:param item: The item to remove.
|
||
:return: undefined
|
||
`;
|
||
|
||
Object.defineProperty(Array.prototype, "copy", {
|
||
value: function () {
|
||
var c = [];
|
||
this.forEach(function (x, i) {
|
||
c[i] = deep_copy(x);
|
||
});
|
||
return c;
|
||
},
|
||
});
|
||
|
||
(Array.prototype.copy)[cell.DOC] = `Return a deep copy of this array by applying 'deep_copy' to each element.
|
||
The resulting array is entirely new.
|
||
|
||
:return: A new array that is a deep copy of the original.
|
||
`;
|
||
|
||
Object.defineProperty(Array.prototype, "equal", {
|
||
value: function equal(b) {
|
||
if (this.length !== b.length) return false;
|
||
if (b == null) return false;
|
||
if (this === b) return true;
|
||
return JSON.stringify(this) === JSON.stringify(b);
|
||
|
||
for (var i = 0; i < this.length; i++) {
|
||
if (!this[i] === b[i]) return false;
|
||
}
|
||
return true;
|
||
},
|
||
});
|
||
|
||
(Array.prototype.equal)[cell.DOC] = `Check if this array and array 'b' have the same elements in the same order.
|
||
If they are of different lengths, return false. Otherwise compare them via JSON.
|
||
|
||
:param b: Another array to compare against.
|
||
:return: True if they match, false otherwise.
|
||
`;
|
||
|
||
Object.defineProperty(Array.prototype, "last", {
|
||
value: function () {
|
||
return this[this.length - 1];
|
||
},
|
||
});
|
||
|
||
(Array.prototype.last)[cell.DOC] = `Return the last element of this array. If the array is empty, returns undefined.
|
||
|
||
:return: The last element of the array, or undefined if empty.
|
||
`;
|
||
|
||
Object.defineProperty(Array.prototype, "wrapped", {
|
||
value: function (x) {
|
||
var c = this.slice(0, this.length);
|
||
for (var i = 0; i < x; i++) c.push(this[i]);
|
||
return c;
|
||
},
|
||
});
|
||
|
||
(Array.prototype.wrapped)[cell.DOC] = `Return a copy of the array with the first 'x' elements appended to the end.
|
||
Does not modify the original array.
|
||
|
||
:param x: The number of leading elements to re-append.
|
||
:return: A new array with the leading elements wrapped to the end.
|
||
`;
|
||
|
||
Object.defineProperty(Array.prototype, "wrap_idx", {
|
||
value: function (x) {
|
||
while (x >= this.length) {
|
||
x -= this.length;
|
||
}
|
||
return x;
|
||
},
|
||
});
|
||
|
||
(Array.prototype.wrap_idx)[cell.DOC] = `Wrap the integer 'x' around this array's length, ensuring the resulting index
|
||
lies within [0, this.length - 1].
|
||
|
||
:param x: The index to wrap.
|
||
:return: A wrapped index within this array's bounds.
|
||
`;
|
||
|
||
Object.defineProperty(Array.prototype, "mirrored", {
|
||
value: function (x) {
|
||
var c = this.slice(0);
|
||
if (c.length <= 1) return c;
|
||
for (var i = c.length - 2; i >= 0; i--) c.push(c[i]);
|
||
return c;
|
||
},
|
||
});
|
||
|
||
(Array.prototype.mirrored)[cell.DOC] = `Return a new array that appends a reversed copy (excluding the last element)
|
||
of itself to the end. For example, [1,2,3] -> [1,2,3,2,1]. If the array has length
|
||
<= 1, a copy of it is returned directly.
|
||
|
||
:return: A new "mirrored" array.
|
||
`;
|
||
|
||
|
||
|
||
/// doc for builtin string
|
||
(String.prototype.at)[cell.DOC] = `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.
|
||
|
||
:param index: The position of the character to return (can be negative).
|
||
:return: A string of length 1 representing the character, or undefined if out of range.
|
||
`;
|
||
|
||
(String.prototype.charCodeAt)[cell.DOC] = `Return a number indicating the UTF-16 code unit value at the given index.
|
||
If the index is out of range, returns NaN.
|
||
|
||
:param index: An integer between 0 and string length - 1.
|
||
:return: An integer in the range [0, 65535] or NaN if out of range.
|
||
`;
|
||
|
||
(String.prototype.charAt)[cell.DOC] = `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.
|
||
|
||
:param index: The zero-based index of the desired character.
|
||
:return: The single-character string at the specified index, or '' if out of range.
|
||
`;
|
||
|
||
(String.prototype.concat)[cell.DOC] = `Concatenate the provided string arguments to the current string and return a
|
||
new string.
|
||
|
||
:param stringN: One or more strings to concatenate.
|
||
:return: A new string formed by joining the caller with the provided arguments.
|
||
`;
|
||
|
||
(String.prototype.codePointAt)[cell.DOC] = `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.
|
||
|
||
:param position: The index in the string (can be surrogate pairs).
|
||
:return: The code point value, or undefined if out of range.
|
||
`;
|
||
|
||
(String.prototype.isWellFormed)[cell.DOC] = `Return a boolean indicating whether the string is valid Unicode.
|
||
If it contains unpaired surrogate code points, return false.
|
||
|
||
:return: True if the string is well-formed UTF-16, otherwise false.
|
||
`;
|
||
|
||
(String.prototype.toWellFormed)[cell.DOC] = `Return a new string in which any unpaired surrogate code points have been
|
||
replaced by the Unicode replacement character U+FFFD.
|
||
|
||
:return: A well-formed UTF-16 version of the string.
|
||
`;
|
||
|
||
(String.prototype.indexOf)[cell.DOC] = `Return the zero-based index of the first occurrence of 'searchValue' in the
|
||
string, starting at 'fromIndex'. If not found, return -1.
|
||
|
||
:param searchValue: The substring to search for.
|
||
:param fromIndex: The index at which to begin searching (default 0).
|
||
:return: The index of the first match, or -1 if not found.
|
||
`;
|
||
|
||
(String.prototype.lastIndexOf)[cell.DOC] = `Return the zero-based index of the last occurrence of 'searchValue' in the
|
||
string, searching backwards from 'fromIndex'. If not found, return -1.
|
||
|
||
:param searchValue: The substring to search for.
|
||
:param fromIndex: The index at which to begin the backward search (defaults to string length - 1).
|
||
:return: The index of the last match, or -1 if not found.
|
||
`;
|
||
|
||
(String.prototype.includes)[cell.DOC] = `Return a boolean indicating whether 'searchString' appears within this string.
|
||
An optional position can be provided to start searching.
|
||
|
||
:param searchString: The substring to search for.
|
||
:param position: The position from which to begin searching (default 0).
|
||
:return: True if the substring is found, otherwise false.
|
||
`;
|
||
|
||
(String.prototype.endsWith)[cell.DOC] = `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.
|
||
|
||
:param searchString: The substring to search for at the end.
|
||
:param length: An optional length to truncate the string before testing.
|
||
:return: True if the string ends with 'searchString', otherwise false.
|
||
`;
|
||
|
||
(String.prototype.startsWith)[cell.DOC] = `Return a boolean indicating whether the string begins with 'searchString'.
|
||
An optional position can be provided to start checking at that index.
|
||
|
||
:param searchString: The substring to search for at the start.
|
||
:param position: The index in the string to start searching (default 0).
|
||
:return: True if the string starts with 'searchString', otherwise false.
|
||
`;
|
||
|
||
(String.prototype.match)[cell.DOC] = `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.
|
||
|
||
:param regexp: The pattern to match (RegExp or string).
|
||
:return: An array of matches or null.
|
||
`;
|
||
|
||
(String.prototype.matchAll)[cell.DOC] = `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.
|
||
|
||
:param regexp: The global/sticky RegExp to match over this string.
|
||
:return: An iterator of match arrays.
|
||
`;
|
||
|
||
(String.prototype.search)[cell.DOC] = `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.
|
||
|
||
:param regexp: A RegExp or string. If a string, it is converted to RegExp.
|
||
:return: The index of the first match, or -1 if not found.
|
||
`;
|
||
|
||
(String.prototype.split)[cell.DOC] = `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.
|
||
|
||
:param separator: A string or RegExp used to divide the string.
|
||
:param limit: Maximum number of splits to include in the result array.
|
||
:return: An array of the split substrings.
|
||
`;
|
||
|
||
(String.prototype.substring)[cell.DOC] = `Return the substring between 'start' and 'end'. Indices outside the range
|
||
are clamped. If 'end' < 'start', they swap.
|
||
|
||
:param start: The starting index (0-based).
|
||
:param end: The ending index (exclusive).
|
||
:return: The extracted substring.
|
||
`;
|
||
|
||
(String.prototype.substr)[cell.DOC] = `Return the substring from 'start' for 'length' characters. Negative 'start'
|
||
counts from the end. This method is deprecated but still supported in many
|
||
engines.
|
||
|
||
:param start: The starting index.
|
||
:param length: The number of characters to extract.
|
||
:return: The extracted substring.
|
||
`;
|
||
|
||
(String.prototype.slice)[cell.DOC] = `Extract a section of the string from 'start' up to (but not including) 'end',
|
||
and return it as a new string. Supports negative indices.
|
||
|
||
:param start: The starting index. Negative values count from the end.
|
||
:param end: The ending index (exclusive). Negative values count from the end.
|
||
:return: The extracted slice.
|
||
`;
|
||
|
||
(String.prototype.repeat)[cell.DOC] = `Construct and return a new string which contains the specified number of copies
|
||
of the calling string, concatenated together.
|
||
|
||
:param count: The number of times to repeat the string (must be >= 0).
|
||
:return: A new repeated string.
|
||
`;
|
||
|
||
(String.prototype.replace)[cell.DOC] = `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.
|
||
|
||
:param searchValue: A string or RegExp to match.
|
||
:param replaceValue: The replacement string or function.
|
||
:return: A new string with the matched substring(s) replaced.
|
||
`;
|
||
|
||
(String.prototype.replaceAll)[cell.DOC] = `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.
|
||
|
||
:param searchValue: A string or RegExp with the 'g' flag.
|
||
:param replaceValue: The replacement string or function.
|
||
:return: A new string with all matches replaced.
|
||
`;
|
||
|
||
(String.prototype.padEnd)[cell.DOC] = `Pad the string from the end with the given 'padString' so its length reaches
|
||
'maxLength'. The result is a new string.
|
||
|
||
:param maxLength: The desired length of the resulting string.
|
||
:param padString: The string to pad with (default ' ').
|
||
:return: A new string padded at the end.
|
||
`;
|
||
|
||
(String.prototype.padStart)[cell.DOC] = `Pad the string from the start with the given 'padString' so its length reaches
|
||
'maxLength'. The result is a new string.
|
||
|
||
:param maxLength: The desired length of the resulting string.
|
||
:param padString: The string to pad with (default ' ').
|
||
:return: A new string padded at the start.
|
||
`;
|
||
|
||
(String.prototype.trim)[cell.DOC] = `Return a new string with whitespace trimmed from the start and end of this
|
||
string.
|
||
|
||
:return: The trimmed string.
|
||
`;
|
||
|
||
(String.prototype.trimEnd)[cell.DOC] = `Return a new string with trailing whitespace removed. Alias: trimRight().
|
||
|
||
:return: The string without trailing whitespace.
|
||
`;
|
||
|
||
(String.prototype.trimRight)[cell.DOC] = `Alias for trimEnd(). Remove trailing whitespace from the string.
|
||
|
||
:return: The string without trailing whitespace.
|
||
`;
|
||
|
||
(String.prototype.trimStart)[cell.DOC] = `Return a new string with leading whitespace removed. Alias: trimLeft().
|
||
|
||
:return: The string without leading whitespace.
|
||
`;
|
||
|
||
(String.prototype.trimLeft)[cell.DOC] = `Alias for trimStart(). Remove leading whitespace from the string.
|
||
|
||
:return: The string without leading whitespace.
|
||
`;
|
||
|
||
(String.prototype.toString)[cell.DOC] = `Return a string representing the specified object (itself). Usually called
|
||
implicitly. Overrides Object.prototype.toString.
|
||
|
||
:return: The string itself.
|
||
`;
|
||
|
||
(String.prototype.valueOf)[cell.DOC] = `Return the primitive string value of this String object.
|
||
|
||
:return: The primitive string value.
|
||
`;
|
||
|
||
(String.prototype.__quote)[cell.DOC] = `(Non-standard) Return a quoted representation of the string, typically for
|
||
debug or serialization. Implementation details may vary.
|
||
|
||
:return: A quoted version of the string.
|
||
`;
|
||
|
||
(String.prototype.toLowerCase)[cell.DOC] = `Return a new string with all alphabetic characters converted to lowercase.
|
||
|
||
:return: The lowercase version of this string.
|
||
`;
|
||
|
||
(String.prototype.toUpperCase)[cell.DOC] = `Return a new string with all alphabetic characters converted to uppercase.
|
||
|
||
:return: The uppercase version of this string.
|
||
`;
|
||
|
||
(String.prototype.toLocaleLowerCase)[cell.DOC] = `Return a locale-aware lowercase version of this string, using the host's
|
||
current locale or the specified locale if supported.
|
||
|
||
:return: The locale-sensitive lowercase string.
|
||
`;
|
||
|
||
(String.prototype.toLocaleUpperCase)[cell.DOC] = `Return a locale-aware uppercase version of this string, using the host's
|
||
current locale or the specified locale if supported.
|
||
|
||
:return: The locale-sensitive uppercase string.
|
||
`;
|
||
|
||
(String.prototype.anchor)[cell.DOC] = `Return a string representing an HTML <a> element with a 'name' attribute
|
||
set to the current string.
|
||
|
||
:param name: The name attribute for the anchor.
|
||
:return: An HTML <a name="...">...</a> string.
|
||
`;
|
||
|
||
(String.prototype.big)[cell.DOC] = `Return a string representing an HTML <big> element containing the current
|
||
string.
|
||
|
||
:return: An HTML <big>...</big> string.
|
||
`;
|
||
|
||
(String.prototype.blink)[cell.DOC] = `Return a string representing an HTML <blink> element containing the current
|
||
string (historical, not recommended).
|
||
|
||
:return: An HTML <blink>...</blink> string.
|
||
`;
|
||
|
||
(String.prototype.bold)[cell.DOC] = `Return a string representing an HTML <b> element containing the current
|
||
string in bold.
|
||
|
||
:return: An HTML <b>...</b> string.
|
||
`;
|
||
|
||
(String.prototype.fixed)[cell.DOC] = `Return a string representing an HTML <tt> element containing the current
|
||
string in fixed-width font.
|
||
|
||
:return: An HTML <tt>...</tt> string.
|
||
`;
|
||
|
||
(String.prototype.fontcolor)[cell.DOC] = `Return a string representing an HTML <font> element with a 'color' attribute,
|
||
containing the current string.
|
||
|
||
:param color: The color value for the 'font' element.
|
||
:return: An HTML <font color="...">...</font> string.
|
||
`;
|
||
|
||
(String.prototype.fontsize)[cell.DOC] = `Return a string representing an HTML <font> element with a 'size' attribute,
|
||
containing the current string.
|
||
|
||
:param size: The size value for the 'font' element.
|
||
:return: An HTML <font size="...">...</font> string.
|
||
`;
|
||
|
||
(String.prototype.italics)[cell.DOC] = `Return a string representing an HTML <i> element containing the current
|
||
string in italics.
|
||
|
||
:return: An HTML <i>...</i> string.
|
||
`;
|
||
|
||
(String.prototype.link)[cell.DOC] = `Return a string representing an HTML <a> element with an 'href' attribute set
|
||
to the current string.
|
||
|
||
:param url: The URL for the 'href' attribute.
|
||
:return: An HTML <a href="...">...</a> string.
|
||
`;
|
||
|
||
(String.prototype.small)[cell.DOC] = `Return a string representing an HTML <small> element containing the current
|
||
string.
|
||
|
||
:return: An HTML <small>...</small> string.
|
||
`;
|
||
|
||
(String.prototype.strike)[cell.DOC] = `Return a string representing an HTML <strike> element containing the current
|
||
string with strike-through.
|
||
|
||
:return: An HTML <strike>...</strike> string.
|
||
`;
|
||
|
||
(String.prototype.sub)[cell.DOC] = `Return a string representing an HTML <sub> element containing the current
|
||
string as subscript.
|
||
|
||
:return: An HTML <sub>...</sub> string.
|
||
`;
|
||
|
||
(String.prototype.sup)[cell.DOC] = `Return a string representing an HTML <sup> element containing the current
|
||
string as superscript.
|
||
|
||
:return: An HTML <sup>...</sup> string.
|
||
`;
|
||
|
||
|
||
// builtin array
|
||
(Array.prototype.at)[cell.DOC] = `Return the item at index 'index', supporting negative indices to count from
|
||
the end. If 'index' is out of range, returns undefined.
|
||
|
||
:param index: The index of the element to return (can be negative).
|
||
:return: The element at the given index, or undefined.
|
||
`;
|
||
|
||
(Array.prototype.with)[cell.DOC] = `Return a shallow copy of the array, but with the element at 'index' replaced
|
||
by 'value'. If 'index' is negative, it counts from the end. Throws if out of range.
|
||
|
||
:param index: The zero-based index (can be negative) to replace.
|
||
:param value: The new value for the specified position.
|
||
:return: A new array with the updated element.
|
||
`;
|
||
|
||
(Array.prototype.concat)[cell.DOC] = `Return a new array that is the result of concatenating this array with
|
||
any additional arrays or values provided.
|
||
|
||
:param items: One or more arrays or values to concatenate.
|
||
:return: A new array with the items appended.
|
||
`;
|
||
|
||
(Array.prototype.every)[cell.DOC] = `Return true if the provided callback function returns a truthy value for
|
||
every element in the array; otherwise false.
|
||
|
||
:param callback: A function(element, index, array) => boolean.
|
||
:param thisArg: Optional. A value to use as 'this' within the callback.
|
||
:return: True if all elements pass the test, otherwise false.
|
||
`;
|
||
|
||
(Array.prototype.some)[cell.DOC] = `Return true if the provided callback function returns a truthy value for at
|
||
least one element in the array; otherwise false.
|
||
|
||
:param callback: A function(element, index, array) => boolean.
|
||
:param thisArg: Optional. A value to use as 'this' within the callback.
|
||
:return: True if at least one element passes the test, otherwise false.
|
||
`;
|
||
|
||
(Array.prototype.forEach)[cell.DOC] = `Call the provided callback function once for each element in the array.
|
||
Does not produce a return value.
|
||
|
||
:param callback: A function(element, index, array).
|
||
:param thisArg: Optional. A value to use as 'this' within the callback.
|
||
:return: None
|
||
`;
|
||
|
||
(Array.prototype.map)[cell.DOC] = `Create a new array with the results of calling a provided callback function
|
||
on every element in this array.
|
||
|
||
:param callback: A function(element, index, array) => newElement.
|
||
:param thisArg: Optional. A value to use as 'this' within the callback.
|
||
:return: A new array of transformed elements.
|
||
`;
|
||
|
||
(Array.prototype.filter)[cell.DOC] = `Create a new array containing all elements for which the provided callback
|
||
function returns a truthy value.
|
||
|
||
:param callback: A function(element, index, array) => boolean.
|
||
:param thisArg: Optional. A value to use as 'this' within the callback.
|
||
:return: A new array of elements that passed the test.
|
||
`;
|
||
|
||
(Array.prototype.reduce)[cell.DOC] = `Apply a callback function against an accumulator and each element in the
|
||
array (from left to right) to reduce it to a single value.
|
||
|
||
:param callback: A function(accumulator, element, index, array) => newAccumulator.
|
||
:param initialValue: Optional. The initial value for the accumulator.
|
||
:return: The single resulting value.
|
||
`;
|
||
|
||
(Array.prototype.reduceRight)[cell.DOC] = `Similar to reduce(), except it processes elements from right to left.
|
||
|
||
:param callback: A function(accumulator, element, index, array) => newAccumulator.
|
||
:param initialValue: Optional. The initial value for the accumulator.
|
||
:return: The single resulting value.
|
||
`;
|
||
|
||
(Array.prototype.fill)[cell.DOC] = `Fill the array with a static value from 'start' index up to (but not including)
|
||
'end' index. Modifies the original array.
|
||
|
||
:param value: The value to fill.
|
||
:param start: The starting index (default 0).
|
||
:param end: The ending index (default array.length).
|
||
:return: The modified array (with filled values).
|
||
`;
|
||
|
||
(Array.prototype.find)[cell.DOC] = `Return the first element in the array that satisfies the provided callback
|
||
function. If none is found, return undefined.
|
||
|
||
:param callback: A function(element, index, array) => boolean.
|
||
:param thisArg: Optional. A value to use as 'this' within the callback.
|
||
:return: The first matching element, or undefined if not found.
|
||
`;
|
||
|
||
(Array.prototype.findIndex)[cell.DOC] = `Return the index of the first element in the array that satisfies the
|
||
provided callback function. If none is found, return -1.
|
||
|
||
:param callback: A function(element, index, array) => boolean.
|
||
:param thisArg: Optional. A value to use as 'this' within the callback.
|
||
:return: The index of the first matching element, or -1 if not found.
|
||
`;
|
||
|
||
(Array.prototype.findLast)[cell.DOC] = `Return the last element in the array that satisfies the provided callback
|
||
function, searching from right to left. If none is found, return undefined.
|
||
|
||
:param callback: A function(element, index, array) => boolean.
|
||
:param thisArg: Optional. A value to use as 'this' within the callback.
|
||
:return: The last matching element, or undefined if not found.
|
||
`;
|
||
|
||
(Array.prototype.findLastIndex)[cell.DOC] = `Return the index of the last element in the array that satisfies the
|
||
provided callback function, searching from right to left. If none is found,
|
||
return -1.
|
||
|
||
:param callback: A function(element, index, array) => boolean.
|
||
:param thisArg: Optional. A value to use as 'this' within the callback.
|
||
:return: The index of the last matching element, or -1 if not found.
|
||
`;
|
||
|
||
(Array.prototype.indexOf)[cell.DOC] = `Return the first index at which a given element can be found. If not present,
|
||
return -1.
|
||
|
||
:param searchElement: The item to locate in the array.
|
||
:param fromIndex: The index at which to start searching (default 0).
|
||
:return: The index of the found element, or -1 if not found.
|
||
`;
|
||
|
||
(Array.prototype.lastIndexOf)[cell.DOC] = `Return the last index at which a given element can be found, or -1 if not
|
||
present. Searches backward from 'fromIndex'.
|
||
|
||
:param searchElement: The item to locate in the array.
|
||
:param fromIndex: The index at which to start searching backward (default array.length - 1).
|
||
:return: The last index of the found element, or -1 if not found.
|
||
`;
|
||
|
||
(Array.prototype.includes)[cell.DOC] = `Return a boolean indicating whether the array contains the given element,
|
||
comparing elements using the SameValueZero algorithm.
|
||
|
||
:param searchElement: The value to search for.
|
||
:param fromIndex: The position in the array to start searching (default 0).
|
||
:return: True if the element is found, otherwise false.
|
||
`;
|
||
|
||
(Array.prototype.join)[cell.DOC] = `Join all elements of the array into a string, separated by 'separator'.
|
||
|
||
:param separator: The delimiter string to separate elements (default ',').
|
||
:return: A string of array elements joined by the separator.
|
||
`;
|
||
|
||
(Array.prototype.toString)[cell.DOC] = `Return a string representing the elements of the array, separated by commas.
|
||
Overrides Object.prototype.toString.
|
||
|
||
:return: A comma-separated string of array elements.
|
||
`;
|
||
|
||
(Array.prototype.toLocaleString)[cell.DOC] = `Return a localized string representing the array and its elements, calling
|
||
each element's toLocaleString if available.
|
||
|
||
:return: A locale-sensitive, comma-separated string of array elements.
|
||
`;
|
||
|
||
(Array.prototype.pop)[cell.DOC] = `Remove the last element from the array and return it. This changes the length
|
||
of the array.
|
||
|
||
:return: The removed element, or undefined if the array is empty.
|
||
`;
|
||
|
||
(Array.prototype.push)[cell.DOC] = `Append one or more elements to the end of the array and return the new length
|
||
of the array.
|
||
|
||
:param items: One or more items to append.
|
||
:return: The new length of the array.
|
||
`;
|
||
|
||
(Array.prototype.shift)[cell.DOC] = `Remove the first element from the array and return it. This changes the length
|
||
of the array.
|
||
|
||
:return: The removed element, or undefined if the array is empty.
|
||
`;
|
||
|
||
(Array.prototype.unshift)[cell.DOC] = `Insert one or more elements at the start of the array and return the new
|
||
length of the array.
|
||
|
||
:param items: One or more elements to insert at the start.
|
||
:return: The new length of the array.
|
||
`;
|
||
|
||
(Array.prototype.reverse)[cell.DOC] = `Reverse the elements of the array in place and return the modified array.
|
||
|
||
:return: The reversed array.
|
||
`;
|
||
|
||
(Array.prototype.toReversed)[cell.DOC] = `Return a shallow copy of the array in reverse order, without modifying the original array.
|
||
|
||
:return: A new reversed array.
|
||
`;
|
||
|
||
(Array.prototype.sort)[cell.DOC] = `Sort the array in place, returning it. By default, sorts elements as strings in ascending order. An optional compareFunction may be used for custom sorting.
|
||
|
||
:param compareFunction: A function(a, b) => number, defining sort order.
|
||
:return: The sorted array.
|
||
`;
|
||
|
||
(Array.prototype.toSorted)[cell.DOC] = `Return a shallow copy of the array, sorted according to the optional compare
|
||
function, without modifying the original array.
|
||
|
||
:param compareFunction: A function(a, b) => number, defining sort order.
|
||
:return: A new sorted array.
|
||
`;
|
||
|
||
(Array.prototype.slice)[cell.DOC] = `Return a shallow copy of a portion of the array into a new array object, selected from 'start' to 'end' (end not included).
|
||
|
||
:param start: The beginning index (0-based). Negative values count from the end.
|
||
:param end: The end index (exclusive). Negative values count from the end.
|
||
:return: A new array containing the extracted elements.
|
||
`;
|
||
|
||
(Array.prototype.splice)[cell.DOC] = `Change the contents of the array by removing or replacing existing elements and/or adding new elements in place. Returns an array of removed elements.
|
||
|
||
:param start: The index at which to start changing the array.
|
||
:param deleteCount: Number of elements to remove.
|
||
:param items: Elements to add in place of the removed elements.
|
||
:return: An array containing the removed elements (if any).
|
||
`;
|
||
|
||
(Array.prototype.toSpliced)[cell.DOC] = `Return a shallow copy of the array, with a splice-like operation applied at 'start' removing 'deleteCount' elements and adding 'items'. Does not mutate the original array.
|
||
|
||
:param start: The index at which to start the splice operation.
|
||
:param deleteCount: Number of elements to remove.
|
||
:param items: Elements to add in place of the removed elements.
|
||
:return: A new array with the splice applied.
|
||
`;
|
||
|
||
(Array.prototype.copyWithin)[cell.DOC] = `Copy a sequence of array elements within the array, overwriting existing values. This operation is performed in place and returns the modified array.
|
||
|
||
:param target: The index at which to copy the sequence to.
|
||
:param start: The beginning index of the sequence to copy.
|
||
:param end: The end index (exclusive) of the sequence to copy (default array.length).
|
||
:return: The modified array.
|
||
`;
|
||
|
||
(Array.prototype.flatMap)[cell.DOC] = `Return a new array formed by applying a callback function to each element and then flattening the result by one level.
|
||
|
||
:param callback: A function(element, index, array) => array or value.
|
||
:param thisArg: Optional. A value to use as 'this' within the callback.
|
||
:return: A new array with the flattened results.
|
||
`;
|
||
|
||
(Array.prototype.flat)[cell.DOC] = `Return a new array with all sub-array elements concatenated into it recursively up to the specified depth.
|
||
|
||
:param depth: The maximum depth to flatten (default 1).
|
||
:return: A new flattened array.
|
||
`;
|
||
|
||
(Array.prototype.values)[cell.DOC] = `Return a new Array Iterator object that contains the values for each index in the array.
|
||
|
||
:return: An iterator over the array's elements.
|
||
`;
|
||
|
||
(Array.prototype.keys)[cell.DOC] = `Return a new Array Iterator object that contains the keys (indexes) for each index in the array.
|
||
|
||
:return: An iterator over the array's indices.
|
||
`;
|
||
|
||
(Array.prototype.entries)[cell.DOC] = `Return a new Array Iterator object that contains key/value pairs for each index in the array. Each entry is [index, value].
|
||
|
||
:return: An iterator over [index, value] pairs.
|
||
`;
|
||
|
||
(Array.prototype.add)[cell.DOC] = `Non-standard. Add corresponding elements of the current array and 'other' element-wise, returning a new array. Behavior depends on data types.
|
||
|
||
:param other: Another array or scalar to add to each element.
|
||
:return: A new array with element-wise sum results.
|
||
`;
|
||
|
||
(Array.prototype.sub)[cell.DOC] = `Non-standard. Subtract corresponding elements of 'other' from the current array element-wise, returning a new array. Behavior depends on data types.
|
||
|
||
:param other: Another array or scalar to subtract from each element.
|
||
:return: A new array with element-wise difference results.
|
||
`;
|
||
|
||
(Array.prototype.div)[cell.DOC] = `Non-standard. Divide each element of the current array by the corresponding element of 'other' (or a scalar) element-wise, returning a new array. Behavior depends on data types.
|
||
|
||
:param other: Another array or scalar for the division.
|
||
:return: A new array with element-wise division results.
|
||
`;
|
||
|
||
// Object
|
||
(Object.prototype.toString)[cell.DOC] = `Return a string representing this object. By default, it returns a string of the form '[object <className>]', where <className> is the object's class.
|
||
|
||
:return: A string that describes the object.
|
||
`;
|
||
|
||
(Object.prototype.toLocaleString)[cell.DOC] = `Return a localized string representation of this object, calling toString() by default or a locale-specific override if defined.
|
||
|
||
:return: A locale-sensitive string representation of the object.
|
||
`;
|
||
|
||
(Object.prototype.valueOf)[cell.DOC] = `Return the primitive value of this object if one exists. Typically, an object returns itself, while a wrapped type (e.g. Number, String) may return the underlying primitive value.
|
||
|
||
:return: The primitive value of the object, or the object itself.
|
||
`;
|
||
|
||
(Object.prototype.hasOwnProperty)[cell.DOC] = `Return a boolean indicating whether the object has a property with the specified name (key) as its own direct property, as opposed to inheriting it. It does not check the prototype chain.
|
||
|
||
:param prop: The name or Symbol of the property to test.
|
||
:return: True if the property is found directly on the object, otherwise false.
|
||
`;
|
||
|
||
(Object.prototype.isPrototypeOf)[cell.DOC] = `Return true if the object appears anywhere in the prototype chain of the specified object, otherwise false.
|
||
|
||
:param obj: The object whose prototype chain will be checked.
|
||
:return: True if this object is in 'obj's prototype chain, otherwise false.
|
||
`;
|
||
|
||
(Object.prototype.propertyIsEnumerable)[cell.DOC] = `Return a boolean indicating whether the specified property is enumerable, i.e., whether it shows up in a for...in loop or Object.keys() on the object.
|
||
|
||
:param prop: The name or Symbol of the property to test.
|
||
:return: True if the property is found and enumerable, otherwise false.
|
||
`;
|
||
|
||
(Object.create)[cell.DOC] = `Create a new object, using the specified prototype object and optional property descriptors.
|
||
|
||
:param proto: The object to be used as the prototype.
|
||
:param propertiesObject: Optional. An object specifying properties to be added.
|
||
:return: A new object with the given prototype and properties.
|
||
`;
|
||
|
||
(Object.getPrototypeOf)[cell.DOC] = `Return the prototype of the specified object. If no prototype is found (e.g. the object has null as its prototype), return null.
|
||
|
||
:param obj: The object whose prototype is to be returned.
|
||
:return: The prototype of 'obj', or null.
|
||
`;
|
||
|
||
(Object.setPrototypeOf)[cell.DOC] = `Set the prototype of the specified object to the provided value. Throws a TypeError if the object is non-extensible and the prototype is changed.
|
||
|
||
:param obj: The object whose prototype is set.
|
||
:param proto: The new prototype or null.
|
||
:return: The object 'obj' after setting its prototype.
|
||
`;
|
||
|
||
(Object.defineProperty)[cell.DOC] = `Define or modify a property on an object using a property descriptor, returning the object. Throws a TypeError if the descriptor is invalid.
|
||
|
||
:param obj: The object on which to define or modify a property.
|
||
:param prop: The name or Symbol of the property.
|
||
:param descriptor: A property descriptor object (e.g., {value, writable, get, set, ...}).
|
||
:return: The object with the newly defined or updated property.
|
||
`;
|
||
|
||
(Object.defineProperties)[cell.DOC] = `Define new or modify existing properties on an object, given an object of property descriptors. Returns the modified object.
|
||
|
||
:param obj: The object on which to define or modify properties.
|
||
:param props: An object mapping property names to property descriptors.
|
||
:return: The modified object.
|
||
`;
|
||
|
||
(Object.getOwnPropertyNames)[cell.DOC] = `Return an array of all own (non-Symbol) property names found directly on the given object, in the same order as a for...in loop would return.
|
||
|
||
:param obj: The object whose own property names are returned.
|
||
:return: An array of strings that correspond to the properties.
|
||
`;
|
||
|
||
(Object.getOwnPropertySymbols)[cell.DOC] = `Return an array of all own Symbol properties found directly on the given object.
|
||
|
||
:param obj: The object to retrieve Symbol keys from.
|
||
:return: An array of Symbol keys.
|
||
`;
|
||
|
||
(Object.groupBy)[cell.DOC] = `Non-standard / Proposed. Group the own properties of an object according to the return value of a grouping function. Typically returns a new object whose keys are the group identifiers.
|
||
|
||
:param obj: The object to group.
|
||
:param fn: A function(key, value) => groupingKey, applied to each property.
|
||
:return: An object where properties are grouped by the returned keys.
|
||
`;
|
||
|
||
(Object.keys)[cell.DOC] = `Return an array of the object's own enumerable (non-Symbol) property names, in the same order that a normal loop would.
|
||
|
||
:param obj: The object whose property names are to be returned.
|
||
:return: An array of property names.
|
||
`;
|
||
|
||
(Object.values)[cell.DOC] = `Return an array of the object's own enumerable (non-Symbol) property values, in the same order as Object.keys().
|
||
|
||
:param obj: The object whose property values are to be returned.
|
||
:return: An array of property values.
|
||
`;
|
||
|
||
(Object.entries)[cell.DOC] = `Return an array of [key, value] pairs for the object's own enumerable (non-Symbol) properties, in the same order as Object.keys().
|
||
|
||
:param obj: The object whose [key, value] pairs are to be returned.
|
||
:return: An array of [key, value] pairs.
|
||
`;
|
||
|
||
(Object.isExtensible)[cell.DOC] = `Return a boolean indicating whether new properties can be added to the specified object.
|
||
|
||
:param obj: The object to test.
|
||
:return: True if the object is extensible, otherwise false.
|
||
`;
|
||
|
||
(Object.preventExtensions)[cell.DOC] = `Prevent new properties from ever being added to an object. Existing properties are not affected.
|
||
|
||
:param obj: The object to mark as non-extensible.
|
||
:return: The non-extensible object.
|
||
`;
|
||
|
||
(Object.getOwnPropertyDescriptor)[cell.DOC] = `Return the property descriptor for a named property on the specified object, if it exists, otherwise undefined.
|
||
|
||
:param obj: The object in which to look for the property.
|
||
:param prop: The name or Symbol of the property.
|
||
:return: The property descriptor, or undefined if not found.
|
||
`;
|
||
|
||
(Object.getOwnPropertyDescriptors)[cell.DOC] = `Return an object containing all own property descriptors for the given object, keyed by property names (and Symbols).
|
||
|
||
:param obj: The object to retrieve property descriptors from.
|
||
:return: An object mapping property keys to property descriptors.
|
||
`;
|
||
|
||
(Object.is)[cell.DOC] = `Compare two values for strict equality, like '===' but without special treatment for +0 and -0, and treating NaN as equal to NaN.
|
||
|
||
:param value1: A value to compare.
|
||
:param value2: Another value to compare.
|
||
:return: True if both values are the same, otherwise false.
|
||
`;
|
||
|
||
(Object.assign)[cell.DOC] = `Copy all enumerable own properties from one or more source objects to a target object, returning the modified target.
|
||
|
||
:param target: The object to receive properties.
|
||
:param sources: One or more objects containing properties to copy.
|
||
:return: The updated target object.
|
||
`;
|
||
|
||
(Object.seal)[cell.DOC] = `Seal an object, preventing new properties from being added and marking all existing properties as non-configurable. Values of present properties can still be changed if they are writable.
|
||
|
||
:param obj: The object to seal.
|
||
:return: The sealed object.
|
||
`;
|
||
|
||
(Object.freeze)[cell.DOC] = `Freeze an object, preventing new properties from being added, existing properties from being removed, or current properties from being changed (to the extent permitted by property descriptors).
|
||
|
||
:param obj: The object to freeze.
|
||
:return: The frozen object.
|
||
`;
|
||
|
||
(Object.isSealed)[cell.DOC] = `Check if an object is sealed. A sealed object has no configurable properties and is non-extensible.
|
||
|
||
:param obj: The object to test.
|
||
:return: True if the object is sealed, otherwise false.
|
||
`;
|
||
|
||
(Object.isFrozen)[cell.DOC] = `Check if an object is frozen. A frozen object is sealed and all data properties are non-writable.
|
||
|
||
:param obj: The object to test.
|
||
:return: True if the object is frozen, otherwise false.
|
||
`;
|
||
|
||
(Object.fromEntries)[cell.DOC] = `Transform a list of key-value pairs into an object. The iterable argument should yield pairs [key, value], which become properties on the resulting object.
|
||
|
||
:param entries: An iterable of [key, value] pairs.
|
||
:return: A new object formed from the given entries.
|
||
`;
|
||
|
||
(Object.hasOwn)[cell.DOC] = `Return a boolean indicating whether the specified property exists on the object as a direct own property (similar to hasOwnProperty, but directly on Object).
|
||
|
||
:param obj: The object on which to check the property.
|
||
:param prop: The name or Symbol of the property to check.
|
||
:return: True if the property is found on 'obj', otherwise false.
|
||
`;
|
||
|
||
(Object.id)[cell.DOC] = `Non-standard. Return a unique identifier for the given object, assigning one if necessary. The same object will always yield the same ID.
|
||
|
||
:param obj: The object to retrieve or assign a unique ID.
|
||
:return: A unique identifier (string or number) associated with the object.
|
||
`;
|
||
|
||
(String.fromCharCode)[cell.DOC] = `Return a string created from the specified sequence of UTF-16 code units.
|
||
Each argument is treated as a code unit in the range [0, 65535].
|
||
|
||
:param codeUnits: A series of numbers representing UTF-16 code units.
|
||
:return: A string constructed by mapping each code unit to a character.
|
||
`;
|
||
|
||
(String.fromCodePoint)[cell.DOC] = `Return a string created from the specified sequence of code points,
|
||
including those above U+FFFF (which will become surrogate pairs).
|
||
Throws a RangeError for invalid code points.
|
||
|
||
:param codePoints: A series of numbers representing Unicode code points.
|
||
:return: A string constructed from the given code points.
|
||
`;
|
||
|
||
(String.raw)[cell.DOC] = `A tag function of template literals that returns a raw where escape sequences (e.g., '\\n', '\\u00A9') are not processed.
|
||
Commonly used to retrieve the unprocessed text of a template.
|
||
|
||
:param template: A template literal, or an object with a 'raw' property.
|
||
:param substitutions: Additional values to substitute (if any).
|
||
:return: The combined raw string from the template.
|
||
`;
|
||
|
||
(Math.min)[cell.DOC] = `Return the smallest of the zero or more given numbers. If no arguments are provided, the result is Infinity. If any value is NaN, the result is NaN.
|
||
|
||
:param values: One or more numeric values.
|
||
:return: The smallest numeric value, Infinity if no arguments, or NaN if any argument cannot be converted to a number.
|
||
`;
|
||
|
||
(Math.max)[cell.DOC] = `Return the largest of the zero or more given numbers. If no arguments are provided, the result is -Infinity. If any value is NaN, the result is NaN.
|
||
|
||
:param values: One or more numeric values.
|
||
:return: The largest numeric value, -Infinity if no arguments, or NaN if any argument cannot be converted to a number.
|
||
`;
|
||
|
||
(Math.abs)[cell.DOC] = `Return the absolute value of the given number. For example, -5 becomes 5.
|
||
|
||
:param x: A numeric value.
|
||
:return: The absolute value of x.
|
||
`;
|
||
|
||
(Math.floor)[cell.DOC] = `Return the greatest integer less than or equal to x, effectively rounding down to the nearest integer.
|
||
|
||
:param x: A numeric value.
|
||
:return: The largest integer <= x.
|
||
`;
|
||
|
||
(Math.ceil)[cell.DOC] = `Return the smallest integer greater than or equal to x, effectively rounding up to the nearest integer.
|
||
|
||
:param x: A numeric value.
|
||
:return: The smallest integer >= x.
|
||
`;
|
||
|
||
(Math.round)[cell.DOC] = `Return x rounded to the nearest integer. If the fractional portion is 0.5 or
|
||
greater, rounds up; otherwise, rounds down. Ties away from zero in modern ECMAScript.
|
||
|
||
:param x: A numeric value.
|
||
:return: x rounded to the nearest integer.
|
||
`;
|
||
|
||
(Math.sqrt)[cell.DOC] = `Return the positive square root of x. If x is negative, the result is NaN.
|
||
|
||
:param x: A non-negative numeric value.
|
||
:return: The positive square root of x, or NaN if x is negative.
|
||
`;
|
||
|
||
(Math.acos)[cell.DOC] = `Return the arccosine (in radians) of x, in the range [0, π]. If x is outside
|
||
the range [-1, 1], the result is NaN.
|
||
|
||
:param x: A numeric value in [-1, 1].
|
||
:return: The arccosine of x in radians, or NaN if out of range.
|
||
`;
|
||
|
||
(Math.asin)[cell.DOC] = `Return the arcsine (in radians) of x, in the range [-π/2, π/2]. If x is
|
||
outside [-1, 1], the result is NaN.
|
||
|
||
:param x: A numeric value in [-1, 1].
|
||
:return: The arcsine of x in radians, or NaN if out of range.
|
||
`;
|
||
|
||
(Math.atan)[cell.DOC] = `Return the arctangent (in radians) of x, in the range [-π/2, π/2].
|
||
|
||
:param x: A numeric value.
|
||
:return: The arctangent of x in radians.
|
||
`;
|
||
|
||
(Math.atan2)[cell.DOC] = `Return the arctangent of the quotient of its arguments (y / x), in the range
|
||
(-π, π]. This takes into account the signs of both x and y to determine
|
||
the correct quadrant.
|
||
|
||
:param y: The y coordinate.
|
||
:param x: The x coordinate.
|
||
:return: The angle in radians between the positive x-axis and the point (x, y).
|
||
`;
|
||
|
||
(Math.cos)[cell.DOC] = `Return the cosine of x, where x is in radians.
|
||
|
||
:param x: A numeric value in radians.
|
||
:return: The cosine of x, in the range [-1, 1].
|
||
`;
|
||
|
||
(Math.exp)[cell.DOC] = `Return e^x, where e is Euler's number (approximately 2.71828).
|
||
|
||
:param x: A numeric exponent.
|
||
:return: The value of e raised to x.
|
||
`;
|
||
|
||
(Math.log)[cell.DOC] = `Return the natural logarithm (base e) of x. If x is <= 0, the result is NaN.
|
||
|
||
:param x: A positive numeric value.
|
||
:return: The natural logarithm of x.
|
||
`;
|
||
|
||
(Math.pow)[cell.DOC] = `Return base raised to the power exponent, i.e. base^exponent. If base is
|
||
negative and exponent is not an integer, result is NaN.
|
||
|
||
:param base: The base number.
|
||
:param exponent: The exponent number.
|
||
:return: base raised to exponent.
|
||
`;
|
||
|
||
(Math.sin)[cell.DOC] = `Return the sine of x, where x is in radians.
|
||
|
||
:param x: A numeric value in radians.
|
||
:return: The sine of x, in the range [-1, 1].
|
||
`;
|
||
|
||
(Math.tan)[cell.DOC] = `Return the tangent of x, where x is in radians. If x is (π/2 + nπ), the
|
||
result is ±Infinity or NaN.
|
||
|
||
:param x: A numeric value in radians.
|
||
:return: The tangent of x.
|
||
`;
|
||
|
||
(Math.trunc)[cell.DOC] = `Return the integer part of x by removing any fractional digits. Does not
|
||
round, just truncates.
|
||
|
||
:param x: A numeric value.
|
||
:return: x truncated toward zero.
|
||
`;
|
||
|
||
(Math.sign)[cell.DOC] = `Return the sign of x, indicating whether x is positive, negative, or zero.
|
||
Returns 1 if x > 0, -1 if x < 0, 0 if x is 0, and NaN if x is NaN.
|
||
|
||
:param x: A numeric value.
|
||
:return: 1, -1, 0, -0, or NaN, depending on x.
|
||
`;
|
||
|
||
(Math.cosh)[cell.DOC] = `Return the hyperbolic cosine of x, (e^x + e^-x) / 2.
|
||
|
||
:param x: A numeric value.
|
||
:return: The hyperbolic cosine of x.
|
||
`;
|
||
|
||
(Math.sinh)[cell.DOC] = `Return the hyperbolic sine of x, (e^x - e^-x) / 2.
|
||
|
||
:param x: A numeric value.
|
||
:return: The hyperbolic sine of x.
|
||
`;
|
||
|
||
(Math.tanh)[cell.DOC] = `Return the hyperbolic tangent of x, (e^x - e^-x) / (e^x + e^-x).
|
||
|
||
:param x: A numeric value.
|
||
:return: The hyperbolic tangent of x.
|
||
`;
|
||
|
||
(Math.acosh)[cell.DOC] = `Return the inverse hyperbolic cosine of x, defined as ln(x + sqrt(x^2 - 1)).
|
||
If x < 1, the result is NaN.
|
||
|
||
:param x: A numeric value >= 1.
|
||
:return: The inverse hyperbolic cosine of x.
|
||
`;
|
||
|
||
(Math.asinh)[cell.DOC] = `Return the inverse hyperbolic sine of x, defined as ln(x + sqrt(x^2 + 1)).
|
||
|
||
:param x: A numeric value.
|
||
:return: The inverse hyperbolic sine of x.
|
||
`;
|
||
|
||
(Math.atanh)[cell.DOC] = `Return the inverse hyperbolic tangent of x, defined as 1/2 * ln((1 + x) / (1 - x)).
|
||
If |x| >= 1, the result is NaN.
|
||
|
||
:param x: A numeric value in the range (-1, 1).
|
||
:return: The inverse hyperbolic tangent of x.
|
||
`;
|
||
|
||
(Math.expm1)[cell.DOC] = `Return e^x - 1, for small values of x this provides higher precision than
|
||
Math.exp(x) - 1.
|
||
|
||
:param x: A numeric exponent.
|
||
:return: e^x - 1.
|
||
`;
|
||
|
||
(Math.log1p)[cell.DOC] = `Return the natural logarithm of (1 + x). More accurate than Math.log(1 + x)
|
||
for small x.
|
||
|
||
:param x: A numeric value > -1.
|
||
:return: ln(1 + x).
|
||
`;
|
||
|
||
(Math.log2)[cell.DOC] = `Return the base-2 logarithm of x. If x <= 0, the result is NaN.
|
||
|
||
:param x: A positive numeric value.
|
||
:return: The base-2 logarithm of x.
|
||
`;
|
||
|
||
(Math.log10)[cell.DOC] = `Return the base-10 logarithm of x. If x <= 0, the result is NaN.
|
||
|
||
:param x: A positive numeric value.
|
||
:return: The base-10 logarithm of x.
|
||
`;
|
||
|
||
(Math.cbrt)[cell.DOC] = `Return the cube root of x, including negative values.
|
||
|
||
:param x: A numeric value (can be negative).
|
||
:return: The cube root of x.
|
||
`;
|
||
|
||
(Math.hypot)[cell.DOC] = `Return the square root of the sum of squares of its arguments, i.e.
|
||
sqrt(x1^2 + x2^2 + ...). If any value is ±Infinity, returns Infinity. If
|
||
any value is NaN, returns NaN.
|
||
|
||
:param values: One or more numeric values.
|
||
:return: The square root of the sum of squares of the arguments.
|
||
`;
|
||
|
||
(Math.random)[cell.DOC] = `Return a pseudo-random floating-point number in the range [0, 1).
|
||
The result is usually seeded by an engine-defined source of randomness.
|
||
|
||
:return: A number >= 0 and < 1.
|
||
`;
|
||
|
||
(Math.fround)[cell.DOC] = `Return the nearest 32-bit single-precision float representation of x.
|
||
|
||
:param x: A numeric value.
|
||
:return: The 32-bit float representation of x.
|
||
`;
|
||
|
||
(Math.imul)[cell.DOC] = `Return the result of a 32-bit integer multiplication of two values.
|
||
Effectively (a * b) | 0 in many implementations.
|
||
|
||
:param a: A numeric value.
|
||
:param b: A numeric value.
|
||
:return: The 32-bit integer result of multiplying a by b.
|
||
`;
|
||
|
||
(Math.clz32)[cell.DOC] = `Return the number of leading zero bits in the 32-bit binary representation
|
||
of x. If x is 0, returns 32.
|
||
|
||
:param x: A numeric value, treated as a 32-bit unsigned integer.
|
||
:return: The count of leading zero bits, in the range [0, 32].
|
||
`;
|
||
|
||
(Number.parseInt)[cell.DOC] = `Parse a string argument and return an integer of the specified radix (base).
|
||
If the string does not start with a valid integer, return NaN. Leading
|
||
whitespace is ignored.
|
||
|
||
:param string: The string to parse as an integer.
|
||
:param radix: An integer between 2 and 36 indicating the base of the number in the string.
|
||
:return: The parsed integer, or NaN if the input is not a valid integer.
|
||
`;
|
||
|
||
(Number.parseFloat)[cell.DOC] = `Parse a string argument and return a floating-point number. If the string does not represent a valid number, return NaN. Leading whitespace is ignored, and the string can include a decimal point or exponent.
|
||
|
||
:param string: The string to parse as a floating-point number.
|
||
:return: The parsed number, or NaN if invalid.
|
||
`;
|
||
|
||
(Number.isNaN)[cell.DOC] = `Determine if a value is the special numeric value NaN, without converting the argument. Unlike the global isNaN(), this returns false for non-numeric values.
|
||
|
||
:param value: The value to test.
|
||
:return: True if the value is NaN, otherwise false.
|
||
`;
|
||
|
||
(Number.isFinite)[cell.DOC] = `Determine if a value is a finite number. Unlike the global isFinite(), this returns false for non-numeric values without attempting to convert them.
|
||
|
||
:param value: The value to test.
|
||
:return: True if the value is a finite number, otherwise false.
|
||
`;
|
||
|
||
(Number.isInteger)[cell.DOC] = `Check if the given value is a finite number and also an integer (no fractional part). Returns false for non-numeric values or NaN.
|
||
|
||
:param value: The value to test.
|
||
:return: True if value is an integer, otherwise false.
|
||
`;
|
||
|
||
(Number.isSafeInteger)[cell.DOC] = `Check if the given value is a safe integer. A safe integer is one that can be exactly represented as an IEEE-754 double-precision number (i.e., between -9007199254740991 and 9007199254740991 inclusive).
|
||
|
||
:param value: The value to test.
|
||
:return: True if value is an integer within the safe range, otherwise false.
|
||
`;
|
||
|
||
(Array.isArray)[cell.DOC] = `Determine if the given value is an Array. Returns true if the argument is an array, otherwise false.
|
||
|
||
:param value: The value to be checked.
|
||
:return: True if 'value' is an array, otherwise false.
|
||
`;
|
||
|
||
(Array.from)[cell.DOC] = `Create a new array from an array-like or iterable object. An optional map function can be invoked on each element before it is added to the new array.
|
||
|
||
:param arrayLike: An array-like or iterable object to convert.
|
||
:param mapFn: Optional. A function to call on every element of the new array.
|
||
:param thisArg: Optional. A value to use as 'this' within the map function.
|
||
:return: A new array populated with elements processed from arrayLike.
|
||
`;
|
||
|
||
(Array.of)[cell.DOC] = `Create a new array with a variable number of arguments, regardless of the number or type of the arguments. Unlike the Array constructor, there is no special treatment for a single numeric argument.
|
||
|
||
:param elements: A variable number of arguments which become array elements.
|
||
:return: A new array containing the provided arguments.
|
||
`;
|
||
|
||
(Symbol.for)[cell.DOC] = `Search the global symbol registry for a symbol with the given key. If found, return that symbol; otherwise, create a new symbol with that key and add it to the registry, then return the new symbol.
|
||
|
||
:param key: A string key used to identify the symbol in the global registry.
|
||
:return: A symbol associated with the given key in the global registry.
|
||
`;
|
||
|
||
(Symbol.keyFor)[cell.DOC] = `Retrieve a shared symbol’s key from the global symbol registry. If the symbol is not in the global registry, return undefined.
|
||
|
||
:param sym: The symbol to find the key for.
|
||
:return: The string key if 'sym' is a global symbol, otherwise undefined.
|
||
`;
|
||
|
||
// ------------------------------------------
|
||
// MAP
|
||
// ------------------------------------------
|
||
Map.prototype[cell.DOC] = {}
|
||
Map.prototype[cell.DOC][cell.DOC] = `A Map object holds key-value pairs, where any value (both objects and primitive values) may be used as either a key or a value. Insertion order is remembered, which allows iteration in that order.`;
|
||
|
||
Map.prototype[cell.DOC].size = `A read-only property returning the number of key-value pairs in the Map.
|
||
|
||
:return: The number of entries in the Map.
|
||
`;
|
||
|
||
(Map.prototype.set)[cell.DOC] = `Add or update an entry in the Map with the specified key and value.
|
||
|
||
:param key: The key of the element to add or update.
|
||
:param value: The value associated with the key.
|
||
:return: The Map object (for chaining).
|
||
`;
|
||
|
||
(Map.prototype.get)[cell.DOC] = `Return the value associated with the specified key, or undefined if no
|
||
such key exists.
|
||
|
||
:param key: The key of the element to retrieve.
|
||
:return: The value associated with the key, or undefined if not found.
|
||
`;
|
||
|
||
(Map.prototype.has)[cell.DOC] = `Return a boolean indicating whether the Map contains an element with the
|
||
specified key.
|
||
|
||
:param key: The key to test for presence in the Map.
|
||
:return: True if the key is found, otherwise false.
|
||
`;
|
||
|
||
(Map.prototype.delete)[cell.DOC] = `Remove the specified key and its associated value from the Map, if it exists.
|
||
|
||
:param key: The key to remove.
|
||
:return: True if an element was removed, otherwise false.
|
||
`;
|
||
|
||
(Map.prototype.clear)[cell.DOC] = `Remove all entries from the Map, leaving it empty.
|
||
|
||
:return: None
|
||
`;
|
||
|
||
(Map.prototype.forEach)[cell.DOC] = `Execute a provided callback function once per each key-value pair in the Map,
|
||
in insertion order.
|
||
|
||
:param callbackFn: A function(value, key, map) to execute on each entry.
|
||
:param thisArg: Optional. A value to use as 'this' when executing callbackFn.
|
||
:return: None
|
||
`;
|
||
|
||
(Map.prototype.values)[cell.DOC] = `Return a new Iterator object that contains the values for each element
|
||
in the Map, in insertion order.
|
||
|
||
:return: An iterator of the Map's values.
|
||
`;
|
||
|
||
(Map.prototype.keys)[cell.DOC] = `Return a new Iterator object that contains the keys for each element in
|
||
the Map, in insertion order.
|
||
|
||
:return: An iterator of the Map's keys.
|
||
`;
|
||
|
||
(Map.prototype.entries)[cell.DOC] = `Return a new Iterator object that contains the [key, value] pairs for
|
||
each element in the Map, in insertion order.
|
||
|
||
:return: An iterator of [key, value] pairs.
|
||
`;
|
||
|
||
|
||
// ------------------------------------------
|
||
// SET
|
||
// ------------------------------------------
|
||
Set.prototype[cell.DOC] = {}
|
||
Set.prototype[cell.DOC][cell.DOC] = `A Set object lets you store unique values of any type, whether primitive values or object references. It remembers insertion order for iteration.`;
|
||
|
||
Set.prototype[cell.DOC].size = `A read-only property returning the number of elements in the Set.
|
||
|
||
:return: The number of unique values in the Set.
|
||
`;
|
||
|
||
(Set.prototype.add)[cell.DOC] = `Add a new element with the given value to the Set, if it’s not already present.
|
||
|
||
:param value: The value to add.
|
||
:return: The Set object (for chaining).
|
||
`;
|
||
|
||
(Set.prototype.has)[cell.DOC] = `Return a boolean indicating whether the Set contains the specified value.
|
||
|
||
:param value: The value to check for presence in the Set.
|
||
:return: True if the value is found, otherwise false.
|
||
`;
|
||
|
||
(Set.prototype.delete)[cell.DOC] = `Remove the specified value from the Set if it exists.
|
||
|
||
:param value: The value to remove.
|
||
:return: True if the value was present and removed, otherwise false.
|
||
`;
|
||
|
||
(Set.prototype.clear)[cell.DOC] = `Remove all elements from the Set, leaving it empty.
|
||
|
||
:return: None
|
||
`;
|
||
|
||
(Set.prototype.forEach)[cell.DOC] = `Execute a provided callback function once for each value in the Set,
|
||
in insertion order.
|
||
|
||
:param callbackFn: A function(value, valueAgain, set) to execute on each element.
|
||
:param thisArg: Optional. A value to use as 'this' when executing callbackFn.
|
||
:return: None
|
||
`;
|
||
|
||
(Set.prototype.values)[cell.DOC] = `Return a new Iterator object containing all the values in the Set,
|
||
in insertion order.
|
||
|
||
:return: An iterator of the Set's values.
|
||
`;
|
||
|
||
(Set.prototype.keys)[cell.DOC] = `Alias for values() in a Set. Return a new Iterator object containing all
|
||
the values (as keys) in the Set, in insertion order.
|
||
|
||
:return: An iterator of the Set's values.
|
||
`;
|
||
|
||
(Set.prototype.entries)[cell.DOC] = `Return a new Iterator object containing [value, value] pairs for each value
|
||
in the Set, in insertion order. This maintains API consistency with Map objects.
|
||
|
||
:return: An iterator of [value, value] pairs.
|
||
`;
|