UNPKG

tamda

Version:

Practical functional programming library for TypeScript

38 lines (37 loc) 1.86 kB
/** * Filters items that are only in `arrayA` or `arrayB`, but not both. * @note From set theory, given sets A and B, denoted A △ B or A ⊖ B, * returns the set of symmetricDifference members of exactly one of A and B * (elements which are in one of the sets, but not in both). * @param arrayA First array to find and compare items. * @param arrayB Second array to find and compare items. * @param keyFn Optional function to extract a key for comparison between array items. Default: `identity()`. * @example * symmetricDifference([1, 2, 3], [2, 3, 4]); * // [1, 4] */ export declare function symmetricDifference<T>(arrayA: T[], arrayB: T[], keyFn?: KeyFn<T>): T[]; /** * Returns a function that * filters items that are only in `arrayA` or `arrayB`, but not both. * @note From set theory, given sets A and B, denoted A △ B or A ⊖ B, * returns the set of symmetricDifference members of exactly one of A and B * (elements which are in one of the sets, but not in both). * @param arrayB Second array to find and compare items. * @param keyFn Optional function to extract a key for comparison between array items. Default: `identity()`. * @example * const symDiff = symmetricDifference([2, 3, 4]); * symDiff([1, 2, 3]); * // [1, 4] */ export declare function symmetricDifference<T>(arrayB: T[], keyFn?: KeyFn<T>): typeof deferred; /** * Filters items that are only in `arrayA` or `arrayB`, but not both. * @note From set theory, given sets A and B, denoted A △ B or A ⊖ B, * returns the set of symmetricDifference members of exactly one of A and B * (elements which are in one of the sets, but not in both). * @param arrayA First array to find and compare items. */ declare function deferred<T>(arrayA: T[]): T[]; declare type KeyFn<T> = (item: T, index: number) => any; export {};