'use strict';
-/* global Serpentity */
-
/*
* A node describes a set of components in order to describe entities
* that include them.
*/
-let Node = class Node {
+const Node = class Node {
/*
* Returns true if the given entity matches the defined protocol,
* false otherwise
*/
- static matches (entity) {
- let types = this.types;
+ static matches(entity) {
+
+ const typeNames = Object.keys(this.types);
- for (let typeName in types) {
- if (types.hasOwnProperty(typeName)) {
+ for (const typeName of typeNames) {
- let matched = false;
- let type = types[typeName];
+ const type = this.types[typeName];
+ let matched = false;
- if (entity.hasComponent(type)) {
- matched = true;
- }
+ if (entity.hasComponent(type)) {
+ matched = true;
+ }
- if (!matched) {
- return false;
- }
+ if (!matched) {
+ return false;
}
}
return true;
}
- constructor (config) {
+ constructor(config) {
+
this.types = {};
- Object.assign(this, config || {});
+ Object.assign(this, config);
}
};
-if (typeof module !== 'undefined' && this.module !== module) {
- module.exports = Node;
-} else {
- Serpentity.Node = Node;
-}
+module.exports = Node;