# massaman > A rich blend of functional patterns. ## Introduction - [Introduction](https://massaman.dev/introduction.md): Massaman is a Rust-inspired utility library for functional programming in JavaScript, with first-class TypeScript support. It favors pure functions, immutable data, function composition, errors returned as values, and pattern matching that handles every case. ## Philosophy - [Philosophy](https://massaman.dev/philosophy.md): Massaman is opinionated about how JavaScript should be written, but it does not invent a new world for your application to live in. ## Concepts - [Concepts](https://massaman.dev/concepts.md): Failure as data, exhaustive branching, and composable transformations. - [Composition](https://massaman.dev/concepts/composition.md): Composition builds larger operations from small functions. Each step receives the previous step's output, which keeps transformations explicit and avoids intermediate mutable state. Massaman includes the standard synchronous tools from es-toolkit and adds async-aware and branching combinators for pipelines that need them. - [Pattern Matching](https://massaman.dev/concepts/match.md): massaman/match re-exports ts-pattern and adds P.ok and P.err patterns for Massaman results. It turns branching into an expression and can prove that every variant of a union is handled. - [Result & Errors](https://massaman.dev/concepts/result.md): Massaman treats expected failure as data. A fallible operation returns a Result so its caller can see and handle both outcomes without relying on an exception path. The error parameter preserves specific Error types while defaulting to Error for existing Result call sites. Thrown and rejected values still exist at unsafe boundaries; attempt, attemptAsync, and err normalize non-Error values before returning an Err. ## Reference - [Reference](https://massaman.dev/reference.md): Every exported function, grouped by public surface. - [Array](https://massaman.dev/reference/array.md) - [adjust](https://massaman.dev/reference/array/adjust.md): Applies a function to the element at an index and returns a new array. - [ascend](https://massaman.dev/reference/array/ascend.md): Creates an ascending comparator from an accessor function. - [at](https://massaman.dev/reference/array/at.md): Gets the elements at specified indices from an array and returns a new array. - [cartesianProduct](https://massaman.dev/reference/array/cartesianProduct.md): Computes the Cartesian product of the input arrays. - [chunk](https://massaman.dev/reference/array/chunk.md): Splits an array into smaller arrays of a specified size. - [chunkBy](https://massaman.dev/reference/array/chunkBy.md): Splits an array into chunks of consecutive elements that share the same key. - [combinations](https://massaman.dev/reference/array/combinations.md): Returns all r-length combinations of elements from the input array. - [compact](https://massaman.dev/reference/array/compact.md): Returns a new array with falsy values removed. - [countBy](https://massaman.dev/reference/array/countBy.md): Categorizes the elements of an array based on a transformation function result and returns an object with counts. - [descend](https://massaman.dev/reference/array/descend.md): Creates a descending comparator from an accessor function. - [difference](https://massaman.dev/reference/array/difference.md): Returns a new array excluding elements from the first array that are in the second array. - [differenceBy](https://massaman.dev/reference/array/differenceBy.md): Transforms elements of two arrays with a conversion function, computes their difference, and returns a new array. - [differenceWith](https://massaman.dev/reference/array/differenceWith.md): Computes the difference of two arrays using a custom comparison function and returns a new array. - [drop](https://massaman.dev/reference/array/drop.md): Returns a new array with the specified number of elements removed from the beginning. - [dropRepeats](https://massaman.dev/reference/array/dropRepeats.md): Removes consecutively repeated elements from an array using strict equality (===). - [dropRight](https://massaman.dev/reference/array/dropRight.md): Returns a new array with the specified number of elements removed from the end. - [dropRightWhile](https://massaman.dev/reference/array/dropRightWhile.md): Returns a new array with elements removed from the end while a condition is satisfied. - [dropWhile](https://massaman.dev/reference/array/dropWhile.md): Returns a new array with elements removed from the beginning while a condition is satisfied. - [fill](https://massaman.dev/reference/array/fill.md): Fills array elements with a specified value. - [filterAsync](https://massaman.dev/reference/array/filterAsync.md): Filters an array using an async predicate function and returns a new array containing only the elements that satisfy the condition. - [flatMap](https://massaman.dev/reference/array/flatMap.md): Transforms each element of an array with a function's return value, then flattens to a specified depth and returns a new array. - [flatMapAsync](https://massaman.dev/reference/array/flatMapAsync.md): Transforms each element in an array using an async function and flattens the result by one level to return a new array. - [flatMapDeep](https://massaman.dev/reference/array/flatMapDeep.md): Transforms each element of an array with a function's return value, then flattens all depths and returns a new array. - [flatten](https://massaman.dev/reference/array/flatten.md): Returns a new array that is flattened to the specified depth. - [flattenDeep](https://massaman.dev/reference/array/flattenDeep.md): Returns a new array with all depths of a nested array flattened. - [forEachAsync](https://massaman.dev/reference/array/forEachAsync.md): Executes an async function for each element in an array. - [forEachRight](https://massaman.dev/reference/array/forEachRight.md): Iterates over the elements of an array from right to left, executing a function for each element. - [groupBy](https://massaman.dev/reference/array/groupBy.md): Returns a new object with array elements grouped according to a key-generating function. - [head](https://massaman.dev/reference/array/head.md): Returns the first element of an array. - [initial](https://massaman.dev/reference/array/initial.md): Returns a new array containing all elements except the last one. - [intersection](https://massaman.dev/reference/array/intersection.md): Returns a new array containing elements that are commonly included in both arrays. - [intersectionBy](https://massaman.dev/reference/array/intersectionBy.md): Returns a new array containing the intersection of two arrays based on the result of a transformation function. - [intersectionWith](https://massaman.dev/reference/array/intersectionWith.md): Returns a new array containing the intersection of two arrays based on a custom comparison function. - [isSubset](https://massaman.dev/reference/array/isSubset.md): Checks if one array is a subset of another array. - [isSubsetWith](https://massaman.dev/reference/array/isSubsetWith.md): Checks if one array is a subset of another array based on a custom comparison function. - [keyBy](https://massaman.dev/reference/array/keyBy.md): Returns a new object with array elements converted to key-value pairs using a key-generating function. - [last](https://massaman.dev/reference/array/last.md): Returns the last element of an array. - [mapAsync](https://massaman.dev/reference/array/mapAsync.md): Transforms each element in an array using an async function and returns a new array. - [maxBy](https://massaman.dev/reference/array/maxBy.md): Returns the element with the maximum value from the array based on the value returned by the transformation function. - [minBy](https://massaman.dev/reference/array/minBy.md): Returns the element with the minimum value from the array based on the value returned by the transformation function. - [orderBy](https://massaman.dev/reference/array/orderBy.md): Returns a new array sorted by multiple criteria and sort directions. - [partition](https://massaman.dev/reference/array/partition.md): Returns a tuple that splits an array into two groups based on a condition. - [pull](https://massaman.dev/reference/array/pull.md): Removes all specified values from an array. - [pullAt](https://massaman.dev/reference/array/pullAt.md): Removes elements at specified indices from an array and returns the removed elements. - [reduceAsync](https://massaman.dev/reference/array/reduceAsync.md): Reduces an array to a single value using an async reducer function. - [reduceWhile](https://massaman.dev/reference/array/reduceWhile.md): Like reduce but stops early when the predicate returns false. - [remove](https://massaman.dev/reference/array/remove.md): Removes elements from an array based on a condition function and returns the removed elements in a new array. - [sample](https://massaman.dev/reference/array/sample.md): Returns a randomly selected element from an array. - [sampleSize](https://massaman.dev/reference/array/sampleSize.md): Returns a new array of randomly selected elements with the specified size. - [scan](https://massaman.dev/reference/array/scan.md): Like reduce but returns an array of all intermediate accumulator values. - [shuffle](https://massaman.dev/reference/array/shuffle.md): Returns a new array with the elements randomly shuffled. - [sortBy](https://massaman.dev/reference/array/sortBy.md): Returns a new array sorted in ascending order by the given criteria. - [sortWith](https://massaman.dev/reference/array/sortWith.md): Sorts an array using multiple comparators in priority order. - [tail](https://massaman.dev/reference/array/tail.md): Returns a new array consisting of all elements except the first. - [take](https://massaman.dev/reference/array/take.md): Creates a new array by taking the specified number of elements from the beginning of the array. - [takeRight](https://massaman.dev/reference/array/takeRight.md): Creates a new array by taking the specified number of elements from the end of the array. - [takeRightWhile](https://massaman.dev/reference/array/takeRightWhile.md): Returns a new array by taking elements from the end of the array while the condition function returns true. - [takeWhile](https://massaman.dev/reference/array/takeWhile.md): Creates a new array by taking elements from the beginning of the array while the condition function returns true. - [toFilled](https://massaman.dev/reference/array/toFilled.md): Creates a new array by filling part or all of it with the specified value. - [unfold](https://massaman.dev/reference/array/unfold.md): Builds an array from a seed value using an iterator function. - [union](https://massaman.dev/reference/array/union.md): Creates a new array containing all unique elements from two arrays. - [unionBy](https://massaman.dev/reference/array/unionBy.md): Creates a new array containing unique elements from two arrays based on values transformed by a specific function. - [unionWith](https://massaman.dev/reference/array/unionWith.md): Creates a new array containing unique elements from two arrays based on a custom equality function. - [uniq](https://massaman.dev/reference/array/uniq.md): Returns a new array with duplicate elements removed. - [uniqBy](https://massaman.dev/reference/array/uniqBy.md): Returns a new array with duplicate elements removed based on values returned by the transformation function. - [uniqWith](https://massaman.dev/reference/array/uniqWith.md): Returns a new array with duplicate elements removed using a comparison function. - [unzip](https://massaman.dev/reference/array/unzip.md): Unpacks grouped arrays and creates new arrays by gathering elements at the same position. - [unzipWith](https://massaman.dev/reference/array/unzipWith.md): Unpacks grouped arrays and applies a transformation function to return a new array. - [windowed](https://massaman.dev/reference/array/windowed.md): Returns a new array containing snapshots of each window as a window of specified size slides regularly along the array. - [without](https://massaman.dev/reference/array/without.md): Creates a new array excluding specific values from the array. - [xor](https://massaman.dev/reference/array/xor.md): Creates a new array with elements that exist in only one of two arrays. - [xorBy](https://massaman.dev/reference/array/xorBy.md): Creates a new array with elements that exist in only one of two arrays, based on values transformed by a given function. - [xorWith](https://massaman.dev/reference/array/xorWith.md): Creates a new array with elements that exist in only one of two arrays using a given comparison function. - [zip](https://massaman.dev/reference/array/zip.md): Creates an array of tuples by bundling elements at the same index from multiple arrays. - [zipObject](https://massaman.dev/reference/array/zipObject.md): Creates a single object from a keys array and a values array. - [zipWith](https://massaman.dev/reference/array/zipWith.md): Creates a new array by combining multiple arrays using a custom function. - [BigInt](https://massaman.dev/reference/bigint.md) - [clamp](https://massaman.dev/reference/bigint/clamp.md): Restricts a BigInt to a given range. - [inRange](https://massaman.dev/reference/bigint/inRange.md): Checks whether a BigInt falls within a range. - [max](https://massaman.dev/reference/bigint/max.md): Returns the largest BigInt in an array. - [maxBy](https://massaman.dev/reference/bigint/maxBy.md): Returns the element of an array whose derived BigInt value is the largest. - [median](https://massaman.dev/reference/bigint/median.md): Returns the middle value of an array of BigInts. - [medianBy](https://massaman.dev/reference/bigint/medianBy.md): Returns the middle of the BigInts that a function derives from each element of an array. - [min](https://massaman.dev/reference/bigint/min.md): Returns the smallest BigInt in an array. - [minBy](https://massaman.dev/reference/bigint/minBy.md): Returns the element of an array whose derived BigInt value is the smallest. - [percentile](https://massaman.dev/reference/bigint/percentile.md): Returns the BigInt at a given percentile of an array. - [range](https://massaman.dev/reference/bigint/range.md): Returns an array of BigInts counting from a start value up to, but not including, an end value. - [rangeRight](https://massaman.dev/reference/bigint/rangeRight.md): Returns the same BigInts as range, but in descending order. - [sum](https://massaman.dev/reference/bigint/sum.md): Returns the sum of all elements in an array of BigInts. - [sumBy](https://massaman.dev/reference/bigint/sumBy.md): Returns the sum of the BigInts that a function derives from each element of an array. - [Control](https://massaman.dev/reference/control.md) - [assert](https://massaman.dev/reference/control/assert.md): Asserts that a given condition is true. - [attempt](https://massaman.dev/reference/control/attempt.md): Executes a synchronous function and wraps the outcome in a Result, so callers can handle failure without try/catch. - [attemptAsync](https://massaman.dev/reference/control/attemptAsync.md): Executes an asynchronous function and wraps the outcome in a Result. - [err](https://massaman.dev/reference/control/err.md): Constructs a failure Result. - [invariant](https://massaman.dev/reference/control/invariant.md): Asserts that a given condition is true. - [isErr](https://massaman.dev/reference/control/isErr.md): Type guard that narrows a Result to Err. - [isOk](https://massaman.dev/reference/control/isOk.md): Type guard that narrows a Result to Ok. - [ok](https://massaman.dev/reference/control/ok.md): Constructs a success Result. - [todo](https://massaman.dev/reference/control/todo.md): Marks a code path you intend to implement later and throws if execution reaches it. - [unimplemented](https://massaman.dev/reference/control/unimplemented.md): Marks a code path as intentionally unsupported and throws if execution reaches it. - [unreachable](https://massaman.dev/reference/control/unreachable.md): Marks a code path as logically impossible and throws if execution reaches it. - [unwrap](https://massaman.dev/reference/control/unwrap.md): Extract the value from an Ok result, or throw on Err. - [Conversion](https://massaman.dev/reference/conversion.md) - [stringify](https://massaman.dev/reference/conversion/stringify.md): Produces a human-readable string from any unknown value. - [toArray](https://massaman.dev/reference/conversion/toArray.md): Converts a value to an array. - [toBoolean](https://massaman.dev/reference/conversion/toBoolean.md): Converts a value to a boolean. - [toError](https://massaman.dev/reference/conversion/toError.md): Coerces an unknown thrown value into a proper Error instance. - [toFinite](https://massaman.dev/reference/conversion/toFinite.md): Converts a value to a finite number. - [toInteger](https://massaman.dev/reference/conversion/toInteger.md): Converts a value to an integer by calling toNumber and truncating. - [toNumber](https://massaman.dev/reference/conversion/toNumber.md): Converts a value to a number. - [toString](https://massaman.dev/reference/conversion/toString.md): Converts a value to a string. - [Error](https://massaman.dev/reference/error.md) - [AbortError](https://massaman.dev/reference/error/AbortError.md): An error class representing an aborted or canceled operation. - [createError](https://massaman.dev/reference/error/createError.md): Creates a native Error with a typed name and custom data. - [defineError](https://massaman.dev/reference/error/defineError.md): Defines a callable error constructor from an object or a function. - [ErrorWith](https://massaman.dev/reference/error/ErrorWith.md): Describes a native Error with a literal name and readonly custom data. - [TimeoutError](https://massaman.dev/reference/error/TimeoutError.md): An error class representing an operation that has timed out. - [Function](https://massaman.dev/reference/function.md) - [after](https://massaman.dev/reference/function/after.md): Creates a new function that invokes the original function starting from the n-th call. - [ary](https://massaman.dev/reference/function/ary.md): Creates a new function that limits the number of arguments a function can accept. - [asyncNoop](https://massaman.dev/reference/function/asyncNoop.md): A function that asynchronously does nothing. - [before](https://massaman.dev/reference/function/before.md): Creates a new function that limits the number of times a function can be called. - [call](https://massaman.dev/reference/function/call.md): Invokes a function with the provided arguments and returns the result. - [callAsync](https://massaman.dev/reference/function/callAsync.md): Invokes a function returning a Promise with the provided arguments. - [curry](https://massaman.dev/reference/function/curry.md): Curries a function so it can be called with one argument at a time. - [curryRight](https://massaman.dev/reference/function/curryRight.md): Curries a function from right to left so it can be called with one argument at a time. - [debounce](https://massaman.dev/reference/function/debounce.md): Creates a debounced function that delays the invocation of a function. - [flow](https://massaman.dev/reference/function/flow.md): Creates a new function that executes multiple functions in sequence. - [flowAsync](https://massaman.dev/reference/function/flowAsync.md): Creates an async pipeline that awaits each step before passing the result to the next function. - [flowRight](https://massaman.dev/reference/function/flowRight.md): Creates a new function that executes the given functions in sequence from right to left. - [identity](https://massaman.dev/reference/function/identity.md): Returns the input value as is. - [ifElse](https://massaman.dev/reference/function/ifElse.md): Returns a function that branches between two functions based on a predicate. - [memoize](https://massaman.dev/reference/function/memoize.md): Caches function results so it runs faster when called again with the same arguments. - [negate](https://massaman.dev/reference/function/negate.md): Creates a new function that inverts the return value of a function that returns true or false. - [noop](https://massaman.dev/reference/function/noop.md): An empty function that does nothing. - [once](https://massaman.dev/reference/function/once.md): Creates a new function that limits a function to be executed only once. - [partial](https://massaman.dev/reference/function/partial.md): Creates a new function with some arguments pre-applied. - [partialRight](https://massaman.dev/reference/function/partialRight.md): Creates a new function with some parameters pre-applied from the right. - [rest](https://massaman.dev/reference/function/rest.md): Creates a new function that bundles parameters from a specific index into an array and passes them to the function. - [retry](https://massaman.dev/reference/function/retry.md): Retries a Promise-returning function until it succeeds. - [spread](https://massaman.dev/reference/function/spread.md): Creates a new function that spreads a parameter array into individual parameters of the function. - [tap](https://massaman.dev/reference/function/tap.md): Returns a function that runs a side-effect and returns the value unchanged. - [throttle](https://massaman.dev/reference/function/throttle.md): Limits a function to be executed at most once per specified time interval. - [unary](https://massaman.dev/reference/function/unary.md): Creates a new function that limits a function to accept only the first parameter. - [unless](https://massaman.dev/reference/function/unless.md): Returns a function that applies a transform only when a predicate fails, otherwise returns the value unchanged. - [when](https://massaman.dev/reference/function/when.md): Returns a function that applies a transform only when a predicate passes, otherwise returns the value unchanged. - [Functional](https://massaman.dev/reference/fp.md) - [add](https://massaman.dev/reference/fp/add.md): Creates a function that adds a number to its input. - [at](https://massaman.dev/reference/fp/at.md): Creates a function that returns the values at the given indices. - [cartesianProduct](https://massaman.dev/reference/fp/cartesianProduct.md): Creates a function that computes the Cartesian product with the piped array. - [chunk](https://massaman.dev/reference/fp/chunk.md): Creates a function that splits an array into sub-arrays of a given length. - [chunkBy](https://massaman.dev/reference/fp/chunkBy.md): Creates a function that splits adjacent values whenever a key changes. - [combinations](https://massaman.dev/reference/fp/combinations.md): Creates a function that returns combinations of a given size. - [compact](https://massaman.dev/reference/fp/compact.md): Creates a function that removes falsey values from an array. - [countBy](https://massaman.dev/reference/fp/countBy.md): Creates a function that counts values by a key. - [difference](https://massaman.dev/reference/fp/difference.md): Creates a function that excludes values found in another array. - [differenceBy](https://massaman.dev/reference/fp/differenceBy.md): Creates a function that excludes values by a mapped key. - [differenceWith](https://massaman.dev/reference/fp/differenceWith.md): Creates a function that excludes values using a custom equality function. - [drop](https://massaman.dev/reference/fp/drop.md): Creates a function that drops values from the beginning of an array. - [dropRight](https://massaman.dev/reference/fp/dropRight.md): Creates a function that drops values from the end of an array. - [dropRightWhile](https://massaman.dev/reference/fp/dropRightWhile.md): Creates a function that drops trailing values while a predicate passes. - [dropWhile](https://massaman.dev/reference/fp/dropWhile.md): Creates a function that drops leading values while a predicate passes. - [filter](https://massaman.dev/reference/fp/filter.md): Creates a function that keeps only the elements that pass a test, equivalent to Array.prototype.filter. - [find](https://massaman.dev/reference/fp/find.md): Creates a function that returns the first value that passes a test. - [findIndex](https://massaman.dev/reference/fp/findIndex.md): Creates a function that returns the index of the first value that passes a test. - [findLast](https://massaman.dev/reference/fp/findLast.md): Creates a function that returns the last value that passes a test. - [findLastIndex](https://massaman.dev/reference/fp/findLastIndex.md): Creates a function that returns the index of the last value that passes a test. - [flatMap](https://massaman.dev/reference/fp/flatMap.md): Creates a function that maps each value to an array and flattens the result by one level. - [flatMapDeep](https://massaman.dev/reference/fp/flatMapDeep.md): Creates a function that maps each value and deeply flattens the result. - [flatten](https://massaman.dev/reference/fp/flatten.md): Creates a function that flattens nested arrays to a given depth. - [flattenDeep](https://massaman.dev/reference/fp/flattenDeep.md): Creates a function that recursively flattens nested arrays. - [flow](https://massaman.dev/reference/fp/flow.md): Performs left-to-right function composition, returning a reusable function instead of running immediately. - [forEach](https://massaman.dev/reference/fp/forEach.md): Creates a function that runs a callback for each value and returns the input array. - [groupBy](https://massaman.dev/reference/fp/groupBy.md): Creates a function that groups values by a key. - [head](https://massaman.dev/reference/fp/head.md): Creates a function that returns the first value of an array. - [initial](https://massaman.dev/reference/fp/initial.md): Creates a function that returns all values except the last one. - [intersection](https://massaman.dev/reference/fp/intersection.md): Creates a function that keeps values found in another array. - [intersectionBy](https://massaman.dev/reference/fp/intersectionBy.md): Creates a function that keeps values by a mapped key. - [intersectionWith](https://massaman.dev/reference/fp/intersectionWith.md): Creates a function that keeps values using a custom equality function. - [isSubset](https://massaman.dev/reference/fp/isSubset.md): Creates a function that checks whether the piped array is a subset of another array. - [isSubsetWith](https://massaman.dev/reference/fp/isSubsetWith.md): Creates a function that checks subset membership using a custom equality function. - [join](https://massaman.dev/reference/fp/join.md): Creates a function that joins array values into a string. - [keyBy](https://massaman.dev/reference/fp/keyBy.md): Creates a function that builds an object keyed by each value. - [last](https://massaman.dev/reference/fp/last.md): Creates a function that returns the last value of an array. - [length](https://massaman.dev/reference/fp/length.md): Creates a function that returns the length of an array. - [map](https://massaman.dev/reference/fp/map.md): Creates a function that transforms every element of an array, equivalent to Array.prototype.map. - [maxBy](https://massaman.dev/reference/fp/maxBy.md): Creates a function that returns the value with the largest computed score. - [minBy](https://massaman.dev/reference/fp/minBy.md): Creates a function that returns the value with the smallest computed score. - [multiply](https://massaman.dev/reference/fp/multiply.md): Creates a function that multiplies its input by a number. - [omit](https://massaman.dev/reference/fp/omit.md): Creates a function that removes the given keys from an object. - [orderBy](https://massaman.dev/reference/fp/orderBy.md): Creates a function that sorts objects by criteria and sort orders. - [partition](https://massaman.dev/reference/fp/partition.md): Creates a function that splits values into passing and failing groups. - [pick](https://massaman.dev/reference/fp/pick.md): Creates a function that keeps only the given keys of an object. - [pipe](https://massaman.dev/reference/fp/pipe.md): Performs left-to-right function composition, threading a value through a sequence of functions. - [reverse](https://massaman.dev/reference/fp/reverse.md): Creates a function that returns a reversed copy of an array. - [sample](https://massaman.dev/reference/fp/sample.md): Creates a function that returns a random value from an array. - [sampleSize](https://massaman.dev/reference/fp/sampleSize.md): Creates a function that returns random values from an array. - [shuffle](https://massaman.dev/reference/fp/shuffle.md): Creates a function that returns a shuffled copy of an array. - [sortBy](https://massaman.dev/reference/fp/sortBy.md): Creates a function that sorts an array of objects in ascending order by one or more criteria. - [tail](https://massaman.dev/reference/fp/tail.md): Creates a function that returns all values except the first one. - [take](https://massaman.dev/reference/fp/take.md): Creates a function that returns the first count elements of an array. - [takeRight](https://massaman.dev/reference/fp/takeRight.md): Creates a function that returns values from the end of an array. - [takeRightWhile](https://massaman.dev/reference/fp/takeRightWhile.md): Creates a function that takes trailing values while a predicate passes. - [takeWhile](https://massaman.dev/reference/fp/takeWhile.md): Creates a function that takes leading values while a predicate passes. - [toFilled](https://massaman.dev/reference/fp/toFilled.md): Creates a function that returns a filled copy of an array. - [union](https://massaman.dev/reference/fp/union.md): Creates a function that combines two arrays without duplicate values. - [unionBy](https://massaman.dev/reference/fp/unionBy.md): Creates a function that combines arrays by a mapped key without duplicates. - [unionWith](https://massaman.dev/reference/fp/unionWith.md): Creates a function that combines arrays using a custom equality function. - [uniq](https://massaman.dev/reference/fp/uniq.md): Creates a function that removes duplicate values from an array. - [uniqBy](https://massaman.dev/reference/fp/uniqBy.md): Creates a function that removes duplicates by a mapped key. - [uniqWith](https://massaman.dev/reference/fp/uniqWith.md): Creates a function that removes duplicates using a custom equality function. - [unzip](https://massaman.dev/reference/fp/unzip.md): Creates a function that regroups zipped arrays by position. - [unzipWith](https://massaman.dev/reference/fp/unzipWith.md): Creates a function that regroups zipped arrays and combines each position. - [windowed](https://massaman.dev/reference/fp/windowed.md): Creates a function that returns sliding windows from an array. - [without](https://massaman.dev/reference/fp/without.md): Creates a function that removes specific values from an array. - [xor](https://massaman.dev/reference/fp/xor.md): Creates a function that returns values that appear in exactly one of two arrays. - [xorBy](https://massaman.dev/reference/fp/xorBy.md): Creates a function that returns the symmetric difference by a mapped key. - [xorWith](https://massaman.dev/reference/fp/xorWith.md): Creates a function that returns the symmetric difference using a custom equality function. - [zip](https://massaman.dev/reference/fp/zip.md): Creates a function that groups values from arrays by index. - [zipObject](https://massaman.dev/reference/fp/zipObject.md): Creates a function that builds an object from keys and values. - [zipWith](https://massaman.dev/reference/fp/zipWith.md): Creates a function that combines values from arrays by index. - [Math](https://massaman.dev/reference/math.md) - [clamp](https://massaman.dev/reference/math/clamp.md): Clamps a number within a specified range. - [inRange](https://massaman.dev/reference/math/inRange.md): Checks if a value is within a specified range. - [mean](https://massaman.dev/reference/math/mean.md): Calculates the average of an array of numbers. - [meanBy](https://massaman.dev/reference/math/meanBy.md): Calculates the average of an array by applying the getValue function to each element. - [median](https://massaman.dev/reference/math/median.md): Calculates the median of an array of numbers. - [medianBy](https://massaman.dev/reference/math/medianBy.md): Calculates the median of an array by applying the getValue function to each element. - [percentile](https://massaman.dev/reference/math/percentile.md): Calculates the value at the given percentile of an array of numbers. - [random](https://massaman.dev/reference/math/random.md): Generates a random number within a specified range. - [randomInt](https://massaman.dev/reference/math/randomInt.md): Generates a random integer within a specified range. - [range](https://massaman.dev/reference/math/range.md): Creates an array of numbers within a specified range and step. - [rangeRight](https://massaman.dev/reference/math/rangeRight.md): Creates an array of numbers in reverse order within a specified range and step. - [round](https://massaman.dev/reference/math/round.md): Rounds a number to a specified number of decimal places. - [sum](https://massaman.dev/reference/math/sum.md): Returns the sum of all elements in an array of numbers. - [sumBy](https://massaman.dev/reference/math/sumBy.md): Calculates the sum of array elements using a transformation function. - [Object](https://massaman.dev/reference/object.md) - [clone](https://massaman.dev/reference/object/clone.md): Creates a shallow copy of the given value. - [cloneDeep](https://massaman.dev/reference/object/cloneDeep.md): Creates a deep copy of the given value. - [cloneDeepWith](https://massaman.dev/reference/object/cloneDeepWith.md): Deeply clones the given value with a custom cloning function. - [deepFreeze](https://massaman.dev/reference/object/deepFreeze.md): Recursively freezes an object, making it and all nested objects and arrays immutable. - [evolve](https://massaman.dev/reference/object/evolve.md): Applies a spec of transformation functions to matching keys of an object, returning a new object. - [findKey](https://massaman.dev/reference/object/findKey.md): Finds the key of the first element that satisfies the given condition. - [flattenObject](https://massaman.dev/reference/object/flattenObject.md): Converts a nested object into a flat object. - [invert](https://massaman.dev/reference/object/invert.md): Creates a new object with keys and values swapped. - [mapKeys](https://massaman.dev/reference/object/mapKeys.md): Returns a new object with keys transformed through a function. - [mapKeysAsync](https://massaman.dev/reference/object/mapKeysAsync.md): Returns a new object with keys transformed through an async function. - [mapValues](https://massaman.dev/reference/object/mapValues.md): Returns a new object with values transformed through a function. - [mapValuesAsync](https://massaman.dev/reference/object/mapValuesAsync.md): Returns a new object with values transformed through an async function. - [merge](https://massaman.dev/reference/object/merge.md): Deeply merges the source object into the target object, modifying the target object. - [mergeWith](https://massaman.dev/reference/object/mergeWith.md): Deeply merges the source object into the target object using a custom merge function, modifying the target object. - [omit](https://massaman.dev/reference/object/omit.md): Returns a new object excluding the specified keys. - [omitBy](https://massaman.dev/reference/object/omitBy.md): Returns a new object containing only the properties that do not satisfy the condition function. - [pick](https://massaman.dev/reference/object/pick.md): Returns a new object containing only the properties corresponding to the specified keys. - [pickBy](https://massaman.dev/reference/object/pickBy.md): Returns a new object containing only the properties that satisfy the condition function. - [sortKeys](https://massaman.dev/reference/object/sortKeys.md): Creates a new object with the keys sorted. - [toCamelCaseKeys](https://massaman.dev/reference/object/toCamelCaseKeys.md): Returns a new object with all keys in objects and arrays converted to camelCase. - [toConstantCaseKeys](https://massaman.dev/reference/object/toConstantCaseKeys.md): Returns a new object with all keys in objects and arrays converted to CONSTANTCASE. - [toKebabCaseKeys](https://massaman.dev/reference/object/toKebabCaseKeys.md): Returns a new object with all keys in objects and arrays converted to kebab-case. - [toMerged](https://massaman.dev/reference/object/toMerged.md): Returns a new object with the source object deeply merged into a copy of the target object. - [toPascalCaseKeys](https://massaman.dev/reference/object/toPascalCaseKeys.md): Returns a new object with all keys in objects and arrays converted to PascalCase. - [toSnakeCaseKeys](https://massaman.dev/reference/object/toSnakeCaseKeys.md): Returns a new object with all keys in objects and arrays converted to snakecase. - [Pattern](https://massaman.dev/reference/match.md) - [isMatching](https://massaman.dev/reference/match/isMatching.md): A predicate form of match — returns true/false instead of a value, and narrows types in the truthy branch. - [match](https://massaman.dev/reference/match/match.md): Exhaustive, type-safe pattern matching for TypeScript. - [NonExhaustiveError](https://massaman.dev/reference/match/NonExhaustiveError.md): The runtime error thrown by .exhaustive() when a value reaches it that no pattern matched. - [P](https://massaman.dev/reference/match/P.md): The pattern primitives namespace. - [Pattern](https://massaman.dev/reference/match/Pattern.md): The type-level representation of a pattern. - [Predicate](https://massaman.dev/reference/predicate.md) - [allPass](https://massaman.dev/reference/predicate/allPass.md): Returns a predicate that checks if a value satisfies ALL predicates. - [anyPass](https://massaman.dev/reference/predicate/anyPass.md): Returns a predicate that checks if a value satisfies ANY predicate. - [both](https://massaman.dev/reference/predicate/both.md): Returns a predicate that checks if a value satisfies both predicates. - [either](https://massaman.dev/reference/predicate/either.md): Returns a predicate that checks if a value satisfies either predicate. - [isArray](https://massaman.dev/reference/predicate/isArray.md): Checks if a value is an array. - [isArrayBuffer](https://massaman.dev/reference/predicate/isArrayBuffer.md): Checks if a value is an ArrayBuffer instance. - [isBlob](https://massaman.dev/reference/predicate/isBlob.md): Checks if a value is a Blob instance. - [isBoolean](https://massaman.dev/reference/predicate/isBoolean.md): Checks if a value is a boolean type. - [isBrowser](https://massaman.dev/reference/predicate/isBrowser.md): Checks if the current execution environment is a browser. - [isBuffer](https://massaman.dev/reference/predicate/isBuffer.md): Checks if a value is a Buffer instance. - [isDate](https://massaman.dev/reference/predicate/isDate.md): Checks if a value is a Date object. - [isEmpty](https://massaman.dev/reference/predicate/isEmpty.md): Checks if a value is empty. - [isEmptyObject](https://massaman.dev/reference/predicate/isEmptyObject.md): Checks if a plain object has no properties ({}). - [isEqual](https://massaman.dev/reference/predicate/isEqual.md): Performs a deep comparison to check if two values are equal. - [isEqualWith](https://massaman.dev/reference/predicate/isEqualWith.md): Checks if two values are equal using a custom comparison function. - [isError](https://massaman.dev/reference/predicate/isError.md): Checks if a value is an Error object. - [isFile](https://massaman.dev/reference/predicate/isFile.md): Checks if a value is a File object. - [isFiniteNumber](https://massaman.dev/reference/predicate/isFiniteNumber.md): Checks if a value is a finite number. - [isFunction](https://massaman.dev/reference/predicate/isFunction.md): Checks if a value is a function. - [isInteger](https://massaman.dev/reference/predicate/isInteger.md): Checks if a value is an integer. - [isIterable](https://massaman.dev/reference/predicate/isIterable.md): Checks if a value is iterable. - [isJSON](https://massaman.dev/reference/predicate/isJSON.md): Checks if a value is a valid JSON string. - [isJSONArray](https://massaman.dev/reference/predicate/isJSONArray.md): Checks if a value is a valid JSON array. - [isJSONObject](https://massaman.dev/reference/predicate/isJSONObject.md): Checks if a value is a valid JSON object. - [isJSONValue](https://massaman.dev/reference/predicate/isJSONValue.md): Checks if a value is a valid JSON value. - [isLength](https://massaman.dev/reference/predicate/isLength.md): Checks if a value is a valid array length. - [isMap](https://massaman.dev/reference/predicate/isMap.md): Checks if a value is a Map. - [isNaN](https://massaman.dev/reference/predicate/isNaN.md): Checks if a value is NaN. - [isNil](https://massaman.dev/reference/predicate/isNil.md): Checks if a value is null or undefined. - [isNode](https://massaman.dev/reference/predicate/isNode.md): Checks if the current runtime environment is Node.js. - [isNotEmpty](https://massaman.dev/reference/predicate/isNotEmpty.md): Checks if a value is not empty. - [isNotNil](https://massaman.dev/reference/predicate/isNotNil.md): Checks if a value is neither null nor undefined. - [isNull](https://massaman.dev/reference/predicate/isNull.md): Checks if a value is null. - [isNumber](https://massaman.dev/reference/predicate/isNumber.md): Checks if a value is a number type. - [isObject](https://massaman.dev/reference/predicate/isObject.md): Checks if a value is a non-null object. - [isPlainObject](https://massaman.dev/reference/predicate/isPlainObject.md): Checks if a value is a plain object. - [isPrimitive](https://massaman.dev/reference/predicate/isPrimitive.md): Checks if a given value is a JavaScript primitive. - [isPromise](https://massaman.dev/reference/predicate/isPromise.md): Checks if a given value is a Promise instance. - [isRegExp](https://massaman.dev/reference/predicate/isRegExp.md): Checks if a given value is a RegExp instance. - [isSet](https://massaman.dev/reference/predicate/isSet.md): Checks if a given value is a Set instance. - [isString](https://massaman.dev/reference/predicate/isString.md): Checks if a given value is a string. - [isSymbol](https://massaman.dev/reference/predicate/isSymbol.md): Checks if a given value is a symbol. - [isTypedArray](https://massaman.dev/reference/predicate/isTypedArray.md): Checks if a given value is a TypedArray instance. - [isUndefined](https://massaman.dev/reference/predicate/isUndefined.md): Checks if a given value is undefined. - [isWeakMap](https://massaman.dev/reference/predicate/isWeakMap.md): Checks if a given value is a WeakMap instance. - [isWeakSet](https://massaman.dev/reference/predicate/isWeakSet.md): Checks if a given value is a WeakSet instance. - [Promise](https://massaman.dev/reference/promise.md) - [allKeyed](https://massaman.dev/reference/promise/allKeyed.md): Resolves an object of promises concurrently, returning an object with the same keys and resolved values. - [delay](https://massaman.dev/reference/promise/delay.md): Delays code execution for a specified amount of time. - [limitAsync](https://massaman.dev/reference/promise/limitAsync.md): Creates a new function that limits the maximum number of concurrent executions of an async function. - [Mutex](https://massaman.dev/reference/promise/Mutex.md): Ensures that multiple asynchronous tasks do not execute simultaneously. - [Semaphore](https://massaman.dev/reference/promise/Semaphore.md): Limits the number of asynchronous tasks that can execute simultaneously. - [timeout](https://massaman.dev/reference/promise/timeout.md): Returns a Promise that throws a TimeoutError after the specified time. - [withTimeout](https://massaman.dev/reference/promise/withTimeout.md): Sets a time limit on an asynchronous function, throwing a TimeoutError if it doesn't complete within the specified time. - [String](https://massaman.dev/reference/string.md) - [camelCase](https://massaman.dev/reference/string/camelCase.md): Converts a string to camel case. - [capitalize](https://massaman.dev/reference/string/capitalize.md): Converts the first character of a string to uppercase and the remaining characters to lowercase. - [constantCase](https://massaman.dev/reference/string/constantCase.md): Converts a string to constant case. - [deburr](https://massaman.dev/reference/string/deburr.md): Converts special characters and diacritics to ASCII characters. - [dedent](https://massaman.dev/reference/string/dedent.md): Removes the common leading whitespace from every line of a multi-line string. - [escape](https://massaman.dev/reference/string/escape.md): Converts characters with special meaning in HTML to safe entities. - [escapeRegExp](https://massaman.dev/reference/string/escapeRegExp.md): Escapes characters with special meaning in regular expressions to literal characters. - [kebabCase](https://massaman.dev/reference/string/kebabCase.md): Converts a string to kebab case. - [lowerCase](https://massaman.dev/reference/string/lowerCase.md): Converts a string to lower case format. - [lowerFirst](https://massaman.dev/reference/string/lowerFirst.md): Converts the first character of a string to lowercase. - [pad](https://massaman.dev/reference/string/pad.md): Pads a string on both sides to reach a specified length. - [pascalCase](https://massaman.dev/reference/string/pascalCase.md): Converts a string to pascal case. - [reverseString](https://massaman.dev/reference/string/reverseString.md): Reverses a string. - [snakeCase](https://massaman.dev/reference/string/snakeCase.md): Converts a string to snake case. - [startCase](https://massaman.dev/reference/string/startCase.md): Converts the first letter of each word in a string to uppercase. - [trim](https://massaman.dev/reference/string/trim.md): Removes whitespace or specified characters from the beginning and end of a string. - [trimEnd](https://massaman.dev/reference/string/trimEnd.md): Removes whitespace or specified characters from the end of a string. - [trimStart](https://massaman.dev/reference/string/trimStart.md): Removes whitespace or specified characters from the start of a string. - [unescape](https://massaman.dev/reference/string/unescape.md): Converts HTML entity characters to their original characters. - [upperCase](https://massaman.dev/reference/string/upperCase.md): Converts a string to a format where all letters are uppercase and words are separated by spaces. - [upperFirst](https://massaman.dev/reference/string/upperFirst.md): Converts the first character of a string to uppercase. - [words](https://massaman.dev/reference/string/words.md): Splits a string into an array of words. ## Others - [Installation](https://massaman.dev/installation.md) - [massaman](https://massaman.dev/overview.md): Functional programming utilities for TypeScript. Rust's match and Result in TypeScript, layered over es-toolkit and ts-pattern.