export function mapNotNull(array: T[], fn: (item: T, index: number) => R | null): R[] { const result: R[] = [] let index = 0 for (const item of array) { const mapped = fn(item, index) if (mapped !== null) result.push(mapped) index++ } return result } export function filterNulls(array: T[]): Exclude[] { return array.filter(i => i !== null) as Exclude[] }