edn-to-js 0.1.1 → 1.0.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 CHANGED
@@ -1,16 +1,51 @@
1
1
  # edn-to-js
2
2
 
3
- > A simple ClojureScript `edn->js` implementation, exported as a commonjs module.
4
-
5
- After finding an appalling lack of anything sensible for converting EDN to JavaScript data on NPM I took literally 5 minutes and wrote, built and published this.
3
+ > Convert EDN to JavaScript data. Tolerant of tagged literals (`#inst`, `#uuid`, custom tags).
6
4
 
7
5
  ## Usage
8
6
 
9
7
  ```js
8
+ import { ednToJs, cljToJson, jsonToClj, jsonStringify } from 'edn-to-js';
9
+
10
+ ednToJs('{:foo "bar"}');
11
+ // => { foo: 'bar' }
12
+
13
+ ednToJs('{:created #inst "2024-01-01T00:00:00Z"}');
14
+ // => { created: { tag: 'inst', form: '2024-01-01T00:00:00Z' } }
15
+
16
+ cljToJson('{:foo "bar"}');
17
+ // => '{"foo":"bar"}'
18
+
19
+ jsonToClj('{"foo":"bar"}');
20
+ // => { foo: 'bar' }
21
+ ```
22
+
23
+ ## CLI
24
+
25
+ ```sh
26
+ echo '{:foo "bar"}' | edn-to-json
27
+ # {"foo":"bar"}
28
+
29
+ echo '{"foo":"bar"}' | json-to-edn
30
+ # {:foo "bar"}
31
+ ```
32
+
33
+ ## Migrating from 0.x
34
+
35
+ v1.0 is a full rewrite. The package is now ESM and exports named functions instead of a single CommonJS default.
36
+
37
+ ```js
38
+ // Before (0.x)
10
39
  const edn = require('edn-to-js');
11
- edn('{:foo "bar"}'); // => { foo: 'bar' }
40
+ edn('{:foo "bar"}');
41
+
42
+ // After (1.x)
43
+ import { ednToJs } from 'edn-to-js';
44
+ ednToJs('{:foo "bar"}');
12
45
  ```
13
46
 
47
+ Tagged literals like `#inst` and `#uuid` no longer throw. They are converted to `{ tag, form }` objects.
48
+
14
49
  ## License
15
50
 
16
51
  MIT
package/deps.edn ADDED
@@ -0,0 +1 @@
1
+ {:deps {thheller/shadow-cljs {:mvn/version "3.3.6"}}}