iterable-numbers
v1.0.2-rc
Published
Allows using plain primitive numbers in iteration.
Downloads
3
Maintainers
Readme
iterable-numbers
Allows using plain primitive numbers in iteration.
Installation
import "iterable-numbers";
// or:
require("iterable-numbers");
Usage
for..of
loop:
for (const number of 5) {
console.log(number); // 0, 1, 2, 3, 4
}
Array.from
:
const array = Array.from(5);
console.log(array);
// [ 0, 1, 2, 3, 4 ]
Spread operator (...
):
const array = [ ...5 ];
console.log(array);
// [ 0, 1, 2, 3, 4 ]