UNPKG

@550w-tools/core

Version:

550w-tools 核心库,暴露若干API供应用层调用

20 lines (19 loc) 730 B
/** * @description 对两个数组执行集合操作,返回包含交集和补集的对象。 * * @param arr1 - 第一个数组(全集) * @param arr2 - 第二个数组 * @returns 返回一个包含交集和补集的对象。 * @return intersection 交集 arr1 ∩ arr2 = {x|x∈arr1 ∧ x∈arr2} * @return complement arr2在arr1中的补集:arr1 - arr2 = { x| x∈arr1 且 x∉arr2}。 * * @example * const arr1 = [1, 2, 3, 4, 5]; * const arr2 = [3, 4, 5, 6, 7]; * const res = arraySetOperation(arr1, arr2); * console.log(res); // 输出:{ intersection: [3, 4, 5], complement: [1, 2] } */ export declare function arraySetOperation<T>(arr1: T[], arr2: T[]): { intersection: T[]; complement: T[]; };