1const group = (result, key, value) => { 2 result[key] ||= []; 3 return result[key].push(value); 4}; 5 6export function groupBy(arr, f) { 7 const result = {}; 8 for (const x of arr) { 9 group(result, f(x), x); 10 } 11 return result; 12} 13 14const index = (result, key, value) => (result[key] = value); 15export function indexBy(arr, f) { 16 const result = {}; 17 for (const x of arr) { 18 index(result, f(x), x); 19 } 20 return result; 21} 22 23export function sortBy(array, getValue) { 24 return [...array].sort((a, b) => { 25 const x = getValue(a); 26 const y = getValue(b); 27 28 if (x < y) return -1; 29 if (x > y) return 1; 30 return 0; 31 }); 32}
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.