import { StrictEqualityComparer } from "../../shared" ; import { IEnumerable , IEqualityComparer } from "../../types" ; import { BasicEnumerable } from "../BasicEnumerable" ; param first param second param comparer returns export const intersect = < TSource > ( first , second , comparer = StrictEqualityComparer ) : IEnumerable < TSource > => { function * iterator ( ) { const firstResults = [ ... first . distinct ( comparer ) ] ; if ( firstResults . length === 0 ) { return ; } const secondResults = [ ... second ] ; for ( let i = 0 ; i < firstResults . length ; i ++ ) { const firstValue = firstResults [ i ] ; for ( let j = 0 ; j < secondResults . length ; j ++ ) { const secondValue = secondResults [ j ] ; if ( comparer ( firstValue , secondValue ) === true ) { yield firstValue ; break ; } } } } return new BasicEnumerable ( iterator ) ; } ;