DZakh / rescript-struct

The fastest composable parser/serializer for ReScript (and TypeScript)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CI codecov npm

ReScript Struct

The fastest composable parser/serializer for ReScript (and TypeScript)

⚠️ Be aware that rescript-struct uses eval. It's usually fine but might not work in some environments like Cloudflare Workers or third-party scripts used on pages with the script-src header.

Highlights:

  • Combines validation and transformation without a performance loss
  • Can transform parsed value back to the initial format (serializing)
  • Works with any Js value, not only Js.Json.t
  • Support for asynchronous transformations
  • Immutable API with both result and exception-based operations
  • Easy to create recursive structs
  • Detailed error messages
  • Strict mode for object structs to prevent excessive fields and many more built-in helpers
  • Works with plain JavaScript/TypeScript too! You don't need to use ReScript
  • The fastest composable validation library in the entire JavaScript ecosystem (benchmark)
  • Small JS footprint & tree-shakable API (Comparison with Zod and Valibot)

Also, it has declarative API allowing you to use rescript-struct as a building block for other tools, such as:

Documentation

About

The fastest composable parser/serializer for ReScript (and TypeScript)

License:MIT License


Languages

Language:ReScript 68.9%Language:JavaScript 24.8%Language:TypeScript 4.5%Language:OCaml 1.7%Language:Shell 0.1%Language:Batchfile 0.0%