From a5326a67e37d9f1aee740f7b3d46345f3bcda419 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Wed, 9 Jul 2025 23:29:06 -0400 Subject: 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. --- ui/lib/swatch/json.js | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 ui/lib/swatch/json.js (limited to 'ui/lib/swatch/json.js') 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); +} -- cgit v1.2.3