@ikasoba000/tokoroten
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

tokoroten

tokoroten is a utility for matching JSON-like input to a schema.

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
//   }
// }

Readme

Keywords

none

Package Sidebar

Install

npm i @ikasoba000/tokoroten

Weekly Downloads

0

Version

0.1.2

License

MIT

Unpacked Size

6.86 kB

Total Files

8

Last publish

Collaborators

  • ikasoba000