@es-toolkit/es-toolkit@1.23.0Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
A modern JavaScript utility library that's 2-3 times faster and up to 97% smaller—a major upgrade to lodash.
es-toolkit compatibility layer with lodash (WIP)
// es-toolkit/compat aims to provide 100% feature parity with lodash import { chunk } from 'es-toolkit/compat'; chunk([1, 2, 3, 4], 0); // Returns [], which is identical to lodash
es-toolkit/compat
will offer complete compatibility with lodash, ensuring a seamless transition.
To guarantee identical behavior, es-toolkit/compat
will be thoroughly tested using actual lodash test cases.
The primary goal of es-toolkit/compat
is to serve as a drop-in replacement for lodash.
It's important to note that while es-toolkit/compat
will mirror the behavior of lodash functions with 100% accuracy,
it will deliberately omit unsafe features, such as:
- Implicit type casting from an empty string
''
to 0 or false, and similar cases.
An error class representing an aborted operation.
An error class representing an timeout operation.
Creates a function that only executes starting from the n
-th call.The provided function will be invoked starting from the n
-th call.
Creates a function that invokes func, with up to n
arguments, ignoring any additional arguments.
Retrieves elements from an array at the specified indices.
Attempts to execute a function with the provided arguments.If the function throws an error, it catches the error and returns it.If the caught error is not an instance of Error, it wraps it in a new Error.
Creates a function that limits the number of times the given function (func
) can be called.
Creates a function that invokes func
with the this
binding of thisArg
and partials
prepended to the arguments it receives.
Creates a function that invokes the method at object[key]
with partialArgs
prepended to the arguments it receives.
Converts a string to camel case.
Converts the first character of string to upper case and the remaining to lower case.
Casts value as an array if it's not one.
Computes number rounded up to precision.
Splits an array into smaller arrays of a specified length.
Clamps a number within the inclusive upper bound.
Creates a shallow clone of the given object.
Creates a deep clone of the given object.
Removes falsey values (false, null, 0, 0n, '', undefined, NaN) from an array.
Concatenates multiple arrays and values into a single array.
Creates a function that invokes the predicate properties of source
with the corresponding property values of a given object, returning true
if all predicates return truthy, else false
.
Checks if object
conforms to source
by invoking the predicate properties of source
with the corresponding property values of object
.
Converts a string to constant case.
Count the occurrences of each item in an arraybased on a transformation function.
Creates a function that accepts arguments of func
and either invokes func
returning its result, if at least arity
number of arguments have been provided, or returns a function that accepts the remaining func
arguments, and so on.The arity of func
may be specified if func.length
is not sufficient.
Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument.This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments.
Creates a debounced function that delays invoking the provided function until after debounceMs
millisecondshave elapsed since the last time the debounced function was invoked. The debounced function also has a cancel
method to cancel any pending execution.
Converts a string by replacing special characters and diacritical marks with their ASCII equivalents.For example, "Crème brûlée" becomes "Creme brulee".
Defers invoking the func
until the current call stack has cleared. Any additional arguments are provided to func when it's invoked.
Delays the execution of code for a specified number of milliseconds.
Computes the difference between an array and multiple arrays.
Computes the difference between two arrays after mapping their elements through a provided function.
Computes the difference between two arrays based on a custom equality function.
Removes a specified number of elements from the beginning of an array and returns the rest.
Removes a specified number of elements from the end of an array and returns the rest.
Removes elements from the end of an array until the predicate returns false.
Drops elements from the beginning of an array while the predicate function returns truthy.
Checks if a string contains another string at the end of the string.
Converts the characters "&", "<", ">", '"', and "'" in str
to their corresponding HTML entities.For example, "<" becomes "<".
Escapes the RegExp special characters "^", "$", "\", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", and "|" in str
.
Checks if all elements in an array are truthy.
Fills the whole array with a specified value.
Filters items from a array and returns an array of elements.
Finds the first item in an array that matches the given predicate function.
Finds the index of the first item in an array that matches the given predicate function.
Iterates through an array in reverse order and returns the index of the first item that matches the given predicate function.
Returns the first element of an array.
Maps each element in the array using the iteratee function and flattens the result up to the specified depth.
Recursively maps each element in an array using a provided iteratee function and then deeply flattens the resulting array.
Flattens an array up to the specified depth.
Flattens all depths of a nested array.
Flattens an array up to the specified depth.
Flattens a nested object into a single level object with dot-separated keys.
Reverses the order of arguments for a given function.
Computes number rounded down to precision.
Creates a new function that executes the given functions in sequence. The return value of the previous function is passed as an argument to the next function.
Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.
Iterates over elements of 'arr' from right to left and invokes 'callback' for each element.
Converts an array of key-value pairs into an object.
Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
Groups the elements of an array based on a provided key-generating function.
Checks if a given path exists within an object.
Returns the first element of an array.
Checks if an item is included in an array.
Finds the index of the first occurrence of a value in an array.
Returns an empty array when the input is a tuple containing exactly one element.
Checks if the value is less than the maximum.
Returns the intersection of two arrays.
Returns the intersection of two arrays based on a mapping function.
Returns the intersection of two arrays based on a custom equality function.
Inverts the keys and values of an object. The keys of the input object become the values of the output object and vice versa.
Checks if the given value is an arguments object.
Checks if the given value is an array.
Checks if a given value is ArrayBuffer
.
Checks if value
is array-like.
Checks if the given value is a non-primitive, array-like object.
Checks if the given value is boolean.
Checks if value
is a Date object.
Checks if two values are equal, including support for Date
, RegExp
, and deep object comparison.
Compares two values for equality using a custom comparison function.
Checks if value
is an Error object.
Checks if value
is a finite number.
Checks if value
is a function.
Checks if value
is an integer.
Checks if a given value is a valid JSON array.
Checks if a value is a JSON object.
Checks if a given value is a valid JSON value.
Checks if a given value is a valid length.
Checks if a given value is Map
.
Checks if the target matches the source by comparing their structures and values.This function supports deep comparison for objects, arrays, maps, and sets.
Checks if the value is NaN.
Checks if a given value is null or undefined.
Checks if the given value is not null nor undefined.
Checks if the given value is null.
Checks if a given value is a number.
Checks if the given value is an object. An object is a value that isnot a primitive type (string, number, boolean, symbol, null, or undefined).
Checks if the given value is object-like.
Checks if a given value is a plain object.
Checks whether a value is a JavaScript primitive.JavaScript primitives include null, undefined, strings, numbers, booleans, symbols, and bigints.
Checks if value
is a RegExp.
Checks if value
is a safe integer (between -(253 – 1) and (253 – 1), inclusive).
Checks if a given value is Set
.
Checks if a given value is string.
Checks if the subset
array is entirely contained within the superset
array.
Check whether a value is a symbol.
Checks if a value is a TypedArray.
Checks if the given value is undefined.
Checks if the given value is a WeakMap
.
Checks if the given value is a WeakSet
.
Joins elements of an array into a string.
Converts a string to kebab case.
Maps each element of an array based on a provided key-generating function.
Returns the last element of an array.
Converts a string to lower case.
Converts the first character of string to lower case.
Creates a new object with the same values as the given object, but with keys generatedby running each own enumerable property of the object through the iteratee function.
Creates a new object with the same keys as the given object, but with values generatedby running each own enumerable property of the object through the iteratee function.
Creates a function that performs a deep comparison between a given target and the source object.
Creates a function that checks if a given target object matches a specific property value.
Finds the element in an array that has the maximum value.
Finds the element in an array that has the maximum value when applyingthe getValue
function to each element.
Calculates the average of an array of numbers.
Calculates the average of an array of numbers when applyingthe getValue
function to each element.
Creates a memoized version of the provided function. The memoized function cachesresults based on the argument it receives, so if the same argument is passed again,it returns the cached result instead of recomputing it.
Merges the properties of one or more source objects into the target object.
Merges the properties of one or more source objects into the target object.
Finds the element in an array that has the minimum value.
Finds the element in an array that has the minimum value when applyingthe getValue
function to each element.
Creates a function that negates the result of the predicate function.
A no-operation function that does nothing.This can be used as a placeholder or default function.
Creates a new object with specified keys omitted.
Creates a new object composed of the properties that do not satisfy the predicate function.
Creates a function that is restricted to invoking the provided function func
once.Repeated calls to the function will return the value from the first invocation.
Sorts an array of objects based on multiple properties and their corresponding order directions.
Pads string on the left and right sides if it's shorter than length. Padding characters are truncated if they can't be evenly divided by length.If the length is less than or equal to the original string's length, or if the padding character is an empty string, the original string is returned unchanged.
Pads the end of a string with a given character until it reaches the specified length.
Pads the start of a string with a given character until it reaches the specified length.
Converts string
to an integer of the specified radix. If radix
is undefined or 0, a radix
of 10 is used unless string
is a hexadecimal, in which case a radix
of 16 is used.
Creates a function that invokes func
with partialArgs
prepended to the arguments it receives. This method is like bind
except it does not alter the this
binding.
This method is like partial
except that partially applied arguments are appended to the arguments it receives.
Splits an array into two groups based on a predicate function.
Converts a string to Pascal case.
Creates a new object composed of the picked object properties.
Creates a new object composed of the properties that satisfy the predicate function.
Creates a function that returns the value at a given path of an object.
Removes elements from an array at specified indices and returns the removed elements.
Generate a random number within 0 and 1.
Generates a random integer between 0 (inclusive) and the given maximum (exclusive).
Returns an array of numbers from 0
(inclusive) to end
(exclusive), incrementing by 1
.
Creates a function that invokes func
with arguments arranged according to the specified indices
where the argument value at the first index is provided as the first argument,the argument value at the second index is provided as the second argument, and so on.
Repeats the given string n times.
Creates a function that transforms the arguments of the provided function func
.The transformed arguments are passed to func
such that the arguments starting from a specified indexare grouped into an array, while the previous arguments are passed as individual elements.
Computes number rounded to precision.
Returns a random element from an array.
Returns a sample element array of a specified size
.
Sets the value at the specified path of the given object. If any part of the path does not exist, it will be created.
Randomizes the order of elements in an array using the Fisher-Yates algorithm.
Returns the length of an array, string, or object.
Converts a string to snake case.
Checks if there is an element in an array that is truthy.
Sorts an array of objects based on multiple properties and their corresponding order directions.
Creates a new function that spreads elements of an array argument into individual argumentsfor the original function. The array argument is positioned based on the argsIndex
parameter.
Converts the first character of each word in a string to uppercase and the remaining characters to lowercase.
Checks if a string contains another string at the beginning of the string.
Calculates the sum of an array of numbers.
Calculates the sum of an array of numbers when applyingthe getValue
function to each element.
Returns an empty array when the input is a single-element array.
Returns a new array containing the first count
elements from the input array arr
.If count
is greater than the length of arr
, the entire array is returned.
Returns a new array containing the last count
elements from the input array arr
.If count
is greater than the length of arr
, the entire array is returned.
Takes elements from the end of the array while the predicate function returns true
.
Returns a new array containing the leading elements of the provided arraythat satisfy the provided predicate function. It stops taking elements as soonas an element does not satisfy the predicate.
Creates a throttled function that only invokes the provided function at most onceper every throttleMs
milliseconds. Subsequent calls to the throttled functionwithin the wait time will not trigger the execution of the original function.
Returns a promise that rejects with a TimeoutError
after a specified delay.
Creates a new array filled with the specified value from the start position up to, but not including, the end position.This function does not mutate the original array.
Converts value
to a finite number.
Converts value
to an integer.
Merges the properties of the source object into a deep clone of the target object.Unlike merge
, This function does not modify the original target object.
Converts value
to a number.
Converts a deep key string into an array of path segments.
Converts value
to a string.
Removes leading and trailing whitespace or specified characters from a string.
Removes trailing whitespace or specified characters from a string.
Removes leading whitespace or specified characters from a string.
Creates a function that accepts up to one argument, ignoring any additional arguments.
Converts the HTML entities &
, <
, >
, "
, and '
in str
to their corresponding characters.It is the inverse of escape
.
Creates an array of unique values from all given arrays.
Creates an array of unique values, in order, from all given arrays using a provided mapping function to determine equality.
Creates an array of unique values from two given arrays based on a custom equality function.
Creates a duplicate-free version of an array.
Returns a new array containing only the unique elements from the original array,based on the values returned by the mapper function.
Returns a new array containing only the unique elements from the original array,based on the values returned by the comparator function.
Removes the property at the given path of the object.
Gathers elements in the same position in an internal arrayfrom a grouped array of elements and returns them as a new array.
Unzips an array of arrays, applying an iteratee
function to regrouped elements.
Converts a string to upper case.
Converts the first character of string to upper case.
Creates an array that excludes all specified values.
Executes an async function and enforces a timeout.
Computes the symmetric difference between two arrays. The symmetric difference is the set of elementswhich are in either of the arrays, but not in their intersection.
Computes the symmetric difference between two arrays using a custom mapping function.The symmetric difference is the set of elements which are in either of the arrays,but not in their intersection, determined by the result of the mapping function.
Computes the symmetric difference between two arrays using a custom equality function.The symmetric difference is the set of elements which are in either of the arrays,but not in their intersection.
Combines multiple arrays into a single array of tuples.
Combines two arrays, one of property names and one of corresponding values, into a single object.
Creates a deeply nested object given arrays of paths and values.
Combines multiple arrays into a single array using a custom combiner function.
Represents a cache for memoization, allowing storage and retrieval of computed values.
Add Package
deno add jsr:@es-toolkit/es-toolkit
Import symbol
import * as mod from "@es-toolkit/es-toolkit/compat";
---- OR ----
Import directly with a jsr specifier
import * as mod from "jsr:@es-toolkit/es-toolkit/compat";
Add Package
npx jsr add @es-toolkit/es-toolkit
Import symbol
import * as mod from "@es-toolkit/es-toolkit/compat";
Add Package
yarn dlx jsr add @es-toolkit/es-toolkit
Import symbol
import * as mod from "@es-toolkit/es-toolkit/compat";
Add Package
pnpm dlx jsr add @es-toolkit/es-toolkit
Import symbol
import * as mod from "@es-toolkit/es-toolkit/compat";
Add Package
bunx jsr add @es-toolkit/es-toolkit
Import symbol
import * as mod from "@es-toolkit/es-toolkit/compat";