From 22c2b877fbf3d2adf7d763e8cce8cd331764ca8a Mon Sep 17 00:00:00 2001 From: Dennis Hotson Date: Fri, 15 Mar 2013 11:25:23 +0000 Subject: [PATCH] Updated to springy 2.0.1 --- springy.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/springy.js b/springy.js index 098dbcb..ce3a9b5 100644 --- a/springy.js +++ b/springy.js @@ -1,5 +1,5 @@ /** - * Springy v2.0.0 + * Springy v2.0.1 * * Copyright (c) 2010 Dennis Hotson * @@ -215,7 +215,6 @@ } this.detachNode(node); - }; // removes edges associated with a given node @@ -247,6 +246,16 @@ this.adjacency[x][y].splice(j, 1); } } + + // Clean up empty edge arrays + if (this.adjacency[x][y].length == 0) { + delete this.adjacency[x][y]; + } + } + + // Clean up empty objects + if (isEmpty(this.adjacency[x])) { + delete this.adjacency[x]; } } @@ -676,4 +685,13 @@ } }; } + + var isEmpty = function(obj) { + for (var k in obj) { + if (obj.hasOwnProperty(k)) { + return false; + } + } + return true; + }; }).call(this);