1 | import hasItems from '../utils/has-items.js';
|
2 | import { Predicate } from './predicate.js';
|
3 | export class WeakMapPredicate extends Predicate {
|
4 | |
5 |
|
6 |
|
7 | constructor(options) {
|
8 | super('WeakMap', options);
|
9 | }
|
10 | |
11 |
|
12 |
|
13 |
|
14 |
|
15 | hasKeys(...keys) {
|
16 | return this.addValidator({
|
17 | message: (_, label, missingKeys) => `Expected ${label} to have keys \`${JSON.stringify(missingKeys)}\``,
|
18 | validator: map => hasItems(map, keys),
|
19 | });
|
20 | }
|
21 | |
22 |
|
23 |
|
24 |
|
25 |
|
26 | hasAnyKeys(...keys) {
|
27 | return this.addValidator({
|
28 | message: (_, label) => `Expected ${label} to have any key of \`${JSON.stringify(keys)}\``,
|
29 | validator: map => keys.some(key => map.has(key)),
|
30 | });
|
31 | }
|
32 | }
|