diff options
| author | Alon Levy <alon@pobox.com> | 2014-12-08 03:13:36 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2014-12-08 11:37:43 +0200 |
| commit | d0c940cdd17ec6c05bdfd61317ab5c77af605777 (patch) | |
| tree | b2c2c238a7fda8e20e3b4486ab7c360ca736cff2 /src/model/graph.js | |
| parent | 326d3256d218323031b2b87d31ae313e73f5d2cd (diff) | |
graph: add hasNodeByNameAndNotState
Diffstat (limited to 'src/model/graph.js')
| -rw-r--r-- | src/model/graph.js | 18 |
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; |
