robb-j / gruber

(WIP) A standards-based JavaScript server library & patterns
0 stars 0 forks source link

enum structure #16

Open robb-j opened 4 months ago

robb-j commented 4 months ago
// type: Structure<'a string', 42, false>
const type = Structure.enum(['a string', 42, false])

An enum structure would be useful, it could also take a default value too.

robb-j commented 1 month ago

This can now be achieved with Structure.union and Structure.literal. I'll leave this open as the idea to add an enum syntax sugar if it becomes more important