Add remove node api

This commit is contained in:
Nick O'Leary
2014-08-07 22:20:06 +01:00
parent 43ad8706aa
commit 58c2f5dd3d
5 changed files with 77 additions and 16 deletions

View File

@@ -61,18 +61,19 @@ var registry = (function() {
},
removeNode: function(id) {
var config = nodeConfigs[id];
if (config) {
delete nodeConfigs[id];
var i = nodeList.indexOf(id);
if (i > -1) {
nodeList.splice(i,1);
}
config.types.forEach(function(t) {
delete nodeConstructors[t];
delete nodeTypeToId[t];
});
nodeConfigCache = null;
if (!config) {
throw new Error("Unrecognised id: "+id);
}
delete nodeConfigs[id];
var i = nodeList.indexOf(id);
if (i > -1) {
nodeList.splice(i,1);
}
config.types.forEach(function(t) {
delete nodeConstructors[t];
delete nodeTypeToId[t];
});
nodeConfigCache = null;
return filterNodeInfo(config);
},
getNodeInfo: function(typeOrId) {