1/** Returns the last index of an item based on a given criteria. */ 2export function findLastIndex<T>(array: T[], predicate: (item: T) => boolean) { 3 for (let i = array.length - 1; i >= 0; i--) { 4 if (predicate(array[i])) { 5 return i; 6 } 7 } 8 return -1; 9} 10 11/** Returns a list of items that intersect between two given arrays. */ 12export function intersecting<T>(a: T[], b: T[]): T[] { 13 const [c, d] = a.length > b.length ? [a, b] : [b, a]; 14 return c.filter((value) => d.includes(value)); 15} 16