Sorts the specified items
by the specified field
.
Creates a copy of the specified array of items
with the items reversed.
Creates a copy of the specified array of items
sorted by the optional
compareFunc
. This is done because the native sort function mutates the array.
Removes any duplicate values from the specified items
array.
Function that iterates over the specified object item
and returns the
key.
Appends a value
to the dict
entry associated with the specified key
. If the
key is not present in the dict
, add it as an array containing value
.
The object is mutated for performance reasons, and the mutated dict
is returned.
Groups the specified items
array by the specified property
.
Converts a collection of items
to keyed by the specified field
name.
Returns an array of values in which the specified fieldName
value matches the
specified searchTerm
in the specified collection
.
Sums the values of the specified field
in the specified collection
of objects.
Mask | Description |
---|---|
d |
Day of the month as digits; no leading zero for single-digit days. |
dd |
Day of the month as digits; leading zero for single-digit days. |
ddd |
Day of the week as a three-letter abbreviation. |
DDD |
"Ysd", "Tdy" or "Tmw" if date lies within these three days. Else fall back to ddd . |
dddd |
Day of the week as its full name. |
DDDD |
"Yesterday", "Today" or "Tomorrow" if date lies within these three days. Else fall back to dddd . |
m |
Month as digits; no leading zero for single-digit months. |
mm |
Month as digits; leading zero for single-digit months. |
mmm |
Month as a three-letter abbreviation. |
mmmm |
Month as its full name. |
yy |
Year as last two digits; leading zero for years less than 10. |
yyyy |
Year represented by four digits. |
h |
Hours; no leading zero for single-digit hours (12-hour clock). |
hh |
Hours; leading zero for single-digit hours (12-hour clock). |
H |
Hours; no leading zero for single-digit hours (24-hour clock). |
HH |
Hours; leading zero for single-digit hours (24-hour clock). |
M |
Minutes; no leading zero for single-digit minutes. |
MM |
Minutes; leading zero for single-digit minutes. |
N |
ISO 8601 numeric representation of the day of the week. |
o |
GMT/UTC timezone offset, e.g. -0500 or +0230. |
p |
GMT/UTC timezone offset, e.g. -05:00 or +02:30. |
s |
Seconds; no leading zero for single-digit seconds. |
ss |
Seconds; leading zero for single-digit seconds. |
S |
The date's ordinal suffix (st, nd, rd, or th). Works well with d . |
l |
Milliseconds; gives 3 digits. |
L |
Milliseconds; gives 2 digits. |
t |
Lowercase, single-character time marker string: a or p. |
tt |
Lowercase, two-character time marker string: am or pm. |
T |
Uppercase, single-character time marker string: A or P. |
TT |
Uppercase, two-character time marker string: AM or PM. |
W |
ISO 8601 week number of the year, e.g. 4, 42. |
WW |
ISO 8601 week number of the year, leading zero for single-digit, e.g. 04, 42 |
Z |
US timezone abbreviation, e.g. EST or MDT. For non-US timezones, the GMT/UTC offset is returned, e.g. GMT-0500. |
'...' , "..." |
Literal character sequence. Surrounding quotes are removed. |
Formats the specified date
using the specified format mask
.
Used to add type safety to event listeners on a class that extends EventTarget
.
See the example below for additional details.
An object that can be passed to the listener
parameter of
TypedEventTarget.addEventListener
and TypedEventTarget.removeEventListener
.
A function that can be passed to the listener
parameter of
TypedEventTarget.addEventListener
and TypedEventTarget.removeEventListener
.
Type of parameter listener
in TypedEventTarget.addEventListener
and TypedEventTarget.removeEventListener
.
Joins the specified file pathElements
based on the host platform path
separator.
Splits the specified filePath
into separate elements based on the host
platform path separator.
Creates a debounced function that only invokes func
at most once per
every delay
milliseconds (or once per browser frame).
Does nothing. Useful for initializing function variables or properties
before assigning values. Note that it returns any
instead of void
and
accepts arbitrary arguments so TypeScript doesn't freak out.
Creates a throttled function that only invokes func
at most once per
every delay
milliseconds (or once per browser frame). See
this article
for additional details.
Attempts to extract the numeric value from the specified value
. This
function will always return a number. If a number cannot be extracted from
the value, returns the specified fallback
.
Clamps specified value within the inclusive lower and upper bounds.
Checks if the specified value
is greater than or equal to the specified
other
value.
Checks if the specified value
is a valid number. If the value
is NaN
,
returns false
.
Checks if the specified value
is less than or equal to the specified
other
value.
Returns a random integer between the minimum
and maximum
specified values.
Rounds the specified value
to the specified precision
.
Attempts to coerce the specified value
to a number. If the value cannot be
coerced to a valid number, returns the specified fallback
value.
Creates an array of [key, value] pairs for the specified dict
.
The purpose of this function is to allow an override for the type of the
object key since TypeScript defaults to only allowing a string, number, or
symbol (but it could be an enum).
Returns true if the specified left
and right
values are deeply equal.
Checks if the specified value
is a plain object.
Gets the keys of the specified dict
as an array that won't throw a
TypeScript error if you try to loop through them and access values from the
corresponding dict
.
Removes the specified key
from the specified dict
and returns a copy of
the updated object.
Creates an array of [key, value] pairs for the specified dict
.
The purpose of this function is to allow an override for the type of the
object key since TypeScript defaults to only allowing a string (but it
could be a string enum).
Possible platforms for the host. Note that Linux encompasses several different distros. But for the purposes of this library, we only need to know the specific OS distro.
Gets the current OS/platform that the application is running on.
Checks if the specified platform
matches the host.
Runtime environment in which the code is executing.
Gets the current JavaScript runtime in which the application is running.
Checks if the program is running in the specified runtime
.
Checks if the specified runtime
matches the host.
Transforms the specified string value to camelCase.
Capitalizes the first letter of the specified value and returns the result.
Strips indentation from multi-line template strings.
Converts the specified value
to kebab-case.
Terminal style that can be applied to a string before logging.
Callback that takes an input
string and returns the result with formatting
applied.
Object with key of terminal style and value of the corresponding formatter callback to apply style to an input.
Object with terminal style formatters. Use this if you don't need to programmatically set whether terminal styles should be enabled.
Creates a terminal styles formatter object dynamically and returns an object with formatter functions for applying formatting to an input. This is provided in the event that you need to explicitly enable or disable terminal colors programmatically.
Object with key of DictKey
and any value.
Function that takes any variable arguments and returns any value.
Any plain object with key/value pair of type any
.
Key/value pair with key of valid DictKey
.
Valid key type for an object (i.e. dictionary).
Extracts the string keys of the specified object into an array.
Represents a value that could be of type T
or null
or undefined
.
Type is either a single item or array of items of type T
.
Represents primitive values (i.e. booleans, numbers, and strings).
Adds null
as the possible type for the fields in the specified type.
Adds undefined
as the possible type for the fields in the specified type.
Forces the specified value to be the specified type T
to get around annoying
TypeScript idiosyncrasies.
Checks if the specified value
is empty.
Checks if the specified value
is null
or undefined
.
Checks if the specified value is not null
and not undefined
.
Pauses execution for the specified duration.
Converts the specified value
to a boolean (note that it is case-insensitive).
Generates a V4 UUID using the Node.js crypto.randomUUID function or the browser's crypto.randomUUID function. The correct one to use is determined automatically.
Removes the item at the specified
index
from the specifieditems
array.