@naturalcycles/js-lib 15.7.0 → 15.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/array/range.js +7 -2
- package/package.json +1 -1
- package/src/array/range.ts +7 -7
package/dist/array/range.js
CHANGED
|
@@ -2,9 +2,14 @@ import { AsyncIterable2 } from '../iter/asyncIterable2.js';
|
|
|
2
2
|
import { Iterable2 } from '../iter/iterable2.js';
|
|
3
3
|
export function _range(fromIncl, toExcl, step = 1) {
|
|
4
4
|
if (toExcl === undefined) {
|
|
5
|
-
|
|
5
|
+
toExcl = fromIncl;
|
|
6
|
+
fromIncl = 0;
|
|
7
|
+
}
|
|
8
|
+
const a = [];
|
|
9
|
+
for (let i = fromIncl; i < toExcl; i += step) {
|
|
10
|
+
a.push(i);
|
|
6
11
|
}
|
|
7
|
-
return
|
|
12
|
+
return a;
|
|
8
13
|
}
|
|
9
14
|
export function _rangeIterable(fromIncl, toExcl, step = 1) {
|
|
10
15
|
if (toExcl === undefined) {
|
package/package.json
CHANGED
package/src/array/range.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { AsyncIterable2 } from '../iter/asyncIterable2.js'
|
|
2
2
|
import { Iterable2 } from '../iter/iterable2.js'
|
|
3
3
|
|
|
4
|
-
/* eslint-disable unicorn/no-new-array */
|
|
5
|
-
|
|
6
4
|
/**
|
|
7
5
|
* Returns an array with ranges from `from` up to (but not including) `to`.
|
|
8
6
|
*
|
|
@@ -17,13 +15,15 @@ export function _range(toExcl: number): number[]
|
|
|
17
15
|
export function _range(fromIncl: number, toExcl: number, step?: number): number[]
|
|
18
16
|
export function _range(fromIncl: number, toExcl?: number, step = 1): number[] {
|
|
19
17
|
if (toExcl === undefined) {
|
|
20
|
-
|
|
18
|
+
toExcl = fromIncl
|
|
19
|
+
fromIncl = 0
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
(
|
|
26
|
-
|
|
22
|
+
const a: number[] = []
|
|
23
|
+
for (let i = fromIncl; i < toExcl; i += step) {
|
|
24
|
+
a.push(i)
|
|
25
|
+
}
|
|
26
|
+
return a
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/**
|