@thi.ng/transducers
Version:
Collection of ~170 lightweight, composable transducers, reducers, generators, iterators for functional data transformations
18 lines (17 loc) • 331 B
JavaScript
import { $$reduce, reducer } from "./reduce.js";
function fill(...args) {
const res = $$reduce(fill, args);
if (res !== void 0) return res;
let start = args[0] || 0;
return reducer(
() => [],
(acc, x) => (acc[start++] = x, acc)
);
}
function fillN(...args) {
return fill(...args);
}
export {
fill,
fillN
};