A representation of a duration of time within a codebase. This class provides a way to work with durations of time in a type-safe manner.
-
days(days: Days): Duration
Creates a Duration from days.
-
hours(hours: Hours): Duration
Creates a Duration from hours.
-
milliseconds(milliseconds: Milliseconds): Duration
Creates a Duration from milliseconds.
-
minutes(minutes: Minutes): Duration
Creates a Duration from minutes.
-
seconds(seconds: Seconds): Duration
Creates a Duration from seconds.
-
sleep(): Promise<void>
Sleeps for the current duration.
-
toDays(): Days
Converts the duration to days.
-
toHours(): Hours
Converts the duration to hours.
-
toMilliseconds(): Milliseconds
Converts the duration to milliseconds.
-
toMinutes(): Minutes
Converts the duration to minutes.
-
toSeconds(): Seconds
Converts the duration to seconds.
-
toWeeks(): Weeks
Converts the duration to weeks.
-
toYears(): Years
Converts the duration to years.
-
weeks(weeks: Weeks): Duration
Creates a Duration from weeks.
-
years(years: Years): Duration
Creates a Duration from years.
Adds the given amount of days to the specified date.
Adds the given amount of months to the specified date.
Adds the given amount of years to the specified date.
Returns the average number from a list of numbers.
Converts the string to camelCase by removing punctuation, trimming extra
spaces, and lowercasing the first word with subsequent words capitalized.
Splits an array into chunks of a fixed size.
Clamps a number between a minimum and maximum value.
Clone an object using structuredClone.
Removes null and undefined values from a list.
The current month as a number from 1 (January) to 12 (December).
The current year as a number (e.g. 2026).
Converts days to milliseconds. This is shorthand for the following:
Calculates the days between two dates.
Returns the difference of multiple arrays.
Returns the distinct values from a list.
Returns a list with the first n elements removed. Does not mutate the input.
Returns a strongly-typed array of an object's own enumerable [key, value] pairs.
Determines if the given value is falsy.
Returns the first thing in a list. If the value is a string, then it will return the first character.
Groups items into a Map keyed by the value returned from keyFn.
Converts hours to milliseconds. This is shorthand for the following:
Determines if searchIn contains the given searchFor term(s).
Determines if searchIn contains any of the given searchFor term(s).
Returns true if the given value is within the given range (inclusive on both ends).
Returns the intersection of multiple arrays.
Determines if the given value is an array. Acts as a type guard, narrowing
the value to unknown[] in branches where the result is true.
Determines if the given thing is empty.
Compares two things by turning them into strings, and comparing them by their string value.
Compares two things by turning them into strings and lowercasing
them, and comparing the string values. Works exactly like isEqual except
will lowercase both things before comparing.
Determines if a number is even.
Checks if a date is a Friday.
Determines if the date is in the future.
Determines if the date is in the past.
Checks if a date is a Monday.
Returns true if the given value is null or undefined.
Alias for isEmpty.
Alias for isWhitespace.
Determines if the given thing is not empty.
Compares two things by turning them into strings, and comparing them by their string value.
Compares two things by turning them into strings, trimming and lowercasing
them, and comparing the string values. Works exactly like isEqual except
will lowercase both things before comparing.
Alias for isNotEmpty.
Alias for isNotWhitespace.
Determines if the given text contains any non-whitespace characters.
Determines if a number is odd.
Checks if a date is a Saturday.
Returns true if the given value is not null or undefined.
Checks if a date is a Sunday.
Checks if a date is a Thursday.
Determines if the date is today.
Determines if the date is tomorrow.
Checks if a date is a Tuesday.
Checks if a date is a Wednesday.
Checks if a date is a weekday.
Checks if a date is a weekend.
Determines if the given text is only comprised of whitespace.
Determines if the date is yesterday.
Converts the string to kebab-case by removing punctuation,
trimming extra spaces, converting to lowercase, and joining words with hyphens.
Returns a copy of the given string with all non-alpha characters removed, except for spaces. Letters are preserved regardless of case.
Returns a copy of the given string with all non-alphanumeric characters removed, except for spaces. Letters and digits are preserved regardless of case.
Removes any non-numeric characters. This includes spaces.
Returns a strongly-typed array of an object's own enumerable keys.
Returns the last thing in a list. If the value is a string, then it will return the last character.
Converts the string to lowercase.
An alias for toLowerCase().
Returns a new object with each key transformed by fn. Values are unchanged.
If fn produces duplicate keys, later entries overwrite earlier ones.
Returns a new object with the same keys, where each value is transformed by fn.
Returns the maximum number from a list of numbers.
Returns the median value from a list of numbers.
Converts milliseconds to milliseconds. This is shorthand for the following:
Returns the minimum number from a list of numbers.
Converts minutes to milliseconds. This is shorthand for the following:
Calculates the months between two dates.
Returns a new list with an element moved from one index to another.
Returns a function that does nothing.
Right now. This is an alias for new Date().
Returns a new object with the specified keys excluded.
Converts a number to "1st", "2nd", "3rd", etc.
Safely parses a string to JSON or returns the string itself. This will
never throw an error and internally called JSON.parse(thing)
Splits a list into two: the first contains items where the predicate is true, the second contains items where it is false.
Converts the string to PascalCase by removing punctuation, trimming extra
spaces, and capitalizing every word.
Returns a new object containing only the specified keys. Keys that are not present on the source object are silently ignored.
Gives a random number in the given range. The first parameter is inclusive and the second one is exclusive. Therefore, it will work with lists out of the box.
Generates a list of numbers in the given range. The start is inclusive, the end is exclusive.
Reverses the given string or list.
Rounds a number to the nearest integer.
Rounds a number to the given number of decimal places.
Pick a random item from an array.
Converts seconds to milliseconds. This is shorthand for the following:
Sleeps for the given duration of milliseconds.
Converts a string to a URL-safe slug. Diacritics are stripped, punctuation is removed, and whitespace is replaced with hyphens.
Converts a string to snake_case by replacing spaces and punctuation with underscores.
Uses kebab() internally, replacing hyphens with underscores.
Returns a new array sorted by the value returned from keyFn.
Returns a new array with elements removed and/or inserted, without mutating the original.
Converts the given parameter into the string equivalent.
Subtracts the given amount of days from the specified date.
Subtracts the given amount of months from the specified date.
Subtracts the given amount of yers from the specified date.
Returns the sum of a list of numbers.
Returns a new list with the elements at indices i and j swapped.
Returns the first n elements of a list. Does not mutate the input.
Converts the string to Title Case. This will capitalize the letter of each word that is separated by a space. Underscores are considered spaces. Hyphens are respected.
Today's date at midnight.
Returns a function that does nothing. Similar to noop, however
this allows you to put in an optional message regarding todos.
Tomorrow's date at midnight.
Trims the whitespace from the beginning and the end. This is an
alias for .trim(). Useful for when you're mapping over lists.
Truncates a string to the given length. If truncation occurs, the suffix is appended and counted toward the total length.
Determines if the given value is truthy.
Returns the union of multiple arrays.
Returns the distinct values from a list.
Converts the string to uppercase.
An alias for toUpperCase().
Converts weeks to milliseconds. This is shorthand for the following:
Converts years to milliseconds. This is shorthand for the following:
Calculates the years between two dates. The date must be equal or past for it to count as a full year.
Yesterday's date at midnight.
Pairs up elements from two lists. Stops at the shorter list.
This is a utility type that allows you to Autocomplete a string.
Represents a type that is branded with a unique symbol.
Represents a duration of time in days.
Represents a duration of time in hours.
This is a utility type that allows you to get the keys from an object or list.
Represents a duration of time in milliseconds. You should always use this type when working with durations of time in milliseconds. It helps ensure that you're working with durations of time in milliseconds, and not accidentally using a different unit of time.
Represents a duration of time in minutes.
Syntactic sugar for null | undefined.
Represents a non-empty list.
This is a utility type that allows you to get the keys from a list.
Represents when there can be one or many of someting
Represents a thing that might be None (null or undefined).
A utility type that takes an object type and makes the hover overlay more readable for the developer.
| number
| boolean
| bigint
| symbol
| null
| undefined
Represents any primitive ECMAScript value.
Represents a duration of time in seconds.
This is a utility type that allows you to get the values from an object or a list.
Represents a duration of time in weeks.
Represents a duration of time in years.