UNPKG

@tidyjs/tidy

Version:

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

24 lines (21 loc) 547 B
import { singleOrArray } from './helpers/singleOrArray.js'; function fill(keys) { const _fill = (items) => { const keysArray = singleOrArray(keys); const replaceMap = {}; return items.map((d) => { const obj = {...d}; for (const key of keysArray) { if (obj[key] != null) { replaceMap[key] = obj[key]; } else if (replaceMap[key] != null) { obj[key] = replaceMap[key]; } } return obj; }); }; return _fill; } export { fill }; //# sourceMappingURL=fill.js.map