-
-
Notifications
You must be signed in to change notification settings - Fork 0
unify soft()
Eugene Lazutkin edited this page Apr 3, 2026
·
2 revisions
Wraps an object to be treated as "soft" during unification.
Marks an object as "soft" - a variant of open matching that is more permissive. Unlike "open" which requires exact value matches for existing properties, "soft" allows more flexible matching semantics.
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.
Soft matching is primarily used internally for preprocessing patterns. When an object is marked as "soft":
- It can match counterparts with additional properties/elements (like "open")
- The matching semantics are more relaxed for certain edge cases
- Used by preprocess() when preparing patterns
- 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