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 |
countBy | array, map, set |
difference | array, date |
equalsDeep | array, object |
equalsShallow | array, object |
filter | map, set |
isEmpty | array, object, string |
isNonEmpty | array, object, string |
map | object, set |
toMapByKey | map, set |
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”countBy
Section titled “countBy”difference
Section titled “difference”equalsDeep
Section titled “equalsDeep”equalsShallow
Section titled “equalsShallow”filter
Section titled “filter”isEmpty
Section titled “isEmpty”isNonEmpty
Section titled “isNonEmpty”toMapByKey
Section titled “toMapByKey”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):
What about a single unified package?
Section titled “What about a single unified package?”Two “install everything” options exist, and neither reintroduces the naming collision:
@helpers4/allis a documentation-only bundle: it lists every category as apeerDependencybut ships no code of its own, so there is no flat module where two same-named exports could collide — you still install and import each@helpers4/<category>package directly.helpers4(added in v3.1.0) installs every category as a real dependency in onenpm install helpers4, but keeps the per-category split at the import site: each category is reachable only at its own subpath (helpers4/array,helpers4/object, …). There is no top-levelimport ... from 'helpers4'— since only the subpaths resolve,compactfromarrayandcompactfromobjectnever share a module and can never collide.
Both forms are equivalent — helpers4/<category> re-exports @helpers4/<category> verbatim, so the same as rename above works no matter which one you installed:
Design rationale
Section titled “Design rationale”See Philosophy — Category independence for a deeper explanation of why cross-category deduplication is intentionally avoided.
