-
-
Notifications
You must be signed in to change notification settings - Fork 0
unify soft()
Eugene Lazutkin edited this page Apr 6, 2026
·
2 revisions
Wraps an object to be treated as "soft" during unification.
Marks an object as "soft" — bidirectional open matching that merges missing properties from each side. When two soft objects are unified, each gains the other's unique properties.
import {soft} from 'deep6/unify.js';
import unify from 'deep6/unify.js';
// Soft pattern allows more flexible matching
const pattern = soft({a: 1, b: 2});
unify({a: 1, b: 2, c: 3}, pattern); // truthy - extra properties allowed
unify({a: 1, b: 2}, pattern); // truthyArguments:
-
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 "soft" during unification.
When an object is marked as "soft":
- Common properties are compared normally.
- Extra properties on either side are copied to the other side.
- The soft object is mutated to collect all properties after unification.
This is useful for accumulating properties across multiple unifications. See Wrapping for detailed examples.
- isSoft() — check if an object is wrapped as soft.
- open() — wrap an object as "open".
- isWrapped() — check if an object is wrapped.
Core functions
Environments and variables
Unification
Traverse
Unifiers
Utilities