summaryrefslogtreecommitdiff
path: root/ui/lib/swatch/json.js
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2025-07-09 23:29:06 -0400
committerOwen Jacobson <owen@grimoire.ca>2025-08-21 19:42:09 -0400
commita5326a67e37d9f1aee740f7b3d46345f3bcda419 (patch)
tree18a1eff075e12c60e2bc2400703b9ad2cc67e7d4 /ui/lib/swatch/json.js
parent4624f4dbebf5dd1ed4dc5168573537459b9a115e (diff)
Factor data-to-JSON-string construction out of stitches.
This is a recurring and nameable operation; let's give it a name before we use it further.
Diffstat (limited to 'ui/lib/swatch/json.js')
-rw-r--r--ui/lib/swatch/json.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/ui/lib/swatch/json.js b/ui/lib/swatch/json.js
new file mode 100644
index 0000000..3ebbc0d
--- /dev/null
+++ b/ui/lib/swatch/json.js
@@ -0,0 +1,7 @@
+import { makeDeriver } from '$lib/swatch/derive.js';
+
+export const decode = makeDeriver(JSON.parse);
+
+export function encode(value) {
+ return JSON.stringify(value, /* replacer */ null, /* space */ 2);
+}