Skip to content

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

License

Notifications You must be signed in to change notification settings

atomic8ball/seq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

seq

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

Basic Usage

npm install list-sequence

var seq = require('list-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]

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published