This small utility demonstrates transforming an object to data-* attributes for use in server templating. The data-* attributes match how a browser maps to JS, so you can use it and get back your original keys on the client from an element’s dataset property.
For example, in an Astro component:
---
import { dataset } from './dataset';
const data = { Example: "value", count: 10, backgroundColor: '#fff' };