Skip to content

Commit a399201

Browse files
committed
v2.3.1
1 parent 1fee723 commit a399201

File tree

3 files changed

+71
-8
lines changed

3 files changed

+71
-8
lines changed

deno.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nshiab/journalism",
3-
"version": "2.3.0",
3+
"version": "2.3.1",
44
"exports": {
55
".": "./src/index.ts",
66
"./web": "./src/web.ts"
@@ -24,7 +24,7 @@
2424
"@nshiab/journalism-dataviz": "jsr:@nshiab/journalism-dataviz@^1.0.3",
2525
"@nshiab/journalism-extras": "jsr:@nshiab/journalism-extras@^1.0.2",
2626
"@nshiab/journalism-finance": "jsr:@nshiab/journalism-finance@^1.1.0",
27-
"@nshiab/journalism-format": "jsr:@nshiab/journalism-format@^1.1.0",
27+
"@nshiab/journalism-format": "jsr:@nshiab/journalism-format@^1.1.1",
2828
"@nshiab/journalism-geo": "jsr:@nshiab/journalism-geo@^1.0.3",
2929
"@nshiab/journalism-google": "jsr:@nshiab/journalism-google@^1.0.4",
3030
"@nshiab/journalism-statistics": "jsr:@nshiab/journalism-statistics@^1.0.2",

deno.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

llm.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5944,6 +5944,69 @@ const specificDuration = prettyDuration(start, { end });
59445944
console.log(specificDuration); // Returns "22 days, 6 h, 3 min, 15 sec, 0 ms"
59455945
```
59465946

5947+
## printTable
5948+
5949+
Prints a formatted table to the console with support for word wrapping within
5950+
cells. Unlike console.table(), this function properly handles multi-line content
5951+
within cells, making it ideal for displaying data with long text values.
5952+
5953+
This function has been created for the
5954+
[simple-data-analysis library](https://github.com/nshiab/simple-data-analysis),
5955+
but can be used independently for any array of objects.
5956+
5957+
### Signature
5958+
5959+
```typescript
5960+
function printTable(
5961+
data: Record<string, unknown>[],
5962+
options?: {
5963+
maxColumnWidth?: number;
5964+
minColumnWidth?: number;
5965+
typesRowIndex?: number;
5966+
},
5967+
): void;
5968+
```
5969+
5970+
### Parameters
5971+
5972+
- **`data`**: - An array of objects representing the rows of the table. Each
5973+
object should have string keys.
5974+
- **`options`**: - Optional configuration for table rendering.
5975+
- **`options.maxColumnWidth`**: - The maximum width for any column (default:
5976+
75). Values exceeding this width will be wrapped at word boundaries.
5977+
- **`options.minColumnWidth`**: - The minimum width for any column (default: 3).
5978+
- **`options.typesRowIndex`**: - The index of a row that contains type
5979+
annotations (e.g. "VARCHAR/string"). This row will be rendered in grey. If
5980+
omitted, no row is treated as a types row.
5981+
5982+
### Returns
5983+
5984+
void - The table is printed directly to the console.
5985+
5986+
### Examples
5987+
5988+
```typescript
5989+
const data = [
5990+
{
5991+
name: "Alice",
5992+
description: "A software engineer with expertise in TypeScript",
5993+
},
5994+
{ name: "Bob", description: "A product manager" },
5995+
];
5996+
printTable(data, { maxColumnWidth: 30 });
5997+
// Outputs a nicely formatted table with word-wrapped description column
5998+
```
5999+
6000+
```typescript
6001+
// With types row
6002+
const types = { name: "VARCHAR/string", age: "INTEGER/number" };
6003+
const data = [
6004+
{ name: "Alice", age: 30 },
6005+
{ name: "Bob", age: 25 },
6006+
];
6007+
printTable([types, ...data], { typesRowIndex: 0 });
6008+
```
6009+
59476010
## publishChartDW
59486011

59496012
Publishes a specified Datawrapper chart, table, or map. This function

0 commit comments

Comments
 (0)