-
-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Eugene Lazutkin edited this page Apr 6, 2026
·
15 revisions
deep6 is a no-dependency ES6 mini-library:
- Advanced deep equivalency for JavaScript structures.
- Extensible to accommodate custom objects.
- Traversing objects.
- Extensible deep cloning.
- Written in ES6:
- Use it in Node or browsers without transpiling.
- Natively supports
Map,Set, typed arrays. - Natively supports symbols and property descriptors.
- Presented as ES6 modules.
- Efficient non-recursive algorithms.
- ~550 tests to ensure correctness.
- Support for circular dependencies.
- Support for "loose" comparisons.
- Unification.
- Identifying and capturing object fragments.
Most popular functions available from the main module as named properties:
-
equal(a, b [, options]) — deep equality.
- Also this function is the default export of the module.
- match(a, b [, options]) (or isShape()) — object pattern matching.
- clone(a [, options]) — deep cloning.
Advanced functionality:
-
env — environments and variables:
- Env — a class to create an environment object.
-
Unifier — an interface for custom unifiers.
-
isUnifier(x) — returns a truthy value for objects based on
Unifier.
-
isUnifier(x) — returns a truthy value for objects based on
-
Variable — a class to create variable objects that can be used with
Env.-
isVariable(x) — returns a truthy value for objects based on
Variable. - variable([name]) — creates a variable object.
-
isVariable(x) — returns a truthy value for objects based on
- any (or _) — special object that matches anything.
- unify(a, b [, env] [, options]) — generalized unification of objects.
- Traverse objects (in
traverse/):- walk(o [, options]) — visit all primitives of an object.
- clone(source [, env] [, options]) — deep cloning with full control (underlying implementation).
- assemble(o [, env] [, options]) — assemble an object resolving variables.
- deref(o [, env] [, options]) — dereference variables in an object in place.
- preprocess(o [, options]) — mark up objects for custom unification.
- Useful unifiers (in
unifiers/):- matchCondition(fn) — match if a counterpart satisfies a given function.
- matchInstanceOf(types) — match if a counterpart is of certain instances.
- matchString(regexp [, matches] [, props]) — match if a counterpart satisfies a regular expression.
- matchTypeOf(types) — match if a counterpart is of certain type names.
- ref(variable, value) — binds a variable to a value and continue comparing this values against the other object.
- Utilities (in
utils/):- replaceVars(env) — creates a template literal function that resolves variables.
It is the next generation of heya-unify, which basic concepts were explained and demonstrated in the following blog posts: