Utilities (es-toolkit)
Overview
Check es-toolkit before writing any utility function. It likely already exists with better edge-case handling, tree-shaking, and type safety. These rules cover which es-toolkit functions to reach for and when to write your own instead.
Rules
Use Type Guards for Runtime Checks
Functions for runtime type checking. Prefer these over manual typeof chains.
Correct
Use Object Utilities for Immutable Transforms
Functions for picking, omitting, and transforming object properties without mutation.
Correct
Use Collection Utilities for Arrays
Functions for grouping, deduplicating, and batching arrays.
Correct
Use Function Utilities for Scheduling and Caching
Functions for controlling execution timing and caching results.
Correct
Use String Utilities for Case Conversion
Functions for converting between naming conventions.
Correct
Avoid es-toolkit for Trivial Operations
Do not import es-toolkit for checks that are clearer as one-liners. Reserve it for operations that are genuinely hard to get right.
Correct
Incorrect
Resources
References
- Functions -- Pure function patterns