@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
31 lines (24 loc) • 591 B
JavaScript
import { BaseMatcher } from "../BaseMatcher.js";
/**
* @template T
*/
export class IsIn extends BaseMatcher {
/**
* @type {T[]}
*/
#collection = []
/**
* @param {T[]} collection
*/
constructor(collection) {
super();
this.#collection = collection;
}
matches(item, mismatch_description) {
return this.#collection.includes(item);
}
describeTo(description) {
description.appendText("one of ");
description.appendValueList("{", ", ", "}", this.#collection);
}
}