Skip to content
Subhajit Sahu edited this page May 9, 2020 · 27 revisions

Repeats an iterable given times. 🏃 📼 📦 🌔

iterable.repeat(x, n);
// x: an iterable
// n: times (-1 => Inf)
const iterable = require('extra-iterable');

var x = [1, 2];
[...iterable.repeat(x, 2)];
// [1, 2, 1, 2]

[...iterable.repeat(x, 3)];
// [1, 2, 1, 2, 1, 2]

references

Clone this wiki locally