@thi.ng/arrays 2.1.2 → 2.1.3

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +10 -1
  2. package/package.json +12 -12
  3. package/shuffle.js +5 -8
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2021-11-21T17:09:28Z
3
+ - **Last updated**: 2021-12-13T10:25:59Z
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,15 @@ 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.1.3](https://github.com/thi-ng/umbrella/tree/@thi.ng/arrays@2.1.3) (2021-12-13)
13
+
14
+ #### 🩹 Bug fixes
15
+
16
+ - off-by-one error in shuffleRange() ([f832d2f](https://github.com/thi-ng/umbrella/commit/f832d2f))
17
+ - existing shuffle would keep some indices untouched, resulting in
18
+ still perceivable ordering
19
+ - update tests
20
+
12
21
  ## [2.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/arrays@2.1.0) (2021-11-17)
13
22
 
14
23
  #### 🚀 Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/arrays",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "description": "Array / Arraylike utilities",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -34,20 +34,20 @@
34
34
  "test": "testament test"
35
35
  },
36
36
  "dependencies": {
37
- "@thi.ng/api": "^8.3.2",
38
- "@thi.ng/checks": "^3.1.2",
39
- "@thi.ng/compare": "^2.1.2",
40
- "@thi.ng/equiv": "^2.1.2",
41
- "@thi.ng/errors": "^2.1.2",
42
- "@thi.ng/random": "^3.2.2"
37
+ "@thi.ng/api": "^8.3.3",
38
+ "@thi.ng/checks": "^3.1.3",
39
+ "@thi.ng/compare": "^2.1.3",
40
+ "@thi.ng/equiv": "^2.1.3",
41
+ "@thi.ng/errors": "^2.1.3",
42
+ "@thi.ng/random": "^3.2.3"
43
43
  },
44
44
  "devDependencies": {
45
- "@microsoft/api-extractor": "^7.18.19",
46
- "@thi.ng/testament": "^0.2.2",
45
+ "@microsoft/api-extractor": "^7.19.2",
46
+ "@thi.ng/testament": "^0.2.3",
47
47
  "rimraf": "^3.0.2",
48
48
  "tools": "^0.0.1",
49
- "typedoc": "^0.22.9",
50
- "typescript": "^4.5.2"
49
+ "typedoc": "^0.22.10",
50
+ "typescript": "^4.5.3"
51
51
  },
52
52
  "keywords": [
53
53
  "aos",
@@ -140,5 +140,5 @@
140
140
  "thi.ng": {
141
141
  "year": 2018
142
142
  },
143
- "gitHead": "e8a7c2a40191b391cef182c2978e5a6c85987a87\n"
143
+ "gitHead": "2db9dd34c0c2c60cbfde3dad0bca352b20292f5c\n"
144
144
  }
package/shuffle.js CHANGED
@@ -16,15 +16,12 @@ import { SYSTEM } from "@thi.ng/random/system";
16
16
  */
17
17
  export const shuffleRange = (buf, start = 0, end = buf.length, rnd = SYSTEM) => {
18
18
  assert(start >= 0 && end >= start && end <= buf.length, `illegal range ${start}..${end}`);
19
- let n = end - start;
20
- const l = n;
21
- if (l > 1) {
22
- while (n-- > 0) {
23
- const a = (start + rnd.float(l)) | 0;
24
- const b = (start + rnd.float(l)) | 0;
19
+ if (end - start > 1) {
20
+ for (let i = end; i-- > start;) {
21
+ const a = rnd.minmax(start, i + 1) | 0;
25
22
  const t = buf[a];
26
- buf[a] = buf[b];
27
- buf[b] = t;
23
+ buf[a] = buf[i];
24
+ buf[i] = t;
28
25
  }
29
26
  }
30
27
  return buf;