]> git.r.bdr.sh - rbdr/serpentity/blobdiff - lib/serpentity/node.js
Feature/code update (#1)
[rbdr/serpentity] / lib / serpentity / node.js
index fa0af75ebaaca70792c1ca3ab3fe150cc529d517..796eee53c276993b7299240cc351b513dfbba68b 100644 (file)
@@ -1,48 +1,42 @@
 '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;