import { EnumerableFactory } from '../utilities/EnumerableFactory'; import { IEnumerable } from '../types'; import { EqualityComparer } from '../types'; import { applyExcept } from './applicators/applyExcept'; /** * Produces the set difference of two sequences. * @example * ```typescript * const items = [1, 2, 3, 4]; * const exceptItems = from(items).except([2, 4]); // [1, 3] * ``` * @typeparam TSource The type of source elements. * @param src The source iterable. * @param second An Iterable whose elements that also occur in the first sequence will cause those elements to be removed from the returned sequence. * @returns A sequence that contains the set difference of the elements of two sequences. */ export function except(src: Iterable, second: Iterable): IEnumerable; /** * Produces the set difference of two sequences. * @example * ```typescript * const items = [1, 2, 3, 4]; * const exceptItems = from(items).except([2, 4]); // [1, 3] * ``` * @typeparam TSource The type of source elements. * @param src The source iterable. * @param second An Iterable whose elements that also occur in the first sequence will cause those elements to be removed from the returned sequence. * @returns A sequence that contains the set difference of the elements of two sequences. */ export function except(src: Iterable, ...second: Iterable[]): IEnumerable; /** * Produces the set difference of two sequences. * @example * ```typescript * const items = [1, 2, 3, 4]; * const exceptItems = from(items).except([2, 4], (a, b) => a === b); // [1, 3] * ``` * @typeparam TSource The type of source elements. * @param src The source iterable. * @param second An Iterable whose elements that also occur in the first sequence will cause those elements to be removed from the returned sequence. * @param equalityComparer An EqualityComparer to compare values. * @returns A sequence that contains the set difference of the elements of two sequences. */ export function except( src: Iterable, second: Iterable, equalityComparer: EqualityComparer ): IEnumerable; /** * Produces the set difference of two sequences. * @example * ```typescript * const items = [1, 2, 3, 4]; * const exceptItems = from(items).except([2, 4], [3], (a, b) => a === b); // [1] * ``` * @typeparam TSource The type of source elements. * @param src The source iterable. * @param second An Iterable whose elements that also occur in the first sequence will cause those elements to be removed from the returned sequence. * @param third An Iterable whose elements that also occur in the first sequence will cause those elements to be removed from the returned sequence. * @param equalityComparer An EqualityComparer to compare values. * @returns A sequence that contains the set difference of the elements of two sequences. */ export function except( src: Iterable, second: Iterable, third: Iterable, equalityComparer: EqualityComparer ): IEnumerable; /** * Produces the set difference of two sequences. * @example * ```typescript * const items = [1, 2, 3, 4, 5, 6, 7]; * const exceptItems = from(items).except([2, 4], [3, 5], [7], (a, b) => a === b); // [1, 6] * ``` * @typeparam TSource The type of source elements. * @param src The source iterable. * @param second An Iterable whose elements that also occur in the first sequence will cause those elements to be removed from the returned sequence. * @param third An Iterable whose elements that also occur in the first sequence will cause those elements to be removed from the returned sequence. * @param fourth An Iterable whose elements that also occur in the first sequence will cause those elements to be removed from the returned sequence. * @param equalityComparer An EqualityComparer to compare values. * @returns A sequence that contains the set difference of the elements of two sequences. */ export function except( src: Iterable, second: Iterable, third: Iterable, fourth: Iterable, equalityComparer: EqualityComparer ): IEnumerable; export function except( src: Iterable, ...second: (Iterable | EqualityComparer)[] ): IEnumerable { return applyExcept(new EnumerableFactory(), x => x, src, second); } /** * Produces the set difference of two sequences according to a specified key selector function. * @typeparam TSource The type of source elements. * @typeparam TKey The type of key to identify elements by. * @param src The source iterable. * @param second An Iterable whose keys that also occur in the first sequence will cause those elements to be removed from the returned sequence. * @param keySelector A function to extract the key for each element. * @returns A sequence that contains the set difference of the elements of two sequences. */ export function exceptBy( src: Iterable, second: Iterable, keySelector: (item: TSource) => TKey ): IEnumerable; /** * Produces the set difference of two sequences according to a specified key selector function. * @typeparam TSource The type of source elements. * @typeparam TKey The type of key to identify elements by. * @param src The source iterable. * @param second An Iterable whose keys that also occur in the first sequence will cause those elements to be removed from the returned sequence. * @param third An Iterable whose keys that also occur in the first sequence will cause those elements to be removed from the returned sequence. * @param keySelector A function to extract the key for each element. * @returns A sequence that contains the set difference of the elements of two sequences. */ export function exceptBy( src: Iterable, second: Iterable, third: Iterable, keySelector: (item: TSource) => TKey ): IEnumerable; /** * Produces the set difference of two sequences according to a specified key selector function. * @typeparam TSource The type of source elements. * @typeparam TKey The type of key to identify elements by. * @param src The source iterable. * @param second An Iterable whose keys that also occur in the first sequence will cause those elements to be removed from the returned sequence. * @param third An Iterable whose keys that also occur in the first sequence will cause those elements to be removed from the returned sequence. * @param fourth An Iterable whose keys that also occur in the first sequence will cause those elements to be removed from the returned sequence. * @param keySelector A function to extract the key for each element. * @returns A sequence that contains the set difference of the elements of two sequences. */ export function exceptBy( src: Iterable, second: Iterable, third: Iterable, fourth: Iterable, keySelector: (item: TSource) => TKey ): IEnumerable; /** * Produces the set difference of two sequences according to a specified key selector function. * @typeparam TSource The type of source elements. * @typeparam TKey The type of key to identify elements by. * @param src The source iterable. * @param second An Iterable whose keys that also occur in the first sequence will cause those elements to be removed from the returned sequence. * @param keySelector A function to extract the key for each element. * @param equalityComparer An EqualityComparer to compare values. * @returns A sequence that contains the set difference of the elements of two sequences. */ export function exceptBy( src: Iterable, second: Iterable, keySelector: (item: TSource) => TKey, equalityComparer: EqualityComparer ): IEnumerable; /** * Produces the set difference of two sequences according to a specified key selector function. * @typeparam TSource The type of source elements. * @typeparam TKey The type of key to identify elements by. * @param src The source iterable. * @param second An Iterable whose keys that also occur in the first sequence will cause those elements to be removed from the returned sequence. * @param third An Iterable whose keys that also occur in the first sequence will cause those elements to be removed from the returned sequence. * @param keySelector A function to extract the key for each element. * @param equalityComparer An EqualityComparer to compare values. * @returns A sequence that contains the set difference of the elements of two sequences. */ export function exceptBy( src: Iterable, second: Iterable, thrid: Iterable, keySelector: (item: TSource) => TKey, equalityComparer: EqualityComparer ): IEnumerable; /** * Produces the set difference of two sequences according to a specified key selector function. * @typeparam TSource The type of source elements. * @typeparam TKey The type of key to identify elements by. * @param src The source iterable. * @param second An Iterable whose keys that also occur in the first sequence will cause those elements to be removed from the returned sequence. * @param third An Iterable whose keys that also occur in the first sequence will cause those elements to be removed from the returned sequence. * @param fourth An Iterable whose keys that also occur in the first sequence will cause those elements to be removed from the returned sequence. * @param keySelector A function to extract the key for each element. * @param equalityComparer An EqualityComparer to compare values. * @returns A sequence that contains the set difference of the elements of two sequences. */ export function exceptBy( src: Iterable, second: Iterable, thrid: Iterable, fourth: Iterable, keySelector: (item: TSource) => TKey, equalityComparer: EqualityComparer ): IEnumerable; export function exceptBy( src: Iterable, ...second: (Iterable | ((item: TSource) => TKey) | EqualityComparer)[] ): IEnumerable { return applyExcept(new EnumerableFactory(), null, src, second); }