import { IParallelEnumerable } from "../../types" ; import { BasicParallelEnumerable } from "../BasicParallelEnumerable" ; import { nextIteration } from "./_nextIteration" ; import { nextIterationWithIndex } from "./_nextIterationWithIndex" ; type SelectFunc = { param source param selector returns < TSource , OUT > ( source , selector ) : IParallelEnumerable < OUT > ; param source param selector returns < TSource , TKey extends keyof TSource > ( source , key ) : IParallelEnumerable < TSource [ TKey ] > ; } ; export const select = < TSource , OUT > ( source , key ) : IParallelEnumerable < any > => { if ( typeof key === "function" ) { if ( key . length === 1 ) { return new BasicParallelEnumerable ( nextIteration ( source , key as ( x : TSource ) => OUT ) ) ; } else { return new BasicParallelEnumerable ( nextIterationWithIndex ( source , key ) ) ; } } else { return new BasicParallelEnumerable ( nextIteration ( source , ( x ) => x [ key ] as OUT ) ) ; } } ;