@thi.ng/arrays 2.9.13 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-07-22T13:15:57Z
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
  [![Mastodon Follow](https://img.shields.io/mastodon/follow/109331703950160316?domain=https%3A%2F%2Fmastodon.thi.ng&style=social)](https://mastodon.thi.ng/@toxi)
8
8
 
9
9
  > [!NOTE]
10
- > This is one of 198 standalone projects, maintained as part
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
  >
@@ -75,17 +75,18 @@ Note: @thi.ng/api is in _most_ cases a type-only import (not used at runtime)
75
75
 
76
76
  ## Usage examples
77
77
 
78
- Five projects in this repo's
78
+ Six projects in this repo's
79
79
  [/examples](https://github.com/thi-ng/umbrella/tree/develop/examples)
80
80
  directory are using this package:
81
81
 
82
- | Screenshot | Description | Live demo | Source |
83
- |:-----------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------|:------------------------------------------------------|:-----------------------------------------------------------------------------------|
84
- | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/kmeans-viz.jpg" width="240"/> | k-means clustering visualization | [Demo](https://demo.thi.ng/umbrella/kmeans-viz/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/kmeans-viz) |
85
- | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/pixel-gradients.jpg" width="240"/> | Randomized 4-point 2D color gradient image generator | [Demo](https://demo.thi.ng/umbrella/pixel-gradients/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/pixel-gradients) |
86
- | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/poly-subdiv.jpg" width="240"/> | Animated, iterative polygon subdivisions & visualization | [Demo](https://demo.thi.ng/umbrella/poly-subdiv/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/poly-subdiv) |
87
- | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/related-images.jpg" width="240"/> | Responsive image gallery with tag-based Jaccard similarity ranking | [Demo](https://demo.thi.ng/umbrella/related-images/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/related-images) |
88
- | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/stacked-layout.png" width="240"/> | Responsive & reactively computed stacked column layout | [Demo](https://demo.thi.ng/umbrella/stacked-layout/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/stacked-layout) |
82
+ | Screenshot | Description | Live demo | Source |
83
+ |:-----------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------------------|:------------------------------------------------------|:-----------------------------------------------------------------------------------|
84
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/kmeans-viz.jpg" width="240"/> | k-means clustering visualization | [Demo](https://demo.thi.ng/umbrella/kmeans-viz/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/kmeans-viz) |
85
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/pixel-gradients.jpg" width="240"/> | Randomized 4-point 2D color gradient image generator | [Demo](https://demo.thi.ng/umbrella/pixel-gradients/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/pixel-gradients) |
86
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/poly-subdiv.jpg" width="240"/> | Animated, iterative polygon subdivisions & visualization | [Demo](https://demo.thi.ng/umbrella/poly-subdiv/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/poly-subdiv) |
87
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/related-images.jpg" width="240"/> | Responsive image gallery with tag-based Jaccard similarity ranking | [Demo](https://demo.thi.ng/umbrella/related-images/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/related-images) |
88
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/stacked-layout.png" width="240"/> | Responsive & reactively computed stacked column layout | [Demo](https://demo.thi.ng/umbrella/stacked-layout/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/stacked-layout) |
89
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/thing-browser.avif" width="240"/> | Tree-based UI to find & explore thi.ng projects via their associated keywords | [Demo](https://demo.thi.ng/umbrella/thing-browser/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/thing-browser) |
89
90
 
90
91
  ## API
91
92
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/arrays",
3
- "version": "2.9.13",
3
+ "version": "2.10.0",
4
4
  "description": "Array / Arraylike utilities",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -36,18 +36,18 @@
36
36
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
37
37
  },
38
38
  "dependencies": {
39
- "@thi.ng/api": "^8.11.7",
40
- "@thi.ng/checks": "^3.6.9",
41
- "@thi.ng/compare": "^2.3.10",
42
- "@thi.ng/equiv": "^2.1.63",
43
- "@thi.ng/errors": "^2.5.13",
44
- "@thi.ng/random": "^4.0.1"
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
- "@microsoft/api-extractor": "^7.47.0",
47
+ "@microsoft/api-extractor": "^7.47.5",
48
48
  "esbuild": "^0.23.0",
49
- "typedoc": "^0.26.3",
50
- "typescript": "^5.5.3"
49
+ "typedoc": "^0.26.5",
50
+ "typescript": "^5.5.4"
51
51
  },
52
52
  "keywords": [
53
53
  "aos",
@@ -168,5 +168,5 @@
168
168
  "thi.ng": {
169
169
  "year": 2018
170
170
  },
171
- "gitHead": "bd22b0826134b79064169371665b4d6caa9b6066\n"
171
+ "gitHead": "f6e26ea1142525171de5d36b9c3119f2782bb437\n"
172
172
  }
package/topo-sort.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Fn, Nullable, IObjectOf } from "@thi.ng/api";
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: Fn<T, Nullable<string[]>>) => string[];
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 { illegalState } from "@thi.ng/errors";
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
- if (cycles[id]) illegalState(`dependency cycle: ${path.join(" -> ")}`);
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
  }