@dads-framework/csv 0.1.0 → 0.2.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.
Files changed (2) hide show
  1. package/README.md +38 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -4,6 +4,44 @@ Call `toCsv(rows, columns)` to export records with column headers. It produces
4
4
  comma-separated cells, LF line endings, and a final newline. A column selects
5
5
  a property by name, with nested paths such as `address.city` or `items[0]`.
6
6
 
7
+ ## Try it
8
+
9
+ In a project using Node.js 22 or later, install the example dependencies.
10
+
11
+ ```sh
12
+ npm install @dads-framework/csv
13
+ npm install -D tsx
14
+ ```
15
+
16
+ Save this as `example.mts` and run `npx tsx example.mts`.
17
+
18
+ <!-- dads:check-example -->
19
+
20
+ ```ts
21
+ import { toCsv } from "@dads-framework/csv";
22
+
23
+ const csv = toCsv(
24
+ [{ customer: { name: "River, Inc." } }],
25
+ [{ key: "customer.name", header: "Customer" }],
26
+ );
27
+ process.stdout.write(csv);
28
+ ```
29
+
30
+ The script prints the header and a quoted cell on separate lines.
31
+
32
+ ```text
33
+ Customer
34
+ "River, Inc."
35
+ ```
36
+
37
+ The starter applies its spreadsheet-safety policy to note text and passes the result to `toCsv`. [`apps/kit-workbench/domains/notes/server/exports.ts`](../../../apps/kit-workbench/domains/notes/server/exports.ts)
38
+
39
+ ## Use it
40
+
41
+ The column list controls the header names and order. Before exporting data
42
+ that a spreadsheet may interpret as formulas, apply the application's policy
43
+ for spreadsheet-safe values.
44
+
7
45
  ## Cell values
8
46
 
9
47
  The serializer quotes commas, quotes, and line breaks. Missing and null cells
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dads-framework/csv",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=22"