diffx-js 0.4.2 → 0.4.4

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 +45 -9
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -13,27 +13,63 @@ This will automatically download the appropriate `diffx` binary for your system
13
13
  ## Usage
14
14
 
15
15
  ```javascript
16
- const { runDiffx } = require('diffx-js');
16
+ const { diff, diffString } = require('diffx-js');
17
17
 
18
18
  async function main() {
19
- // Compare two JSON files
20
- let result = await runDiffx(["file1.json", "file2.json"]);
21
-
22
- if (result.code === 0) {
19
+ // Compare two files
20
+ const result = await diff('file1.json', 'file2.json');
21
+
22
+ if (result.length === 0) {
23
23
  console.log("No differences found.");
24
24
  } else {
25
25
  console.log("Differences found:");
26
- console.log(result.stdout);
26
+ for (const change of result) {
27
+ console.log(`${change.type}: ${change.path} = ${change.new_value}`);
28
+ }
27
29
  }
28
30
 
29
- // You can pass any arguments supported by the diffx CLI
30
- result = await runDiffx(["file1.yaml", "file2.yaml", "--output", "json"]);
31
- console.log(result.stdout);
31
+ // Compare with options
32
+ const jsonResult = await diff('config1.yaml', 'config2.yaml', {
33
+ output: 'json',
34
+ ignoreKeysRegex: 'timestamp'
35
+ });
36
+
37
+ // Compare directory structures
38
+ const dirResult = await diff('dir1/', 'dir2/', {
39
+ recursive: true,
40
+ output: 'json'
41
+ });
42
+
43
+ // Compare strings directly
44
+ const stringResult = await diffString(
45
+ '{"a": 1}',
46
+ '{"a": 2}',
47
+ 'json',
48
+ { output: 'json' }
49
+ );
32
50
  }
33
51
 
34
52
  main();
35
53
  ```
36
54
 
55
+
56
+ ### API Reference
57
+
58
+ #### `diff(input1, input2, options?)`
59
+ - **input1, input2**: File paths or directory paths to compare
60
+ - **options**: Optional configuration object
61
+ - `format`: Input format ('json', 'yaml', 'toml', 'xml', 'ini', 'csv')
62
+ - `output`: Output format ('cli', 'json', 'yaml', 'unified')
63
+ - `recursive`: Compare directories recursively
64
+ - `ignoreKeysRegex`: Ignore keys matching regex pattern
65
+ - `epsilon`: Tolerance for floating-point comparisons
66
+ - `context`: Number of context lines in unified output
67
+
68
+ #### `diffString(content1, content2, format, options?)`
69
+ - **content1, content2**: String content to compare
70
+ - **format**: Data format ('json', 'yaml', 'toml', etc.)
71
+ - **options**: Same as `diff()` options
72
+
37
73
  ## Development
38
74
 
39
75
  To link for local development:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diffx-js",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "A Node.js wrapper for the diffx CLI tool - semantic diffing of JSON, YAML, TOML, XML, INI, and CSV files. Focuses on structural meaning rather than formatting.",
5
5
  "keywords": [
6
6
  "diff",