Gathering detailed insights and metrics for @sinclair/typebox-remix
Gathering detailed insights and metrics for @sinclair/typebox-remix
Syntax, Compiler and Translation System for Runtime Types
npm install @sinclair/typebox-remix
Typescript
Module System
Node Version
NPM Version
73.4
Supply Chain
97.6
Quality
80.9
Maintenance
100
Vulnerability
100
License
TypeScript (98.92%)
JavaScript (1.08%)
Total Downloads
159
Last Day
1
Last Week
9
Last Month
32
Last Year
159
61 Stars
32 Commits
1 Forks
1 Watching
2 Branches
2 Contributors
Minified
Minified + Gzipped
Latest Version
0.8.1
Package Id
@sinclair/typebox-remix@0.8.1
Unpacked Size
88.84 kB
Size
11.77 kB
File Count
13
NPM Version
10.5.1
Node Version
22.0.0
Publised On
24 Dec 2024
Cumulative downloads
Total Downloads
Last day
-50%
1
Compared to previous day
Last week
80%
9
Compared to previous week
Last month
-74.8%
32
Compared to previous month
Last year
0%
159
Compared to previous year
1
7
1$ npm install @sinclair/typebox-remix --save
TypeBox Remix converts Valibot and Zod Types into TypeBox compatible schematics
1import { Box } from '@sinclair/typebox-remix' 2 3import * as v from 'valibot' 4import * as z from 'zod' 5 6// Valibot to TypeBox (Runtime) 7 8const V = Box(v.object({ // const V = { 9 x: v.number(), // type: 'object', 10 y: v.number(), // required: ['x', 'y', 'z'], 11 z: v.number() // properties: { 12})) // x: { type: 'number' }, 13 // y: { type: 'number' }, 14 // z: { type: 'number' } 15 // } 16 // } 17 18// Zod to TypeBox (Static) 19 20const Z = Box(z.object({ // const Z: TObject<{ 21 a: z.string(), // a: TString, 22 b: z.string(), // b: TString, 23 c: z.string() // c: TString 24})) // }>
TypeBox Remix is a library that makes Zod and Valibot compatible with TypeBox. It works by structurally remapping the types provided by these libraries into Json Schema schematics, enabling them to integrate with the TypeBox infrastructure and making them compatible with Ajv.
This library can be used to integrate Valibot and Zod into server infrastructures that standardize on the Json Schema specification. By transforming these libraries to Json Schema, they can benefit from accelerated type checking and achieve better interoperability with non-JavaScript based systems.
License MIT
TypeBox Remix provides a singular Box function to transform Valibot and Zod types into TypeBox schematics. The top-level export is capable of transforming both Valibot and Zod, but you should use the appropriate submodule depending on which library you are using.
Use the /valibot
submodule if you only have Valibot installed.
1import { Box } from '@sinclair/typebox-remix/valibot' // Transform Valibot Only 2 3import * as v from 'valibot' 4 5const T = Box(v.string()) // const T = { type: 'string' }
Refer to the Valibot documentation for more information on this type library.
Use the /zod
submodule if you only have Zod installed.
1import { Box } from '@sinclair/typebox-remix/zod' // Transform Zod Only 2 3import * as z from 'zod' 4 5const T = Box(z.string()) // const T = { type: 'string' }
Refer to the Zod documentation for more information on this type library.
This project manages a benchmark that runs type check performance using Zod, Valibot and TypeBox validators. The benchmark is setup to run 1 million check operations per library and validator pairing and reports the elapsed time taken to complete.
1const T = { x: number, y: number, z: number }
1┌─────────┬────────────────┬────────────────────┬────────────┬────────────┐ 2│ (index) │ library │ using │ iterations │ elapsed │ 3├─────────┼────────────────┼────────────────────┼────────────┼────────────┤ 4│ 0 │ 'valibot ' │ 'valibot ' │ 1000000 │ '378 ms ' │ 5│ 1 │ 'valibot ' │ 'typebox:value ' │ 1000000 │ '125 ms ' │ 6│ 2 │ 'valibot ' │ 'typebox:compile ' │ 1000000 │ '4 ms ' │ 7└─────────┴────────────────┴────────────────────┴────────────┴────────────┘ 8┌─────────┬────────────────┬────────────────────┬────────────┬────────────┐ 9│ (index) │ library │ using │ iterations │ elapsed │ 10├─────────┼────────────────┼────────────────────┼────────────┼────────────┤ 11│ 0 │ 'zod ' │ 'zod ' │ 1000000 │ '444 ms ' │ 12│ 1 │ 'zod ' │ 'typebox:value ' │ 1000000 │ '127 ms ' │ 13│ 2 │ 'zod ' │ 'typebox:compile ' │ 1000000 │ '5 ms ' │ 14└─────────┴────────────────┴────────────────────┴────────────┴────────────┘
For community benchmarks, refer to the runtime-type-benchmarks project.
This project is open to community contribution. Please ensure you submit an open issue before submitting your pull request. TypeBox and associated projects prefer open community discussion before accepting new features.
No vulnerabilities found.
No security vulnerabilities found.