default

Classes

c
Duration(milliseconds: Milliseconds)

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.

Functions

f
addDays(
date: Date,
days: number
): Date

Adds the given amount of days to the specified date.

f
addMonths(
date: Date,
months: number
): Date

Adds the given amount of months to the specified date.

f
addYears(
date: Date,
years: number
): Date

Adds the given amount of years to the specified date.

f
average(nums: number[]): number

Returns the average number from a list of numbers.

f
camel(text: string): string

Converts the string to camelCase by removing punctuation, trimming extra spaces, and lowercasing the first word with subsequent words capitalized.

f
chunk<T>(
arr: T[],
size: number
): T[][]

Splits an array into chunks of a fixed size.

f
clamp(
num: number,
min: number,
max: number
): number

Clamps a number between a minimum and maximum value.

f
clone<T>(obj: T): T

Clone an object using structuredClone.

f
compact<T>(list: (T | null | undefined)[]): T[]

Removes null and undefined values from a list.

f
currentMonth(): number

The current month as a number from 1 (January) to 12 (December).

f
currentYear(): number

The current year as a number (e.g. 2026).

f
days(days: number): Milliseconds

Converts days to milliseconds. This is shorthand for the following:

f
daysBetween(
start: Date,
end: Date
): number

Calculates the days between two dates.

f
difference<T>(...lists: T[][]): T[]

Returns the difference of multiple arrays.

f
distinct<T>(list: T[]): T[]

Returns the distinct values from a list.

f
drop<T>(
list: T[],
n: number
): T[]

Returns a list with the first n elements removed. Does not mutate the input.

f
entries<T extends Record<string, unknown>>(obj: T | None): [keyof T, T[keyof T]][]

Returns a strongly-typed array of an object's own enumerable [key, value] pairs.

f
falsy(thing: unknown): boolean

Determines if the given value is falsy.

f
first<T>(value: string | T[]): T | string | undefined
2 overloads

Returns the first thing in a list. If the value is a string, then it will return the first character.

f
groupBy<T, K>(
list: T[],
keyFn: (item: T) => K
): Map<K, T[]>

Groups items into a Map keyed by the value returned from keyFn.

f
hours(hours: number): Milliseconds

Converts hours to milliseconds. This is shorthand for the following:

f
inRange(
value: number,
min: number,
max: number
): boolean

Returns true if the given value is within the given range (inclusive on both ends).

f
intersection<T>(...lists: T[][]): T[]

Returns the intersection of multiple arrays.

f
isArray(thing: unknown): thing is unknown[]

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.

f
isEmpty(thing: unknown): boolean

Determines if the given thing is empty.

f
isEqual(
thing1: unknown,
thing2: unknown
): boolean

Compares two things by turning them into strings, and comparing them by their string value.

f
isEqualIgnoreCase(
thing1: unknown,
thing2: unknown
): boolean

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.

f
isEven(num: number): boolean

Determines if a number is even.

f
isFriday(date: Date): boolean

Checks if a date is a Friday.

f
isInFuture(date: Date): boolean

Determines if the date is in the future.

f
isInPast(date: Date): boolean

Determines if the date is in the past.

f
isMonday(date: Date): boolean

Checks if a date is a Monday.

f
isNone(thing: unknown): thing is null | undefined

Returns true if the given value is null or undefined.

f
isNotEmpty(thing: unknown): boolean

Determines if the given thing is not empty.

f
isNotEqual(
thing1: unknown,
thing2: unknown
): boolean

Compares two things by turning them into strings, and comparing them by their string value.

f
isNotEqualIgnoreCase(
thing1: unknown,
thing2: unknown
): boolean

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.

f
isNotWhitespace(text: string): boolean

Determines if the given text contains any non-whitespace characters.

f
isOdd(num: number): boolean

Determines if a number is odd.

f
isSaturday(date: Date): boolean

Checks if a date is a Saturday.

f
isSome<T>(thing: T | null | undefined): thing is T

Returns true if the given value is not null or undefined.

f
isSunday(date: Date): boolean

Checks if a date is a Sunday.

f
isThursday(date: Date): boolean

Checks if a date is a Thursday.

f
isToday(date: Date): boolean

Determines if the date is today.

f
isTomorrow(date: Date): boolean

Determines if the date is tomorrow.

f
isTuesday(date: Date): boolean

Checks if a date is a Tuesday.

f
isWednesday(date: Date): boolean

Checks if a date is a Wednesday.

f
isWeekday(date: Date): boolean

Checks if a date is a weekday.

f
isWeekend(date: Date): boolean

Checks if a date is a weekend.

f
isWhitespace(text: string): boolean

Determines if the given text is only comprised of whitespace.

f
isYesterday(date: Date): boolean

Determines if the date is yesterday.

f
kebab(text: string): Lowercase<string>

Converts the string to kebab-case by removing punctuation, trimming extra spaces, converting to lowercase, and joining words with hyphens.

f
keepAlphabetical(text: string): string

Returns a copy of the given string with all non-alpha characters removed, except for spaces. Letters are preserved regardless of case.

f
keepAlphanumeric(text: string): string

Returns a copy of the given string with all non-alphanumeric characters removed, except for spaces. Letters and digits are preserved regardless of case.

f
keepNumeric(text: string): string

Removes any non-numeric characters. This includes spaces.

f
keys<T extends Record<string, unknown>>(obj: T | None): (keyof T)[]

Returns a strongly-typed array of an object's own enumerable keys.

f
last<T>(value: string | T[]): T | string | undefined
2 overloads

Returns the last thing in a list. If the value is a string, then it will return the last character.

f
lower(text: string): Lowercase<string>

Converts the string to lowercase. An alias for toLowerCase().

f
mapKeys<T extends Record<string, unknown>>(
obj: T | None,
fn: (
key: keyof T,
value: T[keyof T]
) => string
): Record<string, T[keyof T]>

Returns a new object with each key transformed by fn. Values are unchanged. If fn produces duplicate keys, later entries overwrite earlier ones.

f
max(nums: number[]): number

Returns the maximum number from a list of numbers.

f
median(nums: number[]): number

Returns the median value from a list of numbers.

f
milliseconds(milliseconds: number): Milliseconds

Converts milliseconds to milliseconds. This is shorthand for the following:

f
min(nums: number[]): number

Returns the minimum number from a list of numbers.

f
minutes(minutes: number): Milliseconds

Converts minutes to milliseconds. This is shorthand for the following:

f
monthsBetween(
start: Date,
end: Date
): number

Calculates the months between two dates.

f
move<T>(
list: T[],
from: number,
to: number
): T[]

Returns a new list with an element moved from one index to another.

f
noop(): void

Returns a function that does nothing.

f
now(): Date

Right now. This is an alias for new Date().

f
ordinalize(num: number): string

Converts a number to "1st", "2nd", "3rd", etc.

f
parse<T>(thing: string): T | string

Safely parses a string to JSON or returns the string itself. This will never throw an error and internally called JSON.parse(thing)

f
partition<T>(
list: T[],
predicate: (item: T) => boolean
): [T[], T[]]

Splits a list into two: the first contains items where the predicate is true, the second contains items where it is false.

f
pascal(text: string): string

Converts the string to PascalCase by removing punctuation, trimming extra spaces, and capitalizing every word.

f
pick<T extends Record<string, unknown>, K extends keyof T>(
obj: T | None,
keys: K[]
): Pick<T, K>

Returns a new object containing only the specified keys. Keys that are not present on the source object are silently ignored.

f
random(
start: number,
end: number
): number

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.

f
range(
start: number,
end: number,
step?: number
): number[]

Generates a list of numbers in the given range. The start is inclusive, the end is exclusive.

f
round(num: number): number

Rounds a number to the nearest integer.

f
roundTo(
num: number,
decimals: number
): number

Rounds a number to the given number of decimal places.

f
sample<T>(list: T[]): T | undefined

Pick a random item from an array.

f
seconds(seconds: number): Milliseconds

Converts seconds to milliseconds. This is shorthand for the following:

f
sleep(ms: Milliseconds): Promise<void>

Sleeps for the given duration of milliseconds.

f
slugify(text: string): string

Converts a string to a URL-safe slug. Diacritics are stripped, punctuation is removed, and whitespace is replaced with hyphens.

f
snake(text: string): Lowercase<string>

Converts a string to snake_case by replacing spaces and punctuation with underscores. Uses kebab() internally, replacing hyphens with underscores.

f
sortBy<T>(
list: T[],
keyFn: (item: T) => number | string
): T[]

Returns a new array sorted by the value returned from keyFn.

f
splice<T>(
list: T[],
start: number,
deleteCount?: number,
items?: T[]
): T[]

Returns a new array with elements removed and/or inserted, without mutating the original.

f
stringify(thing: unknown): string

Converts the given parameter into the string equivalent.

f
subtractDays(
date: Date,
days: number
): Date

Subtracts the given amount of days from the specified date.

f
subtractMonths(
date: Date,
months: number
): Date

Subtracts the given amount of months from the specified date.

f
subtractYears(
date: Date,
years: number
): Date

Subtracts the given amount of yers from the specified date.

f
sum(nums: number[]): number

Returns the sum of a list of numbers.

f
swap<T>(
list: T[],
i: number,
j: number
): T[]

Returns a new list with the elements at indices i and j swapped.

f
take<T>(
list: T[],
n: number
): T[]

Returns the first n elements of a list. Does not mutate the input.

f
title(text: string): string

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.

f
today(): Date

Today's date at midnight.

f
todo(message?: string): void

Returns a function that does nothing. Similar to noop, however this allows you to put in an optional message regarding todos.

f
tomorrow(): Date

Tomorrow's date at midnight.

f
trim(text: string): string

Trims the whitespace from the beginning and the end. This is an alias for .trim(). Useful for when you're mapping over lists.

f
truncate(
text: string,
length: number,
suffix?: string
): string

Truncates a string to the given length. If truncation occurs, the suffix is appended and counted toward the total length.

f
truthy(thing: unknown): boolean

Determines if the given value is truthy.

f
union<T>(...lists: T[][]): T[]

Returns the union of multiple arrays.

f
unique<T>(list: T[]): T[]

Returns the distinct values from a list.

f
upper(text: string): Uppercase<string>

Converts the string to uppercase. An alias for toUpperCase().

f
weeks(weeks: number): Milliseconds

Converts weeks to milliseconds. This is shorthand for the following:

f
years(years: number): Milliseconds

Converts years to milliseconds. This is shorthand for the following:

f
yearsBetween(
start: Date,
end: Date
): number

Calculates the years between two dates. The date must be equal or past for it to count as a full year.

f
yesterday(): Date

Yesterday's date at midnight.

f
zip<A, B>(
a: A[],
b: B[]
): [A, B][]

Pairs up elements from two lists. Stops at the shorter list.

Type Aliases

T
AutoComplete<T extends string> = T | (string & Record<PropertyKey, unknown>)

This is a utility type that allows you to Autocomplete a string.

T
Brand<T, B> = T & { __brand: B; }

Represents a type that is branded with a unique symbol.

T
Days = Brand<number, "days">

Represents a duration of time in days.

T
Hours = Brand<number, "hours">

Represents a duration of time in hours.

T
KeyOf<T> = T extends Readonly<unknown[]> ? ValueOf<T> : keyof T

This is a utility type that allows you to get the keys from an object or list.

T
Milliseconds = Brand<number, "milliseconds">

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.

T
Minutes = Brand<number, "minutes">

Represents a duration of time in minutes.

T
None = null | undefined

Syntactic sugar for null | undefined.

T
NonEmptyList<T> = [T, ...T[]]

Represents a non-empty list.

T
OneOf<T extends Readonly<unknown[]>> = T[number]

This is a utility type that allows you to get the keys from a list.

T
OneOrMany<T> = T | T[]

Represents when there can be one or many of someting

T
Option<T> = T | None

Represents a thing that might be None (null or undefined).

T
Prettify<T> = [K in keyof T]: T[K] & { }

A utility type that takes an object type and makes the hover overlay more readable for the developer.

T
Seconds = Brand<number, "seconds">

Represents a duration of time in seconds.

T
ValueOf<T> = T extends Readonly<unknown[]> ? T[number] : T[keyof T]

This is a utility type that allows you to get the values from an object or a list.

T
Weeks = Brand<number, "weeks">

Represents a duration of time in weeks.

T
Years = Brand<number, "years">

Represents a duration of time in years.