@thi.ng/arrays 2.0.8 → 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.
- package/CHANGELOG.md +111 -60
- package/package.json +143 -138
- package/shuffle.js +5 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,123 +1,174 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
- **Last updated**: 2021-12-13T10:25:59Z
|
|
4
|
+
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
|
+
|
|
3
6
|
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
7
|
+
See [Conventional Commits](https://conventionalcommits.org/) for commit guidelines.
|
|
8
|
+
|
|
9
|
+
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
|
+
and/or version bumps of transitive dependencies.
|
|
5
11
|
|
|
6
|
-
|
|
12
|
+
### [2.1.3](https://github.com/thi-ng/umbrella/tree/@thi.ng/arrays@2.1.3) (2021-12-13)
|
|
7
13
|
|
|
8
|
-
|
|
14
|
+
#### 🩹 Bug fixes
|
|
9
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
|
|
10
20
|
|
|
21
|
+
## [2.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/arrays@2.1.0) (2021-11-17)
|
|
11
22
|
|
|
23
|
+
#### 🚀 Features
|
|
12
24
|
|
|
25
|
+
- Using workspaces for local tools ([bf7a404](https://github.com/thi-ng/umbrella/commit/bf7a404))
|
|
26
|
+
Improving the overall build ergonomics
|
|
27
|
+
- introduced a tools workspaces
|
|
28
|
+
- imported it in all needed packages/examples
|
|
29
|
+
- inclusive project root
|
|
13
30
|
|
|
14
|
-
|
|
31
|
+
#### ♻️ Refactoring
|
|
15
32
|
|
|
16
|
-
|
|
33
|
+
- testrunner to binary ([4ebbbb2](https://github.com/thi-ng/umbrella/commit/4ebbbb2))
|
|
34
|
+
this commit reverts (partly) changes made in:
|
|
35
|
+
ef346d7a8753590dc9094108a3d861a8dbd5dd2c
|
|
36
|
+
overall purpose is better testament ergonomics:
|
|
37
|
+
instead of having to pass NODE_OPTIONS with every invocation
|
|
38
|
+
having a binary to handle this for us.
|
|
17
39
|
|
|
40
|
+
### [2.0.8](https://github.com/thi-ng/umbrella/tree/@thi.ng/arrays@2.0.8) (2021-11-10)
|
|
18
41
|
|
|
42
|
+
#### ♻️ Refactoring
|
|
19
43
|
|
|
44
|
+
- update all countdown loops ([a5f374b](https://github.com/thi-ng/umbrella/commit/a5f374b))
|
|
20
45
|
|
|
46
|
+
### [2.0.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/arrays@2.0.1) (2021-10-13)
|
|
21
47
|
|
|
22
|
-
|
|
48
|
+
#### ♻️ Refactoring
|
|
23
49
|
|
|
50
|
+
- update imports in all tests/pkgs ([effd591](https://github.com/thi-ng/umbrella/commit/effd591))
|
|
51
|
+
- update imports in all pkgs ([5fa2b6f](https://github.com/thi-ng/umbrella/commit/5fa2b6f))
|
|
52
|
+
- add .js suffix for all relative imports
|
|
24
53
|
|
|
25
|
-
|
|
54
|
+
# [2.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/arrays@2.0.0) (2021-10-12)
|
|
26
55
|
|
|
27
|
-
|
|
56
|
+
#### 🛑 Breaking changes
|
|
28
57
|
|
|
58
|
+
- major update of ALL pkgs (export maps, ESM only) ([0d1d6ea](https://github.com/thi-ng/umbrella/commit/0d1d6ea))
|
|
59
|
+
- BREAKING CHANGE: discontinue CommonJS & UMD versions
|
|
60
|
+
- only ESM modules will be published from now on
|
|
61
|
+
- CJS obsolete due to ESM support in recent versions of node:
|
|
62
|
+
- i.e. launch NodeJS via:
|
|
63
|
+
- `node --experimental-specifier-resolution=node --experimental-repl-await`
|
|
64
|
+
- in the node REPL use `await import(...)` instead of `require()`
|
|
65
|
+
- UMD obsolete due to widespread browser support for ESM
|
|
66
|
+
Also:
|
|
67
|
+
- normalize/restructure/reorg all package.json files
|
|
68
|
+
- cleanup all build scripts, remove obsolete
|
|
69
|
+
- switch from mocha to [@thi.ng/testament](https://github.com/thi-ng/umbrella/tree/main/packages/testament) for all tests
|
|
29
70
|
|
|
30
|
-
|
|
71
|
+
#### ♻️ Refactoring
|
|
31
72
|
|
|
32
|
-
|
|
73
|
+
- update deps & imports in various pkgs ([e1cf29e](https://github.com/thi-ng/umbrella/commit/e1cf29e))
|
|
74
|
+
- largely related to recent updates/restructuring of these packages:
|
|
75
|
+
- api
|
|
76
|
+
- defmulti
|
|
77
|
+
- errors
|
|
78
|
+
- logger
|
|
79
|
+
- update imports ([ad3c3af](https://github.com/thi-ng/umbrella/commit/ad3c3af))
|
|
80
|
+
- update all tests in _all_ pkgs ([8b582bc](https://github.com/thi-ng/umbrella/commit/8b582bc))
|
|
81
|
+
- update all to use [@thi.ng/testament](https://github.com/thi-ng/umbrella/tree/main/packages/testament)
|
|
33
82
|
|
|
34
|
-
-
|
|
35
|
-
- CJS obsolete due to ESM support in recent versions of node:
|
|
36
|
-
- i.e. launch NodeJS via:
|
|
37
|
-
- `node --experimental-specifier-resolution=node --experimental-repl-await`
|
|
38
|
-
- in the node REPL use `await import(...)` instead of `require()`
|
|
39
|
-
- UMD obsolete due to widespread browser support for ESM
|
|
83
|
+
## [0.10.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/arrays@0.10.0) (2021-01-21)
|
|
40
84
|
|
|
41
|
-
|
|
42
|
-
- normalize/restructure/reorg all package.json files
|
|
43
|
-
- cleanup all build scripts, remove obsolete
|
|
44
|
-
- switch from mocha to @thi.ng/testament for all tests
|
|
85
|
+
#### 🚀 Features
|
|
45
86
|
|
|
87
|
+
- add insert/insertUnsafe() ([2a78598](https://github.com/thi-ng/umbrella/commit/2a78598))
|
|
46
88
|
|
|
89
|
+
#### 🩹 Bug fixes
|
|
47
90
|
|
|
91
|
+
- fixed-length binarySearch2/4/8/16/32 ([39e5c37](https://github.com/thi-ng/umbrella/commit/39e5c37))
|
|
92
|
+
- add binarySearch2()
|
|
93
|
+
- fix results for not-found values, make compatible w/ binarySearch()
|
|
48
94
|
|
|
95
|
+
## [0.9.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/arrays@0.9.0) (2021-01-02)
|
|
49
96
|
|
|
97
|
+
#### 🚀 Features
|
|
50
98
|
|
|
51
|
-
|
|
99
|
+
- update sortByCachedKey(), add tests ([64e8f6e](https://github.com/thi-ng/umbrella/commit/64e8f6e))
|
|
100
|
+
- add support for pre-cached key array instead of key fn
|
|
101
|
+
- add into(), sortByCachedKey() ([b94f64c](https://github.com/thi-ng/umbrella/commit/b94f64c))
|
|
102
|
+
- add bisect(), bisectWith() ([17d06a4](https://github.com/thi-ng/umbrella/commit/17d06a4))
|
|
52
103
|
|
|
53
|
-
|
|
104
|
+
## [0.8.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/arrays@0.8.0) (2020-09-13)
|
|
54
105
|
|
|
55
|
-
|
|
106
|
+
#### 🚀 Features
|
|
56
107
|
|
|
57
|
-
|
|
108
|
+
- add first() ([3f5f722](https://github.com/thi-ng/umbrella/commit/3f5f722))
|
|
58
109
|
|
|
59
|
-
|
|
110
|
+
#### ♻️ Refactoring
|
|
60
111
|
|
|
61
|
-
|
|
112
|
+
- update imports, use new Fn types ([1e3b6ac](https://github.com/thi-ng/umbrella/commit/1e3b6ac))
|
|
113
|
+
- update imports, use new function aliases ([136482e](https://github.com/thi-ng/umbrella/commit/136482e))
|
|
62
114
|
|
|
63
|
-
|
|
115
|
+
## [0.7.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/arrays@0.7.0) (2020-08-28)
|
|
64
116
|
|
|
65
|
-
|
|
117
|
+
#### 🚀 Features
|
|
66
118
|
|
|
67
|
-
|
|
119
|
+
- add non-recursive binary search fns ([29a4ee4](https://github.com/thi-ng/umbrella/commit/29a4ee4))
|
|
120
|
+
- add fixed size binarySearch4/8/16/32()
|
|
68
121
|
|
|
69
|
-
|
|
70
|
-
- **arrays:** add into(), sortByCachedKey() ([b94f64c](https://github.com/thi-ng/umbrella/commit/b94f64c2c351cfed5ea9ade5e42ad0b7076ef9e9))
|
|
71
|
-
- **arrays:** update sortByCachedKey(), add tests ([64e8f6e](https://github.com/thi-ng/umbrella/commit/64e8f6e4e83c26c73e23a4831483bd328b78bc49))
|
|
122
|
+
## [0.6.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/arrays@0.6.0) (2020-03-28)
|
|
72
123
|
|
|
73
|
-
|
|
124
|
+
#### 🚀 Features
|
|
74
125
|
|
|
75
|
-
|
|
126
|
+
- add fillRange() & levenshtein() ([2f98225](https://github.com/thi-ng/umbrella/commit/2f98225))
|
|
76
127
|
|
|
77
|
-
|
|
128
|
+
### [0.5.2](https://github.com/thi-ng/umbrella/tree/@thi.ng/arrays@0.5.2) (2020-02-25)
|
|
78
129
|
|
|
79
|
-
|
|
130
|
+
#### ♻️ Refactoring
|
|
80
131
|
|
|
81
|
-
|
|
132
|
+
- update imports ([35765a8](https://github.com/thi-ng/umbrella/commit/35765a8))
|
|
82
133
|
|
|
83
|
-
|
|
134
|
+
## [0.5.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/arrays@0.5.0) (2020-01-24)
|
|
84
135
|
|
|
85
|
-
|
|
136
|
+
#### 🚀 Features
|
|
86
137
|
|
|
87
|
-
|
|
138
|
+
- add binary search predicates, tests, update readme ([b8f421e](https://github.com/thi-ng/umbrella/commit/b8f421e))
|
|
88
139
|
|
|
89
|
-
|
|
140
|
+
## [0.4.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/arrays@0.4.0) (2019-11-30)
|
|
90
141
|
|
|
91
|
-
|
|
142
|
+
#### 🚀 Features
|
|
92
143
|
|
|
93
|
-
|
|
144
|
+
- add arraySeq(), arrayIterator() & tests ([d94df57](https://github.com/thi-ng/umbrella/commit/d94df57))
|
|
145
|
+
- add binarySearchNumeric() ([7b38202](https://github.com/thi-ng/umbrella/commit/7b38202))
|
|
94
146
|
|
|
95
|
-
|
|
147
|
+
#### ♻️ Refactoring
|
|
96
148
|
|
|
97
|
-
|
|
149
|
+
- remove arraySeq() (migrated to [@thi.ng/seq](https://github.com/thi-ng/umbrella/tree/main/packages/seq)) ([779c433](https://github.com/thi-ng/umbrella/commit/779c433))
|
|
98
150
|
|
|
99
|
-
|
|
151
|
+
## [0.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/arrays@0.3.0) (2019-11-09)
|
|
100
152
|
|
|
101
|
-
|
|
102
|
-
- **arrays:** add binarySearchNumeric() ([7b38202](https://github.com/thi-ng/umbrella/commit/7b38202480db71753d24aa52a9c09d3ac78d36ae))
|
|
153
|
+
#### 🚀 Features
|
|
103
154
|
|
|
104
|
-
|
|
155
|
+
- add isSorted() ([65b29f4](https://github.com/thi-ng/umbrella/commit/65b29f4))
|
|
156
|
+
- add types, quickSort(), swap(), multiSwap(), update readme ([b834722](https://github.com/thi-ng/umbrella/commit/b834722))
|
|
157
|
+
- add shuffleRange(), refactor shuffle(), add tests ([1924a05](https://github.com/thi-ng/umbrella/commit/1924a05))
|
|
105
158
|
|
|
106
|
-
|
|
159
|
+
## [0.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/arrays@0.2.0) (2019-07-07)
|
|
107
160
|
|
|
108
|
-
|
|
109
|
-
- **arrays:** add shuffleRange(), refactor shuffle(), add tests ([1924a05](https://github.com/thi-ng/umbrella/commit/1924a05ea093e3d1d0b3f063cb331b330cee0c0a))
|
|
110
|
-
- **arrays:** add types, quickSort(), swap(), multiSwap(), update readme ([b834722](https://github.com/thi-ng/umbrella/commit/b83472237b3ba262dcbb644c8ccc516d0021bc84))
|
|
161
|
+
#### 🚀 Features
|
|
111
162
|
|
|
112
|
-
|
|
163
|
+
- enable TS strict compiler flags (refactor) ([8724f9e](https://github.com/thi-ng/umbrella/commit/8724f9e))
|
|
113
164
|
|
|
114
|
-
|
|
165
|
+
## [0.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/arrays@0.1.0) (2019-02-15)
|
|
115
166
|
|
|
116
|
-
|
|
167
|
+
#### 🚀 Features
|
|
117
168
|
|
|
118
|
-
|
|
169
|
+
- add find/findIndex() ([0007152](https://github.com/thi-ng/umbrella/commit/0007152))
|
|
170
|
+
- extract as new package ([361ba37](https://github.com/thi-ng/umbrella/commit/361ba37))
|
|
119
171
|
|
|
120
|
-
|
|
172
|
+
#### ♻️ Refactoring
|
|
121
173
|
|
|
122
|
-
-
|
|
123
|
-
- **arrays:** extract as new package ([361ba37](https://github.com/thi-ng/umbrella/commit/361ba37))
|
|
174
|
+
- update arg order, fix shuffle() ([b01abaa](https://github.com/thi-ng/umbrella/commit/b01abaa))
|
package/package.json
CHANGED
|
@@ -1,139 +1,144 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
2
|
+
"name": "@thi.ng/arrays",
|
|
3
|
+
"version": "2.1.3",
|
|
4
|
+
"description": "Array / Arraylike utilities",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"module": "./index.js",
|
|
7
|
+
"typings": "./index.d.ts",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/thi-ng/umbrella.git"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/thi-ng/umbrella/tree/develop/packages/arrays#readme",
|
|
14
|
+
"funding": [
|
|
15
|
+
{
|
|
16
|
+
"type": "github",
|
|
17
|
+
"url": "https://github.com/sponsors/postspectacular"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"type": "patreon",
|
|
21
|
+
"url": "https://patreon.com/thing_umbrella"
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"author": "Karsten Schmidt <k+npm@thi.ng>",
|
|
25
|
+
"license": "Apache-2.0",
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "yarn clean && tsc --declaration",
|
|
28
|
+
"clean": "rimraf '*.js' '*.d.ts' '*.map' doc",
|
|
29
|
+
"doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
|
|
30
|
+
"doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
|
|
31
|
+
"doc:readme": "yarn doc:stats && tools:readme",
|
|
32
|
+
"doc:stats": "tools:module-stats",
|
|
33
|
+
"pub": "yarn npm publish --access public",
|
|
34
|
+
"test": "testament test"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
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
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@microsoft/api-extractor": "^7.19.2",
|
|
46
|
+
"@thi.ng/testament": "^0.2.3",
|
|
47
|
+
"rimraf": "^3.0.2",
|
|
48
|
+
"tools": "^0.0.1",
|
|
49
|
+
"typedoc": "^0.22.10",
|
|
50
|
+
"typescript": "^4.5.3"
|
|
51
|
+
},
|
|
52
|
+
"keywords": [
|
|
53
|
+
"aos",
|
|
54
|
+
"array",
|
|
55
|
+
"binary",
|
|
56
|
+
"fuzzy",
|
|
57
|
+
"search",
|
|
58
|
+
"shuffle",
|
|
59
|
+
"swizzle",
|
|
60
|
+
"typescript"
|
|
61
|
+
],
|
|
62
|
+
"publishConfig": {
|
|
63
|
+
"access": "public"
|
|
64
|
+
},
|
|
65
|
+
"engines": {
|
|
66
|
+
"node": ">=12.7"
|
|
67
|
+
},
|
|
68
|
+
"files": [
|
|
69
|
+
"*.js",
|
|
70
|
+
"*.d.ts"
|
|
71
|
+
],
|
|
72
|
+
"exports": {
|
|
73
|
+
".": {
|
|
74
|
+
"import": "./index.js"
|
|
75
|
+
},
|
|
76
|
+
"./api": {
|
|
77
|
+
"import": "./api.js"
|
|
78
|
+
},
|
|
79
|
+
"./binary-search": {
|
|
80
|
+
"import": "./binary-search.js"
|
|
81
|
+
},
|
|
82
|
+
"./bisect": {
|
|
83
|
+
"import": "./bisect.js"
|
|
84
|
+
},
|
|
85
|
+
"./ends-with": {
|
|
86
|
+
"import": "./ends-with.js"
|
|
87
|
+
},
|
|
88
|
+
"./ensure-array": {
|
|
89
|
+
"import": "./ensure-array.js"
|
|
90
|
+
},
|
|
91
|
+
"./ensure-iterable": {
|
|
92
|
+
"import": "./ensure-iterable.js"
|
|
93
|
+
},
|
|
94
|
+
"./fill-range": {
|
|
95
|
+
"import": "./fill-range.js"
|
|
96
|
+
},
|
|
97
|
+
"./find": {
|
|
98
|
+
"import": "./find.js"
|
|
99
|
+
},
|
|
100
|
+
"./fuzzy-match": {
|
|
101
|
+
"import": "./fuzzy-match.js"
|
|
102
|
+
},
|
|
103
|
+
"./insert": {
|
|
104
|
+
"import": "./insert.js"
|
|
105
|
+
},
|
|
106
|
+
"./into": {
|
|
107
|
+
"import": "./into.js"
|
|
108
|
+
},
|
|
109
|
+
"./is-sorted": {
|
|
110
|
+
"import": "./is-sorted.js"
|
|
111
|
+
},
|
|
112
|
+
"./iterator": {
|
|
113
|
+
"import": "./iterator.js"
|
|
114
|
+
},
|
|
115
|
+
"./levenshtein": {
|
|
116
|
+
"import": "./levenshtein.js"
|
|
117
|
+
},
|
|
118
|
+
"./peek": {
|
|
119
|
+
"import": "./peek.js"
|
|
120
|
+
},
|
|
121
|
+
"./quicksort": {
|
|
122
|
+
"import": "./quicksort.js"
|
|
123
|
+
},
|
|
124
|
+
"./shuffle": {
|
|
125
|
+
"import": "./shuffle.js"
|
|
126
|
+
},
|
|
127
|
+
"./sort-cached": {
|
|
128
|
+
"import": "./sort-cached.js"
|
|
129
|
+
},
|
|
130
|
+
"./starts-with": {
|
|
131
|
+
"import": "./starts-with.js"
|
|
132
|
+
},
|
|
133
|
+
"./swap": {
|
|
134
|
+
"import": "./swap.js"
|
|
135
|
+
},
|
|
136
|
+
"./swizzle": {
|
|
137
|
+
"import": "./swizzle.js"
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
"thi.ng": {
|
|
141
|
+
"year": 2018
|
|
142
|
+
},
|
|
143
|
+
"gitHead": "2db9dd34c0c2c60cbfde3dad0bca352b20292f5c\n"
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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[
|
|
27
|
-
buf[
|
|
23
|
+
buf[a] = buf[i];
|
|
24
|
+
buf[i] = t;
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
27
|
return buf;
|