https://github.com/parzh/iterable-numbers
https://github.com/parzh/iterable-numbers
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/parzh/iterable-numbers
- Owner: parzh
- Created: 2020-09-10T19:52:48.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-09-10T20:56:41.000Z (over 5 years ago)
- Last Synced: 2025-02-27T23:52:18.301Z (about 1 year ago)
- Language: JavaScript
- Size: 117 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `iterable-numbers`
Allows using plain primitive numbers in iteration.
## Installation
```js
import "iterable-numbers";
// or:
require("iterable-numbers");
```
## Usage
### `for..of` loop:
```js
for (const number of 5) {
console.log(number); // 0, 1, 2, 3, 4
}
```
### `Array.from`:
```js
const array = Array.from(5);
console.log(array);
// [ 0, 1, 2, 3, 4 ]
```
### Spread operator (`...`):
```js
const array = [ ...5 ];
console.log(array);
// [ 0, 1, 2, 3, 4 ]
```