@thi.ng/arrays 2.9.14 → 2.10.0
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 +9 -1
- package/README.md +1 -1
- package/package.json +8 -8
- package/topo-sort.d.ts +2 -3
- package/topo-sort.js +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-08-
|
|
3
|
+
- **Last updated**: 2024-08-18T14:11:34Z
|
|
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,14 @@ 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.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/arrays@2.10.0) (2024-08-18)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- update topoSort() ([6606d08](https://github.com/thi-ng/umbrella/commit/6606d08))
|
|
17
|
+
- add missing node check/assertion
|
|
18
|
+
- update `deps` fn to incl. node ID as 2nd arg
|
|
19
|
+
|
|
12
20
|
### [2.9.7](https://github.com/thi-ng/umbrella/tree/@thi.ng/arrays@2.9.7) (2024-06-21)
|
|
13
21
|
|
|
14
22
|
#### ♻️ Refactoring
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
> [!NOTE]
|
|
10
|
-
> This is one of
|
|
10
|
+
> This is one of 199 standalone projects, maintained as part
|
|
11
11
|
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
|
|
12
12
|
> and anti-framework.
|
|
13
13
|
>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/arrays",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0",
|
|
4
4
|
"description": "Array / Arraylike utilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@thi.ng/api": "^8.11.
|
|
40
|
-
"@thi.ng/checks": "^3.6.
|
|
41
|
-
"@thi.ng/compare": "^2.4.
|
|
42
|
-
"@thi.ng/equiv": "^2.1.
|
|
43
|
-
"@thi.ng/errors": "^2.5.
|
|
44
|
-
"@thi.ng/random": "^4.0.
|
|
39
|
+
"@thi.ng/api": "^8.11.9",
|
|
40
|
+
"@thi.ng/checks": "^3.6.11",
|
|
41
|
+
"@thi.ng/compare": "^2.4.1",
|
|
42
|
+
"@thi.ng/equiv": "^2.1.65",
|
|
43
|
+
"@thi.ng/errors": "^2.5.15",
|
|
44
|
+
"@thi.ng/random": "^4.0.3"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@microsoft/api-extractor": "^7.47.5",
|
|
@@ -168,5 +168,5 @@
|
|
|
168
168
|
"thi.ng": {
|
|
169
169
|
"year": 2018
|
|
170
170
|
},
|
|
171
|
-
"gitHead": "
|
|
171
|
+
"gitHead": "f6e26ea1142525171de5d36b9c3119f2782bb437\n"
|
|
172
172
|
}
|
package/topo-sort.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Fn2, IObjectOf, Nullable } from "@thi.ng/api";
|
|
2
2
|
/**
|
|
3
3
|
* Takes an object describing a DAG of nodes of type T with keys being node IDs.
|
|
4
4
|
* Also takes a function which will be applied to each node and either returns
|
|
@@ -37,7 +37,6 @@ import type { Fn, Nullable, IObjectOf } from "@thi.ng/api";
|
|
|
37
37
|
*
|
|
38
38
|
* @param nodes
|
|
39
39
|
* @param deps
|
|
40
|
-
* @returns
|
|
41
40
|
*/
|
|
42
|
-
export declare const topoSort: <T>(nodes: IObjectOf<T>, deps:
|
|
41
|
+
export declare const topoSort: <T>(nodes: IObjectOf<T>, deps: Fn2<T, string, Nullable<string[]>>) => string[];
|
|
43
42
|
//# sourceMappingURL=topo-sort.d.ts.map
|
package/topo-sort.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { assert } from "@thi.ng/errors/assert";
|
|
2
2
|
const topoSort = (nodes, deps) => {
|
|
3
3
|
const cycles = {};
|
|
4
4
|
const topology = [];
|
|
5
5
|
const sort = (id, path) => {
|
|
6
|
-
|
|
6
|
+
assert(nodes[id] != null, `missing node: ${id}`);
|
|
7
|
+
assert(!cycles[id], `dependency cycle: ${path.join(" -> ")}`);
|
|
7
8
|
cycles[id] = true;
|
|
8
|
-
const nodeDeps = deps(nodes[id]);
|
|
9
|
+
const nodeDeps = deps(nodes[id], id);
|
|
9
10
|
if (nodeDeps) {
|
|
10
11
|
for (let d of nodeDeps) sort(d, [...path, d]);
|
|
11
12
|
}
|