UNPKG

1.28 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.WeakSetPredicate = void 0;
4const has_items_1 = require("../utils/has-items");
5const predicate_1 = require("./predicate");
6class WeakSetPredicate extends predicate_1.Predicate {
7 /**
8 @hidden
9 */
10 constructor(options) {
11 super('WeakSet', options);
12 }
13 /**
14 Test a WeakSet to include all the provided items. The items are tested by identity, not structure.
15
16 @param items - The items that should be a item in the WeakSet.
17 */
18 has(...items) {
19 return this.addValidator({
20 message: (_, label, missingItems) => `Expected ${label} to have items \`${JSON.stringify(missingItems)}\``,
21 validator: set => has_items_1.default(set, items)
22 });
23 }
24 /**
25 Test a WeakSet to include any of the provided items. The items are tested by identity, not structure.
26
27 @param items - The items that could be a item in the WeakSet.
28 */
29 hasAny(...items) {
30 return this.addValidator({
31 message: (_, label) => `Expected ${label} to have any item of \`${JSON.stringify(items)}\``,
32 validator: set => items.some(item => set.has(item))
33 });
34 }
35}
36exports.WeakSetPredicate = WeakSetPredicate;