fill - nodef/extra-iterable GitHub Wiki

Fill with given value.

Similar: copy, fill.

function fill(x, v, i, I)
// x: an iterable
// v: value
// i: start index [0]
// I: end index [END]
const xiterable = require('extra-iterable');

var x = [1, 2, 3, 4];
[...xiterable.fill(x, 2)];
// → [2, 2, 2, 2]

[...xiterable.fill(x, 2, 1)];
// → [1, 2, 2, 2]

[...xiterable.fill(x, 2, 1, 3)];
// → [1, 2, 2, 4]

References