@thi.ng/arrays 2.10.9 → 2.10.11

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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2025-01-04T21:07:38Z
3
+ - **Last updated**: 2025-01-17T14:10:58Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
@@ -9,6 +9,22 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ ### [2.10.11](https://github.com/thi-ng/umbrella/tree/@thi.ng/arrays@2.10.11) (2025-01-17)
13
+
14
+ #### 🩹 Bug fixes
15
+
16
+ - fix [#495](https://github.com/thi-ng/umbrella/issues/495), update shuffleRange() ([21a4c41](https://github.com/thi-ng/umbrella/commit/21a4c41))
17
+ - fix/undo [8cbfc7b0c8](https://github.com/thi-ng/umbrella/commit/8cbfc7b0c8)
18
+ - update loop type & condition to skip last iteration
19
+ - switch back to using `rnd.minmax()`
20
+ - see [comment](https://github.com/thi-ng/umbrella/issues/495#issuecomment-2595138357)
21
+
22
+ #### ⏱ Performance improvements
23
+
24
+ - fix [#495](https://github.com/thi-ng/umbrella/issues/495), update shuffleRange() ([8cbfc7b](https://github.com/thi-ng/umbrella/commit/8cbfc7b))
25
+ - update loop to skip last iteration (obsolete)
26
+ - use `rnd.minmaxInt()` to compute swap index
27
+
12
28
  ## [2.10.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/arrays@2.10.0) (2024-08-18)
13
29
 
14
30
  #### 🚀 Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/arrays",
3
- "version": "2.10.9",
3
+ "version": "2.10.11",
4
4
  "description": "Array / Arraylike utilities",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@thi.ng/api": "^8.11.16",
44
- "@thi.ng/checks": "^3.6.18",
44
+ "@thi.ng/checks": "^3.6.19",
45
45
  "@thi.ng/compare": "^2.4.8",
46
46
  "@thi.ng/equiv": "^2.1.72",
47
47
  "@thi.ng/errors": "^2.5.22",
@@ -172,5 +172,5 @@
172
172
  "thi.ng": {
173
173
  "year": 2018
174
174
  },
175
- "gitHead": "56c1d57a96565bbcc8c06c73779a619bba0db368\n"
175
+ "gitHead": "d888087b36b086fd8c3e7dc98d35857266f78942\n"
176
176
  }
package/shuffle.js CHANGED
@@ -5,13 +5,11 @@ const shuffleRange = (buf, start = 0, end = buf.length, rnd = SYSTEM) => {
5
5
  start >= 0 && end >= start && end <= buf.length,
6
6
  `illegal range ${start}..${end}`
7
7
  );
8
- if (end - start > 1) {
9
- for (let i = end; i-- > start; ) {
10
- const a = rnd.minmax(start, i + 1) | 0;
11
- const t = buf[a];
12
- buf[a] = buf[i];
13
- buf[i] = t;
14
- }
8
+ while (end > start + 1) {
9
+ const i = rnd.minmax(start, end) | 0;
10
+ const t = buf[i];
11
+ buf[i] = buf[--end];
12
+ buf[end] = t;
15
13
  }
16
14
  return buf;
17
15
  };