convert-buddy-js 0.9.4 → 0.9.6

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 (37) hide show
  1. package/README.md +417 -10
  2. package/dist/src/browser.d.ts +174 -0
  3. package/dist/src/browser.js +204 -0
  4. package/dist/src/browser.js.map +1 -0
  5. package/dist/src/index.d.ts +133 -3
  6. package/dist/src/index.js +427 -26
  7. package/dist/src/index.js.map +1 -1
  8. package/dist/src/node.d.ts +111 -3
  9. package/dist/src/node.js +284 -2
  10. package/dist/src/node.js.map +1 -1
  11. package/dist/tests/edge-cases/control-features.test.d.ts +2 -0
  12. package/dist/tests/edge-cases/control-features.test.js +87 -0
  13. package/dist/tests/edge-cases/control-features.test.js.map +1 -0
  14. package/dist/tests/edge-cases/csv-edge-cases.test.d.ts +2 -0
  15. package/dist/tests/edge-cases/csv-edge-cases.test.js +547 -0
  16. package/dist/tests/edge-cases/csv-edge-cases.test.js.map +1 -0
  17. package/dist/tests/edge-cases/detection.test.d.ts +2 -0
  18. package/dist/tests/edge-cases/detection.test.js +129 -0
  19. package/dist/tests/edge-cases/detection.test.js.map +1 -0
  20. package/dist/tests/edge-cases/error-handling.test.d.ts +2 -0
  21. package/dist/tests/edge-cases/error-handling.test.js +448 -0
  22. package/dist/tests/edge-cases/error-handling.test.js.map +1 -0
  23. package/dist/tests/edge-cases/ndjson-edge-cases.test.d.ts +2 -0
  24. package/dist/tests/edge-cases/ndjson-edge-cases.test.js +539 -0
  25. package/dist/tests/edge-cases/ndjson-edge-cases.test.js.map +1 -0
  26. package/dist/tests/edge-cases/node-helpers.test.d.ts +2 -0
  27. package/dist/tests/edge-cases/node-helpers.test.js +114 -0
  28. package/dist/tests/edge-cases/node-helpers.test.js.map +1 -0
  29. package/dist/wasm/nodejs/convert_buddy.d.ts +9 -5
  30. package/dist/wasm/nodejs/convert_buddy.js +28 -19
  31. package/dist/wasm/nodejs/convert_buddy_bg.wasm +0 -0
  32. package/dist/wasm/nodejs/convert_buddy_bg.wasm.d.ts +1 -0
  33. package/dist/wasm/web/convert_buddy.d.ts +10 -5
  34. package/dist/wasm/web/convert_buddy.js +28 -19
  35. package/dist/wasm/web/convert_buddy_bg.wasm +0 -0
  36. package/dist/wasm/web/convert_buddy_bg.wasm.d.ts +1 -0
  37. package/package.json +6 -2
@@ -0,0 +1,114 @@
1
+ import { describe, it } from "node:test";
2
+ import assert from "node:assert";
3
+ import { writeFileSync, unlinkSync, readFileSync } from "node:fs";
4
+ import {
5
+ convertFileToString,
6
+ convertFileToBuffer,
7
+ convertFileToFile,
8
+ convertBuffer,
9
+ convertStream
10
+ } from "../../src/node.js";
11
+ import { Readable } from "node:stream";
12
+ const TEST_CSV = "name,age\nAlice,30\nBob,25\nCharlie,35\n";
13
+ const TEST_FILE = "./test-input.csv";
14
+ const TEST_OUTPUT = "./test-output.json";
15
+ describe("Node.js High-Level Helpers", () => {
16
+ it("should convert file to string", async () => {
17
+ writeFileSync(TEST_FILE, TEST_CSV);
18
+ try {
19
+ const result = await convertFileToString(TEST_FILE, {
20
+ inputFormat: "csv",
21
+ outputFormat: "json"
22
+ });
23
+ assert.ok(result.length > 0);
24
+ assert.ok(result.includes("Alice"));
25
+ const parsed = JSON.parse(result);
26
+ assert.ok(Array.isArray(parsed));
27
+ } finally {
28
+ unlinkSync(TEST_FILE);
29
+ }
30
+ });
31
+ it("should convert file to buffer", async () => {
32
+ writeFileSync(TEST_FILE, TEST_CSV);
33
+ try {
34
+ const result = await convertFileToBuffer(TEST_FILE, {
35
+ inputFormat: "csv",
36
+ outputFormat: "json"
37
+ });
38
+ assert.ok(Buffer.isBuffer(result));
39
+ assert.ok(result.length > 0);
40
+ const str = result.toString("utf-8");
41
+ assert.ok(str.includes("Alice"));
42
+ } finally {
43
+ unlinkSync(TEST_FILE);
44
+ }
45
+ });
46
+ it("should convert file to file", async () => {
47
+ writeFileSync(TEST_FILE, TEST_CSV);
48
+ try {
49
+ await convertFileToFile(TEST_FILE, TEST_OUTPUT, {
50
+ inputFormat: "csv",
51
+ outputFormat: "json"
52
+ });
53
+ const result = readFileSync(TEST_OUTPUT, "utf-8");
54
+ assert.ok(result.length > 0);
55
+ assert.ok(result.includes("Alice"));
56
+ const parsed = JSON.parse(result);
57
+ assert.ok(Array.isArray(parsed));
58
+ } finally {
59
+ unlinkSync(TEST_FILE);
60
+ try {
61
+ unlinkSync(TEST_OUTPUT);
62
+ } catch {
63
+ }
64
+ }
65
+ });
66
+ it("should convert buffer", async () => {
67
+ const buffer = Buffer.from(TEST_CSV);
68
+ const result = await convertBuffer(buffer, {
69
+ inputFormat: "csv",
70
+ outputFormat: "json"
71
+ });
72
+ assert.ok(Buffer.isBuffer(result));
73
+ const str = result.toString("utf-8");
74
+ assert.ok(str.includes("Alice"));
75
+ });
76
+ it("should convert stream", async () => {
77
+ const stream = Readable.from([Buffer.from(TEST_CSV)]);
78
+ const result = await convertStream(stream, {
79
+ inputFormat: "csv",
80
+ outputFormat: "json"
81
+ });
82
+ assert.ok(Buffer.isBuffer(result));
83
+ const str = result.toString("utf-8");
84
+ assert.ok(str.includes("Alice"));
85
+ });
86
+ it("should auto-detect CSV format from file", async () => {
87
+ writeFileSync(TEST_FILE, TEST_CSV);
88
+ try {
89
+ const result = await convertFileToString(TEST_FILE, {
90
+ inputFormat: "auto",
91
+ outputFormat: "ndjson"
92
+ });
93
+ assert.ok(result.length > 0);
94
+ assert.ok(result.includes("Alice") || result.includes("name"));
95
+ } finally {
96
+ unlinkSync(TEST_FILE);
97
+ }
98
+ });
99
+ it("should auto-detect NDJSON format from file", async () => {
100
+ const ndjson = '{"name":"Alice","age":30}\n{"name":"Bob","age":25}\n';
101
+ writeFileSync(TEST_FILE, ndjson);
102
+ try {
103
+ const result = await convertFileToString(TEST_FILE, {
104
+ inputFormat: "auto",
105
+ outputFormat: "csv"
106
+ });
107
+ assert.ok(result.length > 0);
108
+ assert.ok(result.includes("Alice") || result.includes("name"));
109
+ } finally {
110
+ unlinkSync(TEST_FILE);
111
+ }
112
+ });
113
+ });
114
+ //# sourceMappingURL=node-helpers.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../tests/edge-cases/node-helpers.test.ts"],"sourcesContent":["import { describe, it } from \"node:test\";\r\nimport assert from \"node:assert\";\r\nimport { writeFileSync, unlinkSync, readFileSync } from \"node:fs\";\r\nimport { \r\n convertFileToString, \r\n convertFileToBuffer,\r\n convertFileToFile,\r\n convertBuffer,\r\n convertStream\r\n} from \"../../src/node.js\";\r\nimport { Readable } from \"node:stream\";\r\n\r\nconst TEST_CSV = \"name,age\\nAlice,30\\nBob,25\\nCharlie,35\\n\";\r\nconst TEST_FILE = \"./test-input.csv\";\r\nconst TEST_OUTPUT = \"./test-output.json\";\r\n\r\ndescribe(\"Node.js High-Level Helpers\", () => {\r\n it(\"should convert file to string\", async () => {\r\n writeFileSync(TEST_FILE, TEST_CSV);\r\n \r\n try {\r\n const result = await convertFileToString(TEST_FILE, {\r\n inputFormat: \"csv\",\r\n outputFormat: \"json\",\r\n });\r\n \r\n assert.ok(result.length > 0);\r\n assert.ok(result.includes(\"Alice\"));\r\n \r\n // Should be valid JSON\r\n const parsed = JSON.parse(result);\r\n assert.ok(Array.isArray(parsed));\r\n } finally {\r\n unlinkSync(TEST_FILE);\r\n }\r\n });\r\n\r\n it(\"should convert file to buffer\", async () => {\r\n writeFileSync(TEST_FILE, TEST_CSV);\r\n \r\n try {\r\n const result = await convertFileToBuffer(TEST_FILE, {\r\n inputFormat: \"csv\",\r\n outputFormat: \"json\",\r\n });\r\n \r\n assert.ok(Buffer.isBuffer(result));\r\n assert.ok(result.length > 0);\r\n \r\n const str = result.toString(\"utf-8\");\r\n assert.ok(str.includes(\"Alice\"));\r\n } finally {\r\n unlinkSync(TEST_FILE);\r\n }\r\n });\r\n\r\n it(\"should convert file to file\", async () => {\r\n writeFileSync(TEST_FILE, TEST_CSV);\r\n \r\n try {\r\n await convertFileToFile(TEST_FILE, TEST_OUTPUT, {\r\n inputFormat: \"csv\",\r\n outputFormat: \"json\",\r\n });\r\n \r\n const result = readFileSync(TEST_OUTPUT, \"utf-8\");\r\n assert.ok(result.length > 0);\r\n assert.ok(result.includes(\"Alice\"));\r\n \r\n // Should be valid JSON\r\n const parsed = JSON.parse(result);\r\n assert.ok(Array.isArray(parsed));\r\n } finally {\r\n unlinkSync(TEST_FILE);\r\n try { unlinkSync(TEST_OUTPUT); } catch {}\r\n }\r\n });\r\n\r\n it(\"should convert buffer\", async () => {\r\n const buffer = Buffer.from(TEST_CSV);\r\n \r\n const result = await convertBuffer(buffer, {\r\n inputFormat: \"csv\",\r\n outputFormat: \"json\",\r\n });\r\n \r\n assert.ok(Buffer.isBuffer(result));\r\n const str = result.toString(\"utf-8\");\r\n assert.ok(str.includes(\"Alice\"));\r\n });\r\n\r\n it(\"should convert stream\", async () => {\r\n const stream = Readable.from([Buffer.from(TEST_CSV)]);\r\n \r\n const result = await convertStream(stream, {\r\n inputFormat: \"csv\",\r\n outputFormat: \"json\",\r\n });\r\n \r\n assert.ok(Buffer.isBuffer(result));\r\n const str = result.toString(\"utf-8\");\r\n assert.ok(str.includes(\"Alice\"));\r\n });\r\n\r\n\r\n\r\n it(\"should auto-detect CSV format from file\", async () => {\r\n writeFileSync(TEST_FILE, TEST_CSV);\r\n \r\n try {\r\n // For auto-detection test, just verify that the conversion completes\r\n // without throwing an error\r\n const result = await convertFileToString(TEST_FILE, {\r\n inputFormat: \"auto\",\r\n outputFormat: \"ndjson\",\r\n });\r\n \r\n assert.ok(result.length > 0);\r\n // NDJSON format contains the data\r\n assert.ok(result.includes(\"Alice\") || result.includes(\"name\"));\r\n } finally {\r\n unlinkSync(TEST_FILE);\r\n }\r\n });\r\n\r\n it(\"should auto-detect NDJSON format from file\", async () => {\r\n const ndjson = '{\"name\":\"Alice\",\"age\":30}\\n{\"name\":\"Bob\",\"age\":25}\\n';\r\n writeFileSync(TEST_FILE, ndjson);\r\n \r\n try {\r\n const result = await convertFileToString(TEST_FILE, {\r\n inputFormat: \"auto\",\r\n outputFormat: \"csv\",\r\n });\r\n \r\n assert.ok(result.length > 0);\r\n assert.ok(result.includes(\"Alice\") || result.includes(\"name\"));\r\n } finally {\r\n unlinkSync(TEST_FILE);\r\n }\r\n });\r\n});\r\n"],"mappings":"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","names":[]}
@@ -1,10 +1,5 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- /**
4
- * Detect CSV fields and delimiter from a sample of bytes.
5
- */
6
- export function detectCsvFields(sample: Uint8Array): any;
7
- export function init(debug_enabled: boolean): void;
8
3
  /**
9
4
  * Detect XML elements from a sample of bytes.
10
5
  */
@@ -13,6 +8,15 @@ export function detectXmlElements(sample: Uint8Array): any;
13
8
  * Detect the input format from a sample of bytes.
14
9
  */
15
10
  export function detectFormat(sample: Uint8Array): string | undefined;
11
+ /**
12
+ * Check if SIMD is enabled in this build.
13
+ */
14
+ export function getSimdEnabled(): boolean;
15
+ /**
16
+ * Detect CSV fields and delimiter from a sample of bytes.
17
+ */
18
+ export function detectCsvFields(sample: Uint8Array): any;
19
+ export function init(debug_enabled: boolean): void;
16
20
  /**
17
21
  * A streaming converter state machine.
18
22
  * Converts between CSV, NDJSON, JSON, and XML formats with high performance.
@@ -177,25 +177,6 @@ function passArray8ToWasm0(arg, malloc) {
177
177
  WASM_VECTOR_LEN = arg.length;
178
178
  return ptr;
179
179
  }
180
- /**
181
- * Detect CSV fields and delimiter from a sample of bytes.
182
- * @param {Uint8Array} sample
183
- * @returns {any}
184
- */
185
- module.exports.detectCsvFields = function(sample) {
186
- const ptr0 = passArray8ToWasm0(sample, wasm.__wbindgen_malloc);
187
- const len0 = WASM_VECTOR_LEN;
188
- const ret = wasm.detectCsvFields(ptr0, len0);
189
- return ret;
190
- };
191
-
192
- /**
193
- * @param {boolean} debug_enabled
194
- */
195
- module.exports.init = function(debug_enabled) {
196
- wasm.init(debug_enabled);
197
- };
198
-
199
180
  /**
200
181
  * Detect XML elements from a sample of bytes.
201
182
  * @param {Uint8Array} sample
@@ -225,6 +206,34 @@ module.exports.detectFormat = function(sample) {
225
206
  return v2;
226
207
  };
227
208
 
209
+ /**
210
+ * Check if SIMD is enabled in this build.
211
+ * @returns {boolean}
212
+ */
213
+ module.exports.getSimdEnabled = function() {
214
+ const ret = wasm.getSimdEnabled();
215
+ return ret !== 0;
216
+ };
217
+
218
+ /**
219
+ * Detect CSV fields and delimiter from a sample of bytes.
220
+ * @param {Uint8Array} sample
221
+ * @returns {any}
222
+ */
223
+ module.exports.detectCsvFields = function(sample) {
224
+ const ptr0 = passArray8ToWasm0(sample, wasm.__wbindgen_malloc);
225
+ const len0 = WASM_VECTOR_LEN;
226
+ const ret = wasm.detectCsvFields(ptr0, len0);
227
+ return ret;
228
+ };
229
+
230
+ /**
231
+ * @param {boolean} debug_enabled
232
+ */
233
+ module.exports.init = function(debug_enabled) {
234
+ wasm.init(debug_enabled);
235
+ };
236
+
228
237
  function takeFromExternrefTable0(idx) {
229
238
  const value = wasm.__wbindgen_export_3.get(idx);
230
239
  wasm.__externref_table_dealloc(idx);
@@ -11,6 +11,7 @@ export const converter_withConfig: (a: number, b: number, c: number, d: number,
11
11
  export const detectCsvFields: (a: number, b: number) => any;
12
12
  export const detectFormat: (a: number, b: number) => [number, number];
13
13
  export const detectXmlElements: (a: number, b: number) => any;
14
+ export const getSimdEnabled: () => number;
14
15
  export const init: (a: number) => void;
15
16
  export const stats_bytes_in: (a: number) => number;
16
17
  export const stats_bytes_out: (a: number) => number;
@@ -1,10 +1,5 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- /**
4
- * Detect CSV fields and delimiter from a sample of bytes.
5
- */
6
- export function detectCsvFields(sample: Uint8Array): any;
7
- export function init(debug_enabled: boolean): void;
8
3
  /**
9
4
  * Detect XML elements from a sample of bytes.
10
5
  */
@@ -13,6 +8,15 @@ export function detectXmlElements(sample: Uint8Array): any;
13
8
  * Detect the input format from a sample of bytes.
14
9
  */
15
10
  export function detectFormat(sample: Uint8Array): string | undefined;
11
+ /**
12
+ * Check if SIMD is enabled in this build.
13
+ */
14
+ export function getSimdEnabled(): boolean;
15
+ /**
16
+ * Detect CSV fields and delimiter from a sample of bytes.
17
+ */
18
+ export function detectCsvFields(sample: Uint8Array): any;
19
+ export function init(debug_enabled: boolean): void;
16
20
  /**
17
21
  * A streaming converter state machine.
18
22
  * Converts between CSV, NDJSON, JSON, and XML formats with high performance.
@@ -69,6 +73,7 @@ export interface InitOutput {
69
73
  readonly detectCsvFields: (a: number, b: number) => any;
70
74
  readonly detectFormat: (a: number, b: number) => [number, number];
71
75
  readonly detectXmlElements: (a: number, b: number) => any;
76
+ readonly getSimdEnabled: () => number;
72
77
  readonly init: (a: number) => void;
73
78
  readonly stats_bytes_in: (a: number) => number;
74
79
  readonly stats_bytes_out: (a: number) => number;
@@ -173,25 +173,6 @@ function passArray8ToWasm0(arg, malloc) {
173
173
  WASM_VECTOR_LEN = arg.length;
174
174
  return ptr;
175
175
  }
176
- /**
177
- * Detect CSV fields and delimiter from a sample of bytes.
178
- * @param {Uint8Array} sample
179
- * @returns {any}
180
- */
181
- export function detectCsvFields(sample) {
182
- const ptr0 = passArray8ToWasm0(sample, wasm.__wbindgen_malloc);
183
- const len0 = WASM_VECTOR_LEN;
184
- const ret = wasm.detectCsvFields(ptr0, len0);
185
- return ret;
186
- }
187
-
188
- /**
189
- * @param {boolean} debug_enabled
190
- */
191
- export function init(debug_enabled) {
192
- wasm.init(debug_enabled);
193
- }
194
-
195
176
  /**
196
177
  * Detect XML elements from a sample of bytes.
197
178
  * @param {Uint8Array} sample
@@ -221,6 +202,34 @@ export function detectFormat(sample) {
221
202
  return v2;
222
203
  }
223
204
 
205
+ /**
206
+ * Check if SIMD is enabled in this build.
207
+ * @returns {boolean}
208
+ */
209
+ export function getSimdEnabled() {
210
+ const ret = wasm.getSimdEnabled();
211
+ return ret !== 0;
212
+ }
213
+
214
+ /**
215
+ * Detect CSV fields and delimiter from a sample of bytes.
216
+ * @param {Uint8Array} sample
217
+ * @returns {any}
218
+ */
219
+ export function detectCsvFields(sample) {
220
+ const ptr0 = passArray8ToWasm0(sample, wasm.__wbindgen_malloc);
221
+ const len0 = WASM_VECTOR_LEN;
222
+ const ret = wasm.detectCsvFields(ptr0, len0);
223
+ return ret;
224
+ }
225
+
226
+ /**
227
+ * @param {boolean} debug_enabled
228
+ */
229
+ export function init(debug_enabled) {
230
+ wasm.init(debug_enabled);
231
+ }
232
+
224
233
  function takeFromExternrefTable0(idx) {
225
234
  const value = wasm.__wbindgen_export_3.get(idx);
226
235
  wasm.__externref_table_dealloc(idx);
Binary file
@@ -11,6 +11,7 @@ export const converter_withConfig: (a: number, b: number, c: number, d: number,
11
11
  export const detectCsvFields: (a: number, b: number) => any;
12
12
  export const detectFormat: (a: number, b: number) => [number, number];
13
13
  export const detectXmlElements: (a: number, b: number) => any;
14
+ export const getSimdEnabled: () => number;
14
15
  export const init: (a: number) => void;
15
16
  export const stats_bytes_in: (a: number) => number;
16
17
  export const stats_bytes_out: (a: number) => number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "convert-buddy-js",
3
- "version": "0.9.4",
3
+ "version": "0.9.6",
4
4
  "description": "TypeScript wrapper for convert-buddy (Rust/WASM core)",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -14,6 +14,10 @@
14
14
  "./node": {
15
15
  "types": "./dist/src/node.d.ts",
16
16
  "default": "./dist/src/node.js"
17
+ },
18
+ "./browser": {
19
+ "types": "./dist/src/browser.d.ts",
20
+ "default": "./dist/src/browser.js"
17
21
  }
18
22
  },
19
23
  "files": [
@@ -35,7 +39,7 @@
35
39
  "test:edge-cases": "npm run build && node --test ./dist/tests/edge-cases/*.test.js",
36
40
  "test:all": "npm run test && npm run test:edge-cases",
37
41
  "bench": "npm run build && node ./dist/bench/runner.js",
38
- "bench:single-thread": "npm run build && UV_THREADPOOL_SIZE=1 node ./dist/bench/single-thread.js",
42
+ "bench:single-thread": "npm run build && node ./scripts/run-single-thread.mjs",
39
43
  "bench:multi-thread": "npm run build && node ./dist/bench/multi-thread.js",
40
44
  "bench:compare": "npm run build && node ./dist/bench/compare-threads.js",
41
45
  "bench:competitors": "npm run build && node ./dist/bench/runner-with-competitors.js",