import { IterableX } from '../iterablex' ; import { MapIterable } from './map' ; import { OperatorFunction } from '../../interfaces' ; function plucker ( props , length ) { const mapper = ( x ) => { let currentProp = x ; for ( let i = 0 ; i < length ; i ++ ) { const p = currentProp [ props [ i ] ] ; if ( typeof p !== 'undefined' ) { currentProp = p ; } else { return undefined ; } } return currentProp ; } ; return mapper ; } template TSource template TResult param { ... string [ ] } args returns { OperatorAsyncFunction < TSource , TResult > } export function pluck < TSource , TResult > ( ... args ) { return function pluckOperatorFunction ( source ) : IterableX < TResult > { return new MapIterable < TSource , TResult > ( source , ( plucker ( args , args . length ) as any ) as ( value : TSource ) => TResult ) ; } ; }