import type { Curried } from '../../compositions/curry.js'; import { type Purried, purry } from '../../compositions/purry.js'; import type { MaybePromise, Series, StaticSeries, SyncSeries } from '../../controls/types.js'; import { filterAsync, filterSync } from '../filters/filter.js'; import { _asyncIntersectWith, _syncIntersectWith } from './_intersect-with.js'; const _syncIntersectionWith = ( input: SyncSeries, other: StaticSeries, equals: (value: T, otherValue: U) => boolean, ): Generator => filterSync(input, _syncIntersectWith(other, equals)); const _asyncIntersectionWith = ( input: Series, other: StaticSeries, equals: (value: Awaited, otherValue: U) => MaybePromise, ): AsyncGenerator> => filterAsync(input, _asyncIntersectWith(other, equals)); export function intersectionWithSync( ...args: Parameters> ): ReturnType>; export function intersectionWithSync( ...args: Parameters>> ): ReturnType>>; export function intersectionWithSync( ...args: Parameters>> ): ReturnType>> { return purry(_syncIntersectionWith)(...args); } export function intersectionWithAsync( ...args: Parameters> ): ReturnType>; export function intersectionWithAsync( ...args: Parameters>> ): ReturnType>>; export function intersectionWithAsync( ...args: Parameters>> ): ReturnType>> { return purry(_asyncIntersectionWith)(...args); } export namespace intersectionWith { export const sync = intersectionWithSync; export const async = intersectionWithAsync; }