Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ikasoba/tokoroten
https://github.com/ikasoba/tokoroten
Last synced: 15 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/ikasoba/tokoroten
- Owner: ikasoba
- Created: 2024-02-14T07:14:42.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-02-14T08:20:23.000Z (11 months ago)
- Last Synced: 2024-10-24T06:06:59.202Z (2 months ago)
- Language: TypeScript
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# tokoroten
tokoroten is a utility for matching JSON-like input to a schema.
```ts
import * as t from "@ikasoba000/tokoroten"const Note = t.object({
type: t.const("Note"),
content: t.string,
mediaType: t.opt(t.string),
published: t.map(t.string, x => new Date(x))
})const note = Note({
type: "Note",
content: "hogehoge",
mediaType: 1234,
published: "2024-02-14T04:48:47.155Z"
})console.log(note)
// {
// value: {
// type: "Note",
// content: "hoogehoge",
// published: 2024-02-14T04:48:47.155Z
// }
// }
```