Skip to content package
deep6 v1.2.2 Zero-dependency ESM library for deep equality, deep clone, unification, and pattern matching with logical variables and wildcards. Handles circular references, Map, Set, URL, typed arrays, Date, RegExp, symbols, and property descriptors. Works in Node.js,
node >=22 0 deps esm types open source
overview readme
license BSD-3-Clause
deps 0
unpacked 124.5 kB
files 36
node >=22 $ npm install deep6@1.2.2n npmREADME GitHub-flavored package documentation.
downloads Across all versions.
Download trend unavailable.
compatibility Runtime metadata.
keywords Tagged topics.
deep-equal deep-equality deep-clone deep-copy structured-clone unification pattern-matching wildcard logical-variables circular-references traverse walk
versions Latest published Jul 13, 2026
maintainers Registry package owners.
install size Estimated unpacked size across 1 packages.
122.9 kB
Includes dependencies.
contents deep6
deep6 is a no-dependency ES6 mini-library:
Advanced deep equivalency for JavaScript structures.
Extensible to accommodate custom objects.
Traversing objects.
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.
Intro
import {equal, match, clone, any} from 'deep6' ;
const x = {a: 1 , b: 2 , c: [ 'hi!' , 42 , null, {}]};
// deep equality
equal (x, {b: 2 , a: 1 , c: [ 'hi!' , 42 , null, {}]}); // true
equal (x, {b: 2 , a: 1 , c: [ 'hi!' , 42 , null, {z: 1 }]}); // false
// pattern matching
match (x, {a: 1 }); // true
match (x, {z: 1 }); // false
match (x, {a: 1 , c: any}); // true
Docs
Full documentation is in the wiki — browse the index , or search it by name.
Installation and use
npm install --save deep6 copy
// ES modules
import {equal, clone} from 'deep6' ;
import matchString from 'deep6/unifiers/matchString.js' ; copy
deep6 is ESM-only ("type": "module" in package.json). Tested on Node 22+, Bun, Deno, and modern browsers; from CommonJS use a dynamic import().
License
BSD-3-Clause
Release History
1.4.0 Fixed shared-reference equality, added circular semantic modes, EnvMap is the default environment now.
1.3.1 bugfix: EnvMap now works with assemble(), clone(), and deref().
1.3.0 Significantly improved perf, added EnvMap.
1.2.2 bugfixes (cycle detection with reused unifiers / atomic types, array-vs-object equality, Wrap fall-through type-parity, clone() with unbound variables); match() now opens arrays by default; Ref named export; Node 22+ floor.
1.2.1 AI-friendliness: added shippable use-deep6 skill, bugs/homepage/llms/llmsFull fields in package.json, ship AGENTS.md and ARCHITECTURE.md to npm.
1.2.0 added URL support, bug fixes (RegExp flag comparison, Map assembly/deref, env.ensure()), performance optimizations, improved TypeScript typings, expanded tests (~573).
1.1.4 updated dev deps.
1.1.3 updated dev deps.
1.1.2 updated dev deps.
1.1.1 reformulated any as a well-known symbol.
1.1.0 separated from yopl , extensive refactoring.
1.0.1 added the exports statement.
1.0.0 the first 1.0 release.
The full release notes are in the wiki: Release notes .
match (x, {a: 1 , c: []}); // false
match (x, {a: 1 , d: any}); // false
// deep cloning
const y = clone (x);
equal (x, y); // true
// circular dependencies are fine
const z = {},
w = {};
z.z = z;
w.z = w;
const p = clone (w);
equal (z, w); // true
equal (z, p); // true
// more standard types
const m = {a: new Map (), b: new Uint8Array ([ 99 , 98 , 97 ])};
m.a. set ( 'a' , [ Symbol (), new Set ([ 1 , 2 , 3 ])]);
m.a. set ( 'b' , [ /^abc/ i , new Date ()]);
const n = clone (m);
equal (m, n); // true
// advanced: symbols
const s = Symbol (),
t = {[s]: 42 , [Symbol. for ( 'deep6' )]: 33 },
u = {[s]: 42 , [Symbol. for ( 'deep6' )]: 33 },
v = clone (u, {symbols: true });
equal (t, u, {symbols: true }); // true
equal (t, v, {symbols: true }); // true
// advanced: clone non-enumerable properties
const r = {a: 1 };
Object. defineProperty (r, 'b' , {value: 2 , enumerable: false });
const q = clone (r, {allProps: true });
r === q; // false
equal (r, {a: 1 }); // true
equal (r, {a: 1 , b: 2 }); // false
r.a === q.a; // true
r.b === q.b; // true
copy