Introduction
es-toolkits a modern, high-performance JavaScript utility library designed for contemporary development workflows. It offers a compact bundle size alongside robust TypeScript typings, making it an excellent choice for everyday programming tasks.
When compared to alternatives like lodash, es-toolkit achieves up to 97% reduction in bundle size while delivering 2-3x faster runtime performance. The library leverages modern JavaScript features to implement most of its functionality.
Homepage: https://es-toolkit.slash.page/
Repository: https://github.com/toss/es-toolkit
Key Features
es-toolkit provides several compelling advantages:
- Modern Implementations: Offers everyday utility functions including debounce, delay, chunk, sum, and pick, all implemented using contemporary JavaScript patterns.
- Performance Optimized: Achieves 2-3x performance improvements in modern JavaScript environments compared to traditional utilities.
- Tree-shaking Ready: Reduces JavaScript code size by up to 97% compared to other libraries, thanks to modular design.
- TypeScript First: Includes built-in TypeScript support with intuitive and powerful type definitions, featuring helpful type guards like isNotNil.
- Battle-tested: Maintains 100% test coverage to ensure reliability and stability.
Available Modules
The library organizes functionality into several categories:
- Array: Operations for array manipulation such as uniq and difference.
- Function: Utilities for controlling function execution including debounce and throttle.
- Math: Numeric operations like sum and round.
- Object: Tools for manipulating JavaScript objects including pick and omit.
- Predicate: Type guard functions such as isNotNil.
- Promise: Async utilities like delay.
- String: String manipulation tools including snakeCase.
Installation
es-toolkit supports multiple package managers:
Node.js
npm install es-toolkit
Deno
Install via JSR (note the different package name):
deno add @es-toolkit/es-toolkit
Bun
bun add es-toolkit
Usage Examples
import { debounce, chunk } from "es-toolkit";
const throttledLog = debounce((msg) => {
console.log(msg);
}, 300);
// This invocation gets debounced
throttledLog("Hello, world!");
const numbers = [1, 2, 3, 4, 5, 6];
const groupedNumbers = chunk(numbers, 2);
console.log(groupedNumbers);
// Output: [[1, 2], [3, 4], [5, 6]]
Bundle Size
Thanks to its modern implementation approach, es-toolkit significently minimizes bundle size compared to other libraries. Some utility functions are under 100 bytes, making it one of the most efficient options available. The comparison demonstrates the substantial reduction in payload size.
Performance
Performance was a primary design consideration for es-toolkit. Compared to similar utility libraries, average performance improvements reach 2x, with some functions achieving up to 11x speed gains by leveraging modern JavaScript APIs.
Tests were conducted on MacBook Pro 14-inch (M1 Max, 2021).