Last active
December 15, 2017 13:11
-
-
Save davidhellsing/01ecaecd4245441a81280310f7e847bc to your computer and use it in GitHub Desktop.
Revisions
-
davidhellsing revised this gist
Dec 15, 2017 . 1 changed file with 0 additions 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,6 +1,5 @@ findKey = (haystack, needle) => { let found = false const iterate = (obj) => ( Object.keys(obj).forEach((key) => { if (found === false) { -
davidhellsing revised this gist
Dec 15, 2017 . 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,8 +6,8 @@ findKey = (haystack, needle) => { if (found === false) { if (key === needle) { found = key } else if (obj[key] && typeof obj[key] === 'object') { iterate(obj[key]) } } }) -
davidhellsing revised this gist
Dec 15, 2017 . 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 @@ -12,8 +12,8 @@ findKey = (haystack, needle) => { } }) ) if (haystack && typeof haystack === 'object') { iterate(haystack) } return found } -
davidhellsing created this gist
Dec 15, 2017 .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,20 @@ findKey = (haystack, needle) => { let found = false let prop const iterate = (obj) => ( Object.keys(obj).forEach((key) => { if (found === false) { if (key === needle) { found = key } else if (prop && typeof prop === 'object') { iterate(prop) } } }) ) if (payload && typeof payload === 'object') { iterate(payload) } return found } }