Skip to content

Instantly share code, notes, and snippets.

@jalexanderfox
Forked from DorkForce/scanScope.txt
Last active August 29, 2015 14:20
Show Gist options
  • Save jalexanderfox/1e91b099a9f0e59bb3f0 to your computer and use it in GitHub Desktop.
Save jalexanderfox/1e91b099a9f0e59bb3f0 to your computer and use it in GitHub Desktop.
console.log("Usage Syntax: scanScope($scope.model, 'SCANFOR');");
function scanScope(whatToScan, scanValue, parentTree) {
var insertString = '';
for (var key in whatToScan) {
if (((whatToScan[key] != null) && (whatToScan[key].indexOf != undefined) && whatToScan[key].indexOf(scanValue) > -1) || key.indexOf(scanValue) >= 0) {
if (parentTree != null) {
insertString = parentTree + '.';
} else {
insertString = '';
}
console.log(insertString + key + ' = ' + whatToScan[key]);
} else {
if( (typeof whatToScan[key] === "object") && (key !== null) ) {
if (parentTree != null) {
insertString = parentTree + '.' + key;
} else {
insertString = '' + key;
}
scanScope(whatToScan[key], scanValue, insertString);
}
}
}
}
@DorkForce
Copy link

I noticed your fork of this (thanks!) and just wanted to let you know that I updated it since; it's now case insensitive for both key and value searches.

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