0.0.10 • Published 3 years ago

@tothemungai/range v0.0.10

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Range

A simple minimal JS implementation of Python's range()

Installation

npm install @tothemungai/range

const range = require("@tothemungai/range");

API

range(start: number, end: number, step: number, options?: {includeStart: boolean = true, includeEnd: boolean = true})

Simple iteration

for(let i of range(1, 3)) console.log(i);

//output
1
2
3

Iteration using steps

for(let i of range(0, 4, 2)) console.log(i);

//output
0
2
4

Spread the range values

[...range(1, 3)]

//produces
[1, 2, 3]

Spread the range values (with steps)

[...range(0, 4, 2)]

//produces
[0, 2, 4]

Exclude end value

[...range(1, 3, 1, {includeEnd: false})]

//produces
[1, 2]

Exclude start value

[...range(1, 3, 1, {includeStart: false})]

//produces
[2, 3]
0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago