Name Conflicts Between Categories
Name Conflicts Between Categories
Section titled “Name Conflicts Between Categories”helpers4 is split into independent npm packages — one per category. Each package can be installed and tree-shaken independently. A deliberate consequence of this design is that the same function name can exist in multiple categories when the operation makes sense for different data types.
This is not a bug. compact for arrays and compact for objects are genuinely different operations, and merging them into a single overloaded function would break tree-shaking and make the types less precise.
Known Conflicts
Section titled “Known Conflicts”Auto-generated from the current build — always reflects the documented version.
| Function | Categories |
|---|---|
compact | array, object |
compare | date, version |
difference | array, date |
shallowEquals | array, object |
Resolving Conflicts
Section titled “Resolving Conflicts”When you need two helpers with the same name in the same file, rename one (or both) at the import site using the as keyword.
Recommended naming convention
Section titled “Recommended naming convention”Suffix with 4{category} — consistent with the helpers4 naming identity:
All conflicts — resolution examples
Section titled “All conflicts — resolution examples”compact
Section titled “compact”compare
Section titled “compare”difference
Section titled “difference”shallowEquals
Section titled “shallowEquals”Alternative: namespace import
Section titled “Alternative: namespace import”If you use many helpers from both conflicting categories, a namespace import is more concise — but check that your bundler handles namespace tree-shaking (esbuild, Rollup, and Vite all do):
Why not a single unified package?
Section titled “Why not a single unified package?”The @helpers4/all bundle does export every category. Inside a single module context, the category name is not part of the export, so the last export * wins when two categories export the same name.
This means you cannot safely import { compact } from '@helpers4/all' if both array and object export compact — the result is undefined behavior depending on module bundler internals.
Always use per-category packages (@helpers4/array, @helpers4/object, …) when you need conflicting helpers. They are the canonical import source.
Design rationale
Section titled “Design rationale”See Philosophy — Category independence for a deeper explanation of why cross-category deduplication is intentionally avoided.