Skip to content

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.

Auto-generated from the current build — always reflects the documented version.

FunctionCategories
compactarray, object
comparedate, version
differencearray, date
shallowEqualsarray, object

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.

Suffix with 4{category} — consistent with the helpers4 naming identity:

import { compact as compact4array } from '@helpers4/array';
import { compact as compact4object } from '@helpers4/object';

const numbers = compact4array([0, 1, null, 2, undefined]);
// => [1, 2]

const user = compact4object({ id: 1, name: null, role: undefined });
// => { id: 1 }
import { compact as compact4array } from '@helpers4/array';
import { compact as compact4object } from '@helpers4/object';
import { compare as compare4date } from '@helpers4/date';
import { compare as compare4version } from '@helpers4/version';
import { difference as difference4array } from '@helpers4/array';
import { difference as difference4date } from '@helpers4/date';
import { shallowEquals as shallowEquals4array } from '@helpers4/array';
import { shallowEquals as shallowEquals4object } from '@helpers4/object';

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):

import * as A from '@helpers4/array';
import * as O from '@helpers4/object';

A.compact([0, 1, null]);
O.compact({ a: 1, b: null });

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.

See Philosophy — Category independence for a deeper explanation of why cross-category deduplication is intentionally avoided.