import type { NonEmptyArray } from "../types/generics.js"; export const intersect = (arr: Array) => (x: T) => arr.includes(x); export const ensureNonEmpty = (arr: Array, errMsg?: string): NonEmptyArray => { if (arr.length === 0) throw new Error(errMsg ?? "Array cannot be empty"); return arr as NonEmptyArray; };