convert-buddy-js 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.
package/README.md ADDED
@@ -0,0 +1,163 @@
1
+ # convert-buddy-js
2
+
3
+ A high-performance, streaming-first parser and converter for CSV, XML, NDJSON, and JSON. `convert-buddy-js` is a TypeScript wrapper around a Rust/WASM core, offering fast parsing and multiple usage styles for Node.js and browsers.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install convert-buddy-js
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Convert a full string or buffer
14
+
15
+ ```ts
16
+ import { convertToString } from "convert-buddy-js";
17
+
18
+ const csv = `name,age\nAda,36\nLinus,54`;
19
+
20
+ const output = await convertToString(csv, {
21
+ inputFormat: "csv",
22
+ outputFormat: "ndjson",
23
+ });
24
+
25
+ console.log(output);
26
+ ```
27
+
28
+ ### Manual streaming (chunked)
29
+
30
+ ```ts
31
+ import { ConvertBuddy } from "convert-buddy-js";
32
+
33
+ const buddy = await ConvertBuddy.create({
34
+ inputFormat: "xml",
35
+ outputFormat: "ndjson",
36
+ xmlConfig: { recordElement: "row", includeAttributes: true },
37
+ });
38
+
39
+ const chunkOutput = buddy.push(new Uint8Array([/* bytes */]));
40
+ const finalOutput = buddy.finish();
41
+
42
+ console.log(buddy.stats());
43
+ ```
44
+
45
+ ### Node.js Transform stream
46
+
47
+ ```ts
48
+ import { createNodeTransform } from "convert-buddy-js";
49
+ import { createReadStream, createWriteStream } from "node:fs";
50
+
51
+ const transform = createNodeTransform({
52
+ inputFormat: "csv",
53
+ outputFormat: "ndjson",
54
+ csvConfig: { hasHeaders: true },
55
+ profile: true,
56
+ });
57
+
58
+ createReadStream("input.csv")
59
+ .pipe(transform)
60
+ .pipe(createWriteStream("output.ndjson"));
61
+ ```
62
+
63
+ ### Web Streams
64
+
65
+ ```ts
66
+ import { ConvertBuddyTransformStream } from "convert-buddy-js";
67
+
68
+ const transform = new ConvertBuddyTransformStream({
69
+ inputFormat: "csv",
70
+ outputFormat: "ndjson",
71
+ });
72
+
73
+ const response = await fetch("/data.csv");
74
+ const outputStream = response.body?.pipeThrough(transform);
75
+ ```
76
+
77
+ ## Configuration
78
+
79
+ ### Formats
80
+
81
+ - `csv`
82
+ - `xml`
83
+ - `ndjson`
84
+ - `json`
85
+
86
+ ### CSV options
87
+
88
+ ```ts
89
+ {
90
+ csvConfig: {
91
+ delimiter: ",",
92
+ quote: '"',
93
+ hasHeaders: true,
94
+ trimWhitespace: false,
95
+ }
96
+ }
97
+ ```
98
+
99
+ ### XML options
100
+
101
+ ```ts
102
+ {
103
+ xmlConfig: {
104
+ recordElement: "row",
105
+ trimText: true,
106
+ includeAttributes: true,
107
+ }
108
+ }
109
+ ```
110
+
111
+ ### Performance options
112
+
113
+ ```ts
114
+ {
115
+ chunkTargetBytes: 1024 * 1024,
116
+ parallelism: 4,
117
+ profile: true,
118
+ debug: false,
119
+ }
120
+ ```
121
+
122
+ ## How it works
123
+
124
+ - **Rust core** (`crates/convert-buddy`) implements streaming parsers and stats tracking.
125
+ - **WASM bindings** are generated via `wasm-bindgen` and bundled into this package.
126
+ - **TypeScript wrapper** (`src/index.ts`) exposes the `ConvertBuddy` class and stream adapters.
127
+
128
+ ### Build (repository)
129
+
130
+ ```bash
131
+ npm install
132
+ npm -w convert-buddy-js run build
133
+ ```
134
+
135
+ ### Benchmarks (repository)
136
+
137
+ ```bash
138
+ npm -w convert-buddy-js run bench:competitors
139
+ ```
140
+
141
+ ## Comparison to similar tools
142
+
143
+ Convert Buddy targets multi-format conversion with a unified, streaming API. Most existing libraries specialize:
144
+
145
+ - CSV-only parsers (e.g., PapaParse, `csv-parse`, `fast-csv`)
146
+ - XML-only parsers
147
+ - JSON/NDJSON-only utilities
148
+
149
+ **Where Convert Buddy shines**
150
+ - Large dataset throughput (WASM + fast-path parsing)
151
+ - Streaming conversions without loading full files into memory
152
+ - Unified API across CSV, XML, NDJSON, JSON
153
+
154
+ **Where others may be better**
155
+ - Tiny inputs (WASM setup overhead can dominate)
156
+ - Advanced format-specific features
157
+ - Long-tail ecosystem plugins
158
+
159
+ Benchmarks live in `packages/convert-buddy-js/bench/` and include honest cases where Convert Buddy is slower to help users choose the right tool.
160
+
161
+ ## License
162
+
163
+ MIT