list-sequence

simple and primitive array / list generation - a poor man's list comprehension

Usage no npm install needed!

<script type="module">
  import listSequence from 'https://cdn.skypack.dev/list-sequence';
</script>

README

seq

simple and primitive array / list generation - a poor man's list comprehension

Basic Usage

var seq = require('sequence');

// 4 iterations, default step is 1
seq(0, 4);

[0, 1, 2, 3]

// 4 iterations, step is 2
seq(0, 4, 2);

[0, 2, 4, 6]

// 7 iterations, custom step function
seq('a', 7, function(list, index) {
    return String.fromCharCode(list[index - 1].charCodeAt(0) + 1);
}); // seq / step

['a', 'b', 'c', 'd', 'e', 'f', 'g']

// 4 iterations, step is 1, filtered to evens only with filter function
// (return true if it gets to stay)
seq(0, 4, 1, function(x) {
    return x % 2 == 0;
}); // seq / filter

[0, 2]