-
-
Notifications
You must be signed in to change notification settings - Fork 0
any
Eugene Lazutkin edited this page Jan 11, 2022
·
10 revisions
any
is a special object, which matches any possible value. The same object is exported under a different alias: _
(underscore). See: _.
It is defined in env
and exposed in the main module and unify as a convenience.
import {any, match} from 'deep6';
match([1, 2, 3], [1, any, 3]); // true
match({a: 1, b: 2}, {a: any}); // true
match({a: 1, b: 2}, {b: any}); // true
match({a: 1, b: 2}, {c: any}); // false
const group = new Map();
group.set('bob', 'cool').set('mike', 'cool').set('ben', 'smart');
const pattern = new Map([['mike', any], ['bob', 'cool']]);
// do we have a mike and the cool bob in the group?
match(group, pattern); // true
The current implementation:
const _ = Symbol.for('deep6.any'),
any = _;