@woosh/meep-engine 2.48.9 → 2.48.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BaseMatcher } from "../BaseMatcher.js";
|
|
2
|
+
|
|
3
|
+
export class IsIn extends BaseMatcher {
|
|
4
|
+
/**
|
|
5
|
+
* @type {[]}
|
|
6
|
+
*/
|
|
7
|
+
#collection = []
|
|
8
|
+
|
|
9
|
+
constructor(collection) {
|
|
10
|
+
super();
|
|
11
|
+
|
|
12
|
+
this.#collection = collection;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
matches(item, mismatch_description) {
|
|
16
|
+
return this.#collection.includes(item);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
describeTo(description) {
|
|
20
|
+
description.appendText("one of ");
|
|
21
|
+
description.appendValueList("{", ", ", "}", this.#collection);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
}
|
|
@@ -6,6 +6,7 @@ import { IsNull } from "./IsNull.js";
|
|
|
6
6
|
import { IsIterableContaining } from "./IsIterableContaining.js";
|
|
7
7
|
import { Matcher } from "../Matcher.js";
|
|
8
8
|
import { IsUndefined } from "./IsUndefined.js";
|
|
9
|
+
import { IsIn } from "./IsIn.js";
|
|
9
10
|
|
|
10
11
|
export function anyOf(...matchers) {
|
|
11
12
|
return new AnyOf(matchers);
|
|
@@ -48,7 +49,7 @@ export const isNoUndefined = isDefined;
|
|
|
48
49
|
/**
|
|
49
50
|
* @template
|
|
50
51
|
* @param {Matcher|T} value
|
|
51
|
-
* @return {Matcher}
|
|
52
|
+
* @return {Matcher<T>}
|
|
52
53
|
*/
|
|
53
54
|
export function hasItem(value) {
|
|
54
55
|
if (value instanceof Matcher) {
|
|
@@ -58,3 +59,21 @@ export function hasItem(value) {
|
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
|
|
62
|
+
/**
|
|
63
|
+
* @template T
|
|
64
|
+
* @param {T[]} array
|
|
65
|
+
* @returns {Matcher<T>}
|
|
66
|
+
*/
|
|
67
|
+
export function isIn(array) {
|
|
68
|
+
return new IsIn(array);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @template T
|
|
74
|
+
* @param {T} elements
|
|
75
|
+
* @return {Matcher<T>}
|
|
76
|
+
*/
|
|
77
|
+
export function isOneOf(...elements) {
|
|
78
|
+
return isIn(elements);
|
|
79
|
+
}
|