UNPKG

@thi.ng/arrays

Version:

Array / Arraylike utilities

12 lines (11 loc) 294 B
const fillRange = (buf, index = 0, start = 0, end = buf.length, step = end > start ? 1 : -1) => { if (step > 0) { for (; start < end; start += step) buf[index++] = start; } else { for (; start > end; start += step) buf[index++] = start; } return buf; }; export { fillRange };