Last active
January 27, 2023 22:52
-
-
Save shakhal/3cf5402fc61484d58c8d to your computer and use it in GitHub Desktop.
Revisions
-
shakhal revised this gist
Nov 26, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ function findValuesHelper(obj, key, list) { if (!obj) return list; if (obj instanceof Array) { for (var i in obj) { list = list.concat(findValuesHelper(obj[i], key, [])); } return list; } @@ -16,7 +16,7 @@ function findValuesHelper(obj, key, list) { var children = Object.keys(obj); if (children.length > 0){ for (i = 0; i < children.length; i++ ){ list = list.concat(findValuesHelper(obj[children[i]], key, [])); } } } -
shakhal revised this gist
Nov 26, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ function findValues(obj, key){ return findValuesHelper(obj, key, []); } function findValuesHelper(obj, key, list) { -
shakhal created this gist
Nov 26, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ function findValues(obj, key){ return getElementsByTagNameHelper(obj, key, []); } function findValuesHelper(obj, key, list) { if (!obj) return list; if (obj instanceof Array) { for (var i in obj) { list = list.concat(getNames(obj[i], key, [])); } return list; } if (obj[key]) list.push(obj[key]); if ((typeof obj == "object") && (obj !== null) ){ var children = Object.keys(obj); if (children.length > 0){ for (i = 0; i < children.length; i++ ){ list = list.concat(getNames(obj[children[i]], key, [])); } } } return list; }