UNPKG

@tidyjs/tidy

Version:

Tidy up your data with JavaScript, inspired by dplyr and the tidyverse

14 lines (12 loc) 400 B
function lead(key, options) { const keyFn = typeof key === "function" ? key : (d) => d[key]; const {n = 1, default: defaultValue} = options != null ? options : {}; return (items) => { return items.map((_, i) => { const leadItem = items[i + n]; return leadItem == null ? defaultValue : keyFn(leadItem, i, items); }); }; } export { lead }; //# sourceMappingURL=lead.js.map