summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/model/graph.js18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/model/graph.js b/src/model/graph.js
index 1c27d7e9..2c86eea3 100644
--- a/src/model/graph.js
+++ b/src/model/graph.js
@@ -455,17 +455,19 @@ function Graph() {
};
var hasNodeByName = function(name, state) {
- var i;
-
- for (i = 0 ; i < nodes.length; ++i) {
- if (compareNames(nodes[i].name, name) && nodes[i].state === state) {
- return true;
- }
- }
- return false;
+ return nodes.filter(function (n) {
+ return compareNames(n.name, name) && n.state === state;
+ }).length > 0;
}
this.hasNodeByName = hasNodeByName;
+ var hasNodeByNameAndNotState = function(name, state) {
+ return nodes.filter(function(n) {
+ return compareNames(n.name, name) && n.state !== state;
+ }).length > 0;
+ }
+ this.hasNodeByNameAndNotState = hasNodeByNameAndNotState;
+
var hasNode = function(id, state) {
var i;