UNPKG

563 BJavaScriptView Raw
1import { map } from './map';
2function plucker(props, length) {
3 const mapper = (x) => {
4 let currentProp = x;
5 for (let i = 0; i < length; i++) {
6 const p = currentProp[props[i]];
7 if (typeof p !== 'undefined') {
8 currentProp = p;
9 }
10 else {
11 return undefined;
12 }
13 }
14 return currentProp;
15 };
16 return mapper;
17}
18export function pluck(source, ...args) {
19 return map(source, plucker(args, args.length));
20}
21
22//# sourceMappingURL=pluck.mjs.map