Utilities (massaman/*)
Overview
Check es-toolkit before writing any utility function. It likely already exists with better edge-case handling, tree-shaking, and type safety. In this project, import es-toolkit through massaman/* subpaths — massaman is the umbrella package the codebase uses for both es-toolkit and ts-pattern. Subpath mapping:
These rules cover which utilities to reach for and when to write your own instead. Examples below use the project import form.
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 massaman/predicate for Trivial Operations
For standalone null checks, prefer inline comparison over importing isNil. Reserve predicate helpers for composed or higher-order contexts where they add clarity, such as callbacks to omitBy, filter, or other higher-order functions.
Correct
Incorrect
Resources
References
- Functions -- Pure function patterns