This page is generated from the following source files:
es-toolkit is a state-of-the-art, high-performance JavaScript utility library designed for modern web development. The project emphasizes small bundle sizes, strong TypeScript annotations, and exceptional runtime performance. According to the project documentation, es-toolkit achieves 2-3× better performance compared to alternative libraries while reducing JavaScript bundle size by up to 97% through effective tree shaking support (README.md:1-41).
The library serves as a modern replacement for traditional utility libraries, offering a comprehensive set of everyday utility functions including debounce, delay, chunk, sum, and pick. It provides a complete compatibility layer for seamless lodash migration through the es-toolkit/compat entry point. The project is trusted by major open-source projects including Storybook, Recharts, ink, and CKEditor, demonstrating its production readiness and reliability (README.md:1-16).
The following table summarizes the core technical characteristics of es-toolkit:
| Attribute | Value |
|---|---|
| Package Name | es-toolkit |
| Current Version | 1.45.1 |
| License | MIT |
| Package Manager | Yarn 4.12.0 |
| Side Effects | false (tree-shakeable) |
| Homepage | https://es-toolkit.dev |
| Repository | https://github.com/toss/es-toolkit.git |
The library is built with modern JavaScript development practices, featuring zero side effects for optimal tree shaking, comprehensive TypeScript support, and dual ESM/CommonJS module formats. The package configuration includes extensive export maps supporting both development source files and production builds (package.json:14-29).
es-toolkit implements a modular architecture that allows developers to import utilities either from the main entry point or from specialized sub-modules. This design enables efficient tree shaking and reduces bundle size by only including necessary functions.
正在加载图表渲染器...
The main entry point at src/index.ts exports all core modules, providing a unified API surface for common use cases. The architecture separates concerns into distinct modules: array operations, function utilities, object manipulation, promise helpers, type predicates, mathematical functions, string utilities, and general utilities (src/index.ts:57-65).
The package.json configuration defines granular export paths for each module category:
| Import Path | Purpose | Source Location |
|---|---|---|
es-toolkit | Main entry with all utilities | ./src/index.ts |
es-toolkit/array | Array manipulation functions | ./src/array/index.ts |
es-toolkit/compat | Lodash compatibility layer | ./src/compat/index.ts |
es-toolkit/function | Function utilities | ./src/function/index.ts |
es-toolkit/object | Object manipulation | ./src/object/index.ts |
es-toolkit/promise | Promise and async utilities | ./src/promise/index.ts |
es-toolkit/predicate | Type guards and predicates | ./src/predicate/index.ts |
This modular structure enables developers to import only the specific category of utilities needed, further optimizing bundle size. For example, importing only array functions via import { chunk } from 'es-toolkit/array' ensures that unrelated modules are not included in the final bundle.
The es-toolkit/compat module provides a comprehensive compatibility layer for projects migrating from lodash. This layer implements lodash-compatible function signatures and behaviors while maintaining the performance benefits of es-toolkit's modern implementations. The compatibility module re-exports selected functions from core modules and adds additional wrapper functions to match lodash's API exactly (package.json:17).
es-toolkit provides a comprehensive set of utility functions organized across multiple categories:
(README.md:9-14, CHANGELOG.md:300-341)
The following diagram illustrates the typical data flow when using es-toolkit utilities, showing how user code interacts with the library's modular structure:
正在加载图表渲染器...
This architecture ensures that core implementations remain focused and performant, while the compatibility layer handles API translation when needed. The separation allows the library to maintain both modern best practices and backward compatibility.
The array module implements several key functions with careful attention to edge cases and performance. For example, the nth function retrieves elements at a given index, supporting negative indices for accessing elements from the end of the array:
typescript1export function nth<T>(array: ArrayLike<T> | null | undefined, n = 0): T | undefined { 2 if (!isArrayLikeObject(array) || array.length === 0) { 3 return undefined; 4 } 5 6 n = toInteger(n); 7 8 if (n < 0) { 9 n += array.length; 10 } 11 12 return array[n]; 13}
(src/compat/array/nth.ts:15-27)
The function handles null/undefined inputs by returning undefined, converts the index to an integer, and supports negative indexing by adding the negative offset to the array length. This implementation matches lodash behavior while maintaining type safety.
The zip function demonstrates sophisticated TypeScript usage with multiple overload signatures to provide precise type inference for different numbers of input arrays:
typescript1export function zip<T, U>(arr1: ArrayLike<T>, arr2: ArrayLike<U>): Array<[T | undefined, U | undefined]>; 2 3export function zip<T, U, V>( 4 arr1: ArrayLike<T>, 5 arr2: ArrayLike<U>, 6 arr3: ArrayLike<V> 7): Array<[T | undefined, U | undefined, V | undefined]>;
(src/compat/array/zip.ts:36-77)
Each overload preserves the type information of input arrays in the output tuple type, with undefined included to handle arrays of different lengths. The implementation accepts ArrayLike<T> rather than just T[], supporting array-like objects such as the arguments object or NodeLists.
es-toolkit maintains an active release cycle with frequent updates adding new features, improving compatibility, and fixing bugs. The changelog demonstrates continuous evolution since initial release.
| Version | Release Date | Key Changes |
|---|---|---|
| v1.45.1 | March 4, 2026 | Reverted sample return type, fixed Deno install command |
| v1.45.0 | March 2, 2026 | Fixed findIndex, sample, cloneDeep, retry functions |
| v1.44.0 | February 2026 | Enhanced compatibility, performance improvements |
| v1.33.0 | March 9, 2025 | Added reverseString, isJSON, pullAllBy functions |
The project has evolved significantly, with major additions including:
pullThe changelog acknowledges numerous community contributors, indicating healthy open-source engagement. Contributors have implemented new functions, fixed bugs, improved TypeScript types, and enhanced documentation. The project maintains 100% test coverage, ensuring reliability across all utility functions (README.md:15).
The library provides a straightforward API designed for immediate productivity. Common operations require minimal boilerplate:
typescript1// Import from main entry point 2import { chunk, debounce } from 'es-toolkit'; 3 4// Debounce function calls 5const debouncedLog = debounce(message => { 6 console.log(message); 7}, 300); 8 9// This call will be debounced 10debouncedLog('Hello, world!'); 11 12// Chunk arrays into smaller pieces 13const array = [1, 2, 3, 4, 5, 6]; 14const chunkedArray = chunk(array, 2); 15 16console.log(chunkedArray); 17// Output: [[1, 2], [3, 4], [5, 6]]
For Deno users, the library is available through JSR (JavaScript Registry) at @es-toolkit/es-toolkit, providing the same API with Deno-native imports (README.md:20).
When migrating from lodash, developers can use the compatibility layer to minimize code changes:
typescript1// Lodash-style imports work with compat layer 2import { map, find, filter } from 'es-toolkit/compat'; 3 4// Functions behave identically to lodash equivalents 5const result = map([1, 2, 3], n => n * 2); 6// result: [2, 4, 6]
The compatibility layer ensures that function signatures, edge case handling, and return values match lodash behavior, enabling drop-in replacement for most use cases.
es-toolkit maintains rigorous quality standards through comprehensive testing. The test suite uses Vitest as the testing framework, with tests colocated with implementation files using the .spec.ts convention.
The unzipWith function tests demonstrate thorough coverage of edge cases:
typescript1describe('unzipWith', () => { 2 it('should unzip arrays combining regrouped elements with `iteratee`', () => { 3 const array = [[1, 4], [2, 5], [3, 6]]; 4 const actual = unzipWith(array, (a, b, c) => a + b + c); 5 expect(actual).toEqual([6, 15]); 6 }); 7 8 it('should return an empty array when `array` is null or undefined', () => { 9 expect(unzipWith(null)).toEqual([]); 10 expect(unzipWith(undefined)).toEqual([]); 11 }); 12 13 it('should match the type of lodash', () => { 14 expectTypeOf(unzipWith).toEqualTypeOf<typeof unzipWithLodash>(); 15 }); 16});
(src/compat/array/unzipWith.spec.ts:9-90)
Tests verify correct behavior with normal inputs, edge cases (null, undefined, empty arrays), array-like objects, and type compatibility with lodash. The expectTypeOf assertion ensures TypeScript types match exactly, preventing type regressions.
The following structure represents the core organization of the es-toolkit codebase:
es-toolkit/
├── src/
│ ├── index.ts # Main entry point
│ ├── array/ # Array utilities
│ ├── compat/ # Lodash compatibility layer
│ │ └── array/ # Compat array functions
│ ├── function/ # Function utilities
│ ├── object/ # Object utilities
│ ├── promise/ # Promise utilities
│ ├── predicate/ # Type predicates
│ ├── math/ # Math utilities
│ ├── string/ # String utilities
│ ├── util/ # General utilities
│ └── error/ # Error classes
├── docs/ # Documentation site
├── benchmarks/ # Performance benchmarks
├── package.json # Package configuration
└── CHANGELOG.md # Version history
The src/compat directory mirrors the structure of core modules, providing compatibility wrappers that delegate to core implementations while matching lodash's API. This separation ensures core functions remain focused on modern best practices.
es-toolkit demonstrates significant scope and capability:
| Metric | Value |
|---|---|
| Core Modules | 9 (array, function, object, promise, predicate, math, string, util, error) |
| Export Paths | 12 (main entry + 11 sub-paths) |
| Supported Environments | Browser, Node.js, Deno, React Native |
| Test Coverage | 100% |
| Performance Improvement | 2-3× vs alternatives |
| Bundle Size Reduction | Up to 97% vs alternatives |
| License | MIT |
(README.md:10-11, package.json:11-12)
The following diagram suggests an optimal order for exploring this technical analysis report:
正在加载图表渲染器...
Readers new to es-toolkit should begin with this overview, then explore the module architecture to understand the library's organization. The core features section provides a comprehensive catalog of available utilities, while implementation details offer deeper insights for advanced use cases. The version history provides context for the library's evolution, and usage examples demonstrate practical application patterns.
es-toolkit is particularly well-suited for:
The library's design philosophy prioritizes modern JavaScript practices while maintaining compatibility with existing codebases through the compat layer. This dual approach makes it suitable for both new projects and incremental migration of legacy applications.