UNPKG

@reactivex/ix-es5-esm

Version:

The Interactive Extensions for JavaScript

37 lines (35 loc) 1.17 kB
import { map } from './map.js'; function plucker(props, length) { var mapper = function (x) { var currentProp = x; for (var i = 0; i < length; i++) { var p = currentProp[props[i]]; if (typeof p !== 'undefined') { currentProp = p; } else { return undefined; } } return currentProp; }; return mapper; } /** * Maps each source value to its specified nested property. * * @template TSource The type of the elements in the source sequence. * @template TResult The type of the elements in the result sequence, obtained by the property names. * @param {...string[]} args The nested properties to pluck from each source value. * @returns {OperatorAsyncFunction<TSource, TResult>} An async-iterable of property values from the source values. */ export function pluck() { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } return function pluckOperatorFunction(source) { return map(plucker(args, args.length))(source); }; } //# sourceMappingURL=pluck.js.map