Skip to content

Functions overview

Welcome to the Radashi API Reference.

Array

alphabetical

Sorts an array of objects alphabetically by a property

boil

Reduce a list of items down to one item

castArray

Cast a value into an array

castArrayIfExists

Cast a non-nullish value into an array

cluster

Split a list into many lists of the given size

counting

Creates an object with counts of occurrences of items

diff

Create an array of differences between two arrays

first

Get the first item from a list

flat

Flatten an array of arrays into a single dimension

fork

Split an array into two arrays by a condition

group

Sort an array of items into groups

intersects

Determine if two arrays have a common item

iterate

Iterate over a callback n times

last

Get the last item from a list

list

Create a list with specific items

mapify

Convert an array to a map

merge

Combine two lists overriding items in the first

objectify

Convert a list to a dictionary object

replace

Replace an item in an array

replaceOrAppend

Replace item in array or append if no match

select

Filter and map an array

selectFirst

Find and map the first array element meeting a condition

shift

Shift array items by n steps

sift

Remove all falsy items from list

sort

Sort a list of objects by a numerical property

toggle

Toggles an item’s existence in an array

unique

Remove duplicates from an array

unzip

Group array elements by their index position across the input arrays

zip

Combine multiple arrays in sets

zipToObject

Combine multiple arrays in sets

Async

all

Await many promises

defer

Run an async function with deferred functions

guard

Have a function return undefined if it errors out

map

Map an array with an async function

parallel

Run many async function in parallel

reduce

Reduce an array with an async function

retry

Run an async function retrying if it fails

sleep

Asynchronously wait for time to pass

tryit

Convert a function to an error-first function

withResolvers

Ponyfill for Promise.withResolvers()

Curry

chain

Create a chain of function to run in order

compose

Create a composition of functions

debounce

Delay a function until after a specified time has elapsed since the last call

flip

Swap the only two arguments of a function

memo

Memoize a function

once

Create a function that runs at most once

partial

Create a partial a function

partob

Create a partob a function

proxied

Create a dynamic proxied a object

throttle

Creates a throttled function that limits invocations to a specified interval

Function

always

Create a function that always returns the same value

castComparator

Cast a value into a comparator function

castMapping

Cast a value into a mapping function

noop

Does nothing and returns undefined

Number

clamp

Limit the range of a variable number

inRange

Verifies number within range, inclusive start, exclusive end, flexible order, defaulting to 0 if end unspecified

lerp

Smoothly transitions between two values based on a factor

max

Get the largest item from an array

min

Get the smallest item from an array

range

Create a range used for iterating

round

Rounds a number to a specified precision.

sum

Add up all items of an array

toFloat

Convert a value to a float if possible

toInt

Convert a value to an int if possible

Object

assign

Merges two objects together recursively

clone

Creates a shallow copy of the given object/value.

cloneDeep

Create a deep copy of an object or array

construct

Builds an object from key paths and values

crush

Flattens a deep object to a single dimension

filterKey

Check if an object key passes a filter

get

Get any attribute or child attribute using a deep path

invert

Invert the keys and values of an object

keys

Get all keys from an object deeply

listify

Convert an object to a list

lowerize

Convert all object keys to lower case

mapEntries

Map the keys and values of an object

mapKeys

Map over the keys of an object

mapValues

Map over the keys of an object

omit

Omit unwanted attributes from an object

pick

Pick only the desired properties from an object

set

Set a value on an object using a path key

shake

Remove unwanted values from an object

traverse

Deeply enumerate an object and any nested objects

upperize

Convert all object keys to upper case

Random

draw

Get a random item from a list

random

Generate a random number

shuffle

Randomly shuffle an array

uid

Generate a unique identifier

Series

series

Create an ordered series object

String

camel

Convert a string to camel case

capitalize

Convert a string to a capitalized format

dash

Convert a string to dash case

pascal

Convert a string to pascal case

similarity

Calculate the similarity between two strings using the Levenshtein distance algorithm

snake

Convert a string to snake case

template

Template a string with values from a data object using a search expression

title

Convert a string to title case

trim

Trim values from a string

Typed

isArray

Determine if a value is an Array

isBoolean

Check if a value is a boolean type

isDate

Determine if a value is a Date

isEmpty

Determine if a value is empty

isEqual

Determine if two values are equal

isError

Determine if a value is an Error

isFloat

Determine if a value is a float

isFunction

Determine if a value is a Function

isInt

Determine if a value is an int

isIntString

Determine if a value is an int in string form

isMap

Returns true for Map instances

isNumber

Determine if a value is a number

isObject

Determine if a value is an Object

isPlainObject

Determine if a value is a plain object

isPrimitive

Checks if the given value is primitive

isPromise

Determine if a value is a Promise or has a then method

isRegExp

Returns true for RegExp instances

isResult

Check if a value is a Result tuple

isResultErr

Returns true for failed Result tuple

isResultOk

Returns true for successful Result tuple

isSet

Returns true for Set instances

isString

Determine if a value is a String

isSymbol

Determine if a value is a Symbol

isWeakMap

Returns true for WeakMap instances

isWeakSet

Returns true for WeakSet instances