1/** 2 * Created by t.stulka on 2017-02-03. 3 */ 4 5 6var objectHelper = { 7 getObjectsByKey: function(obj, key, val) { 8 if(typeof obj !== 'undefined') { 9 var objects = []; 10 for (var i in obj) { 11 if (!obj.hasOwnProperty(i)) continue; 12 if (typeof obj[i] === 'object') { 13 objects = objects.concat(objectHelper.getObjectsByKey(obj[i], key, val)); 14 } else 15 //if key matches and value matches or if key matches and value is not passed (eliminating the case where key matches but passed value does not) 16 if (i == key && obj[i] == val || i == key && val === '') { // 17 objects.push(obj); 18 } else if (obj[i] == val && key === '') { 19 //only add if the object is not already in the array 20 if (objects.lastIndexOf(obj) == -1) { 21 objects.push(obj); 22 } 23 } 24 } 25 return objects; 26 } else { 27 return null; 28 } 29 }, 30 getValuesByKey: function(obj, key) { 31 if(typeof obj !== 'undefined') { 32 var objects = []; 33 for (var i in obj) { 34 if (!obj.hasOwnProperty(i)) continue; 35 if (typeof obj[i] === 'object') { 36 objects = objects.concat(objectHelper.getValuesByKey(obj[i], key)); 37 } else if (i == key) { 38 objects.push(obj[i]); 39 } 40 } 41 return objects; 42 } else { 43 return null; 44 } 45 } 46};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.