Skip to content

Instantly share code, notes, and snippets.

View TrevorFSmith's full-sized avatar

Trevor Flowers TrevorFSmith

View GitHub Profile
@gordonbrander
gordonbrander / ruleset.example.js
Last active November 6, 2022 09:20
ruleset.js — parse style-attribute-like strings.
import {Schema, string, bool, number, listOf, optional, cssUnit4} from './ruleset.js';
const parse = Schema({
title: string,
isHidden: optional(bool, false),
numbers: listOf(number)
});
parse("title: 8 Beautiful Notes; numbers: 1, 2, 3, 4, 5, 6, 7, 8")
// > {title: "8 Beautiful Notes", numbers: [1, 2, 3...], isHidden: false}