-
-
Notifications
You must be signed in to change notification settings - Fork 0
unify open()
Eugene Lazutkin edited this page Apr 3, 2026
·
1 revision
Wraps an object to be treated as "open" during unification.
Marks an object so that during unification, it can match objects that have additional properties beyond those defined in the pattern. This is the opposite of exact matching.
import {open} from 'deep6/unify.js';
import unify from 'deep6/unify.js';
// Open pattern matches objects with at least these properties
const pattern = open({a: 1, b: 2});
unify({a: 1, b: 2, c: 3}, pattern); // truthy - extra 'c' is allowed
unify({a: 1, b: 2}, pattern); // truthy - exact match
unify({a: 1}, pattern); // falsy - missing 'b'Arguments:
-
o— a required object to wrap. Can be a plain object, array, Map, or Set.
Returns a wrapped version of o that will be treated as "open" during unification.
Open objects match counterparts that have at least the same properties/elements:
- For objects: the counterpart must have all properties of the open object, but can have extras.
- For arrays: the counterpart must have at least the elements at the same indices.
- For Maps: the counterpart must have at least the same keys with matching values.
- For Sets: the counterpart must contain at least the same elements.
- isOpen() — check if an object is wrapped as open.
- soft() — wrap an object as "soft".
- isWrapped() — check if an object is wrapped.
- match() — uses open semantics by default.
Core functions
Environments and variables
Unification
Traverse
Unifiers
Utilities