import { curryN } from "@unboxing/function"; import { indexOf } from "./indexOf"; interface Difference { (list1: ArrayLike, list2: ArrayLike): T[]; (list1: ArrayLike): (list2: ArrayLike) => T[]; } /** * Returns the array of all elements in the first array not * contained in the second array. */ export const difference = curryN(2, (a: ArrayLike = [], b: ArrayLike = []) => { const result = []; for (let i = 0; i < a.length; i++) { if (indexOf(a[i], b) < 0) { result.push(a[i]); } } return result; }) as Difference