@woosh/meep-engine 2.48.8 → 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
@@ -5,7 +5,7 @@
5
5
  "description": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.48.8",
8
+ "version": "2.48.10",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -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
+ }
@@ -5,6 +5,8 @@ import { IsEqual } from "./IsEqual.js";
5
5
  import { IsNull } from "./IsNull.js";
6
6
  import { IsIterableContaining } from "./IsIterableContaining.js";
7
7
  import { Matcher } from "../Matcher.js";
8
+ import { IsUndefined } from "./IsUndefined.js";
9
+ import { IsIn } from "./IsIn.js";
8
10
 
9
11
  export function anyOf(...matchers) {
10
12
  return new AnyOf(matchers);
@@ -34,10 +36,20 @@ export function isNotNull() {
34
36
  return not(isNull());
35
37
  }
36
38
 
39
+ export function isUndefined() {
40
+ return new IsUndefined();
41
+ }
42
+
43
+ export function isDefined() {
44
+ return not(isUndefined());
45
+ }
46
+
47
+ export const isNoUndefined = isDefined;
48
+
37
49
  /**
38
50
  * @template
39
51
  * @param {Matcher|T} value
40
- * @return {Matcher}
52
+ * @return {Matcher<T>}
41
53
  */
42
54
  export function hasItem(value) {
43
55
  if (value instanceof Matcher) {
@@ -45,6 +57,23 @@ export function hasItem(value) {
45
57
  } else {
46
58
  return new IsIterableContaining(equalTo(value));
47
59
  }
60
+ }
48
61
 
62
+ /**
63
+ * @template T
64
+ * @param {T[]} array
65
+ * @returns {Matcher<T>}
66
+ */
67
+ export function isIn(array) {
68
+ return new IsIn(array);
49
69
  }
50
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
+ }