convert-buddy-js 0.3.0 → 0.4.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 +25 -1
  2. package/package.json +7 -1
package/README.md CHANGED
@@ -44,8 +44,10 @@ console.log(buddy.stats());
44
44
 
45
45
  ### Node.js Transform stream
46
46
 
47
+ Use the Node-specific entrypoint so bundlers keep `node:stream` out of the browser bundle.
48
+
47
49
  ```ts
48
- import { createNodeTransform } from "convert-buddy-js";
50
+ import { createNodeTransform } from "convert-buddy-js/node";
49
51
  import { createReadStream, createWriteStream } from "node:fs";
50
52
 
51
53
  const transform = await createNodeTransform({
@@ -74,6 +76,28 @@ const response = await fetch("/data.csv");
74
76
  const outputStream = response.body?.pipeThrough(transform);
75
77
  ```
76
78
 
79
+ ### Detect format and CSV fields/delimiter
80
+
81
+ Use streaming inputs to keep detection fast on large files.
82
+
83
+ ```ts
84
+ import {
85
+ detectFormat,
86
+ detectCsvFieldsAndDelimiter,
87
+ } from "convert-buddy-js";
88
+
89
+ const fileStream = (await fetch("/data")).body!;
90
+
91
+ const format = await detectFormat(fileStream, { maxBytes: 256 * 1024 });
92
+ console.log(format); // "csv" | "json" | "ndjson" | "xml" | "unknown"
93
+
94
+ const csvInfo = await detectCsvFieldsAndDelimiter(fileStream);
95
+ if (csvInfo) {
96
+ console.log(csvInfo.delimiter);
97
+ console.log(csvInfo.fields);
98
+ }
99
+ ```
100
+
77
101
  ## Configuration
78
102
 
79
103
  ### Formats
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "convert-buddy-js",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "TypeScript wrapper for convert-buddy (Rust/WASM core)",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -10,11 +10,17 @@
10
10
  ".": {
11
11
  "types": "./dist/src/index.d.ts",
12
12
  "default": "./dist/src/index.js"
13
+ },
14
+ "./node": {
15
+ "types": "./dist/src/node.d.ts",
16
+ "default": "./dist/src/node.js"
13
17
  }
14
18
  },
15
19
  "files": [
16
20
  "dist/src/index.js",
17
21
  "dist/src/index.d.ts",
22
+ "dist/src/node.js",
23
+ "dist/src/node.d.ts",
18
24
  "dist/chunk-*.js",
19
25
  "dist/chunk-*.d.ts",
20
26
  "dist/*.js",