@thi.ng/markdown-table 0.3.121 → 0.3.123
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 +7 -1
- package/README.md +2 -2
- package/package.json +13 -13
- package/table.d.ts +7 -5
- package/table.js +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-
|
|
3
|
+
- **Last updated**: 2024-06-21T19:34:38Z
|
|
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,12 @@ 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
|
+
### [0.3.123](https://github.com/thi-ng/umbrella/tree/@thi.ng/markdown-table@0.3.123) (2024-06-21)
|
|
13
|
+
|
|
14
|
+
#### ♻️ Refactoring
|
|
15
|
+
|
|
16
|
+
- enforce uniform naming convention of internal functions ([56992b2](https://github.com/thi-ng/umbrella/commit/56992b2))
|
|
17
|
+
|
|
12
18
|
### [0.3.78](https://github.com/thi-ng/umbrella/tree/@thi.ng/markdown-table@0.3.78) (2023-11-09)
|
|
13
19
|
|
|
14
20
|
#### ♻️ 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 193 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
|
>
|
|
@@ -66,7 +66,7 @@ For Node.js REPL:
|
|
|
66
66
|
const mt = await import("@thi.ng/markdown-table");
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
-
Package sizes (brotli'd, pre-treeshake): ESM:
|
|
69
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 617 bytes
|
|
70
70
|
|
|
71
71
|
## Dependencies
|
|
72
72
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/markdown-table",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.123",
|
|
4
4
|
"description": "Markdown table formatter/generator with support for column alignments",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/thi-ng/umbrella.git"
|
|
12
12
|
},
|
|
13
|
-
"homepage": "https://
|
|
13
|
+
"homepage": "https://thi.ng/markdown-table",
|
|
14
14
|
"funding": [
|
|
15
15
|
{
|
|
16
16
|
"type": "github",
|
|
@@ -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.
|
|
40
|
-
"@thi.ng/checks": "^3.6.
|
|
41
|
-
"@thi.ng/compose": "^3.0.
|
|
42
|
-
"@thi.ng/errors": "^2.5.
|
|
43
|
-
"@thi.ng/strings": "^3.7.
|
|
44
|
-
"@thi.ng/transducers": "^9.0.
|
|
39
|
+
"@thi.ng/api": "^8.11.3",
|
|
40
|
+
"@thi.ng/checks": "^3.6.5",
|
|
41
|
+
"@thi.ng/compose": "^3.0.5",
|
|
42
|
+
"@thi.ng/errors": "^2.5.8",
|
|
43
|
+
"@thi.ng/strings": "^3.7.34",
|
|
44
|
+
"@thi.ng/transducers": "^9.0.6"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@microsoft/api-extractor": "^7.
|
|
48
|
-
"esbuild": "^0.
|
|
49
|
-
"typedoc": "^0.25.
|
|
50
|
-
"typescript": "^5.
|
|
47
|
+
"@microsoft/api-extractor": "^7.47.0",
|
|
48
|
+
"esbuild": "^0.21.5",
|
|
49
|
+
"typedoc": "^0.25.13",
|
|
50
|
+
"typescript": "^5.5.2"
|
|
51
51
|
},
|
|
52
52
|
"keywords": [
|
|
53
53
|
"align",
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
],
|
|
88
88
|
"year": 2021
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "154c95cf9d6bab32174498ec3b5b5d87e42be7f9\n"
|
|
91
91
|
}
|
package/table.d.ts
CHANGED
|
@@ -9,10 +9,10 @@ import type { Column, Row, TableOpts } from "./api.js";
|
|
|
9
9
|
* can also be empty. By default all columns are left-aligned.
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
|
-
* ```ts
|
|
12
|
+
* ```ts tangle:../export/table.ts
|
|
13
13
|
* import { table } from "@thi.ng/markdown-table";
|
|
14
14
|
*
|
|
15
|
-
* table(
|
|
15
|
+
* const res = table(
|
|
16
16
|
* ["ID", "Actor", "Comment"],
|
|
17
17
|
* [
|
|
18
18
|
* [1, "Alice"],
|
|
@@ -23,6 +23,7 @@ import type { Column, Row, TableOpts } from "./api.js";
|
|
|
23
23
|
* { bold: true, align: ["r", "c", "l"] }
|
|
24
24
|
* );
|
|
25
25
|
*
|
|
26
|
+
* console.log(res);
|
|
26
27
|
* // | **ID** | **Actor** | **Comment** |
|
|
27
28
|
* // |-------:|:---------:|:------------|
|
|
28
29
|
* // | 1 | Alice | |
|
|
@@ -41,10 +42,10 @@ export declare const table: (header: string[], rows: Iterable<Row>, opts?: Parti
|
|
|
41
42
|
* values using given `keys` array.
|
|
42
43
|
*
|
|
43
44
|
* @example
|
|
44
|
-
* ```ts
|
|
45
|
+
* ```ts tangle:../export/table-keys.ts
|
|
45
46
|
* import { tableKeys } from "@thi.ng/markdown-table";
|
|
46
47
|
*
|
|
47
|
-
* tableKeys(
|
|
48
|
+
* const res = tableKeys(
|
|
48
49
|
* ["ID", "Actor", "Comment"],
|
|
49
50
|
* ["id", "name", (x) => x.hint],
|
|
50
51
|
* [
|
|
@@ -54,8 +55,9 @@ export declare const table: (header: string[], rows: Iterable<Row>, opts?: Parti
|
|
|
54
55
|
* { id: 44, name: "Dora", hint: "(recipient)" },
|
|
55
56
|
* ],
|
|
56
57
|
* { bold: true, align: ["r", "c", "l"] }
|
|
57
|
-
* )
|
|
58
|
+
* );
|
|
58
59
|
*
|
|
60
|
+
* console.log(res);
|
|
59
61
|
* // | **ID** | **Actor** | **Comment** |
|
|
60
62
|
* // |-------:|:---------:|:------------|
|
|
61
63
|
* // | 1 | Alice | |
|
package/table.js
CHANGED
|
@@ -52,7 +52,7 @@ const table = (header, rows, opts = {}) => {
|
|
|
52
52
|
const pads = widths.map((w, i) => PADS[align[i]](w));
|
|
53
53
|
const colIDs = [...range(numColumns)];
|
|
54
54
|
const result = body.map(
|
|
55
|
-
(row) => colIDs.map((i) => `| ${pads[i](
|
|
55
|
+
(row) => colIDs.map((i) => `| ${pads[i](__str(row[i]))} `).join("") + "|"
|
|
56
56
|
);
|
|
57
57
|
result.splice(
|
|
58
58
|
1,
|
|
@@ -65,13 +65,13 @@ const tableKeys = (headers, keys, items, opts) => table(
|
|
|
65
65
|
headers,
|
|
66
66
|
map(
|
|
67
67
|
juxt(
|
|
68
|
-
...keys.map((k) => isString(k) ? (x) =>
|
|
68
|
+
...keys.map((k) => isString(k) ? (x) => __str(x[k]) : k)
|
|
69
69
|
),
|
|
70
70
|
items
|
|
71
71
|
),
|
|
72
72
|
opts
|
|
73
73
|
);
|
|
74
|
-
const
|
|
74
|
+
const __str = (x) => x != null ? String(x) : "";
|
|
75
75
|
export {
|
|
76
76
|
table,
|
|
77
77
|
tableKeys
|