axax
Version:
A library of async iterator extensions for JavaScript including ```map```, ```reduce```, ```filter```, ```flatMap```, ```pipe``` and [more](https://github.com/jamiemccrindle/axax/blob/master/docs/API.md#functions).
22 lines (21 loc) • 579 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Maps the source objects to their values at the path specified
*/
function pluck(...path) {
return async function* inner(source) {
for await (const item of source) {
let value = item;
for (const key of path) {
if (value[key] === undefined) {
value = undefined;
break;
}
value = value[key];
}
yield value;
}
};
}
exports.pluck = pluck;