Skip to content

Instantly share code, notes, and snippets.

@niisar
Created October 19, 2016 06:34
Show Gist options
  • Save niisar/b82674294feffd2e4cf52db80b70dcce to your computer and use it in GitHub Desktop.
Save niisar/b82674294feffd2e4cf52db80b70dcce to your computer and use it in GitHub Desktop.
add level
vm.recursiveSearch = function find(source, id, currentLevel) {
for (var key in source) {
if (source.hasOwnProperty(key)) {
source[key].level = currentLevel;
var item = source[key];
vm.kk.push(item);
if (item.nodeId === id) {
return item;
}
if (item.childNode) {
var subresult = vm.recursiveSearch(item.childNode, id, currentLevel + 1);
if (subresult) {
return subresult;
}
}
}
}
return null;
};
@niisar
Copy link
Author

niisar commented Oct 19, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment