From e692f3f48956085d4fbdc0be1d422a9566487b53 Mon Sep 17 00:00:00 2001 From: sinclair Date: Sun, 2 Feb 2025 15:31:51 +0900 Subject: [PATCH] Documentation --- package.json | 2 +- readme.md | 24 +++++++++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 8c4e220..983ba9c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@sinclair/typemap", "version": "0.8.12", - "description": "Syntax, Compiler and Translation System for Runtime Types", + "description": "Syntax Compiler and Translation System for Runtime Types", "author": "sinclairzx81", "license": "MIT", "repository": { diff --git a/readme.md b/readme.md index 76158e2..b7ceeb7 100644 --- a/readme.md +++ b/readme.md @@ -2,7 +2,7 @@

TypeMap

-

Syntax, Compiler and Translation System for Runtime Types

+

Syntax Compiler and Translation System for Runtime Types

@@ -24,25 +24,27 @@ $ npm install @sinclair/typemap --save ## Usage -Parse and Compile Types from TypeScript Syntax ([Example](https://www.typescriptlang.org/play/?moduleResolution=99&module=199#code/JYWwDg9gTgLgBAbzgYQuYAbApnAhgZzgBUBPMHAXzgDMo04ByAAX2ADsBjDXYKAehhksIXGAYAoOFOkzZ08Rwht88KFnwBXDPAC8xIQAoGKqOwDmcAD5w2WjAwCUAOgAKuKPixGAElgwYIOAB1aAwAE0dxPj5ZQCBSOQSpeMSUmXiomLTUuOzswBRSQABSIrg3DxwANVwMDSwMnNykhoS6rKbCguIAVTZgJQAeAG0iAGUYUzYzABpiADk7AF0APhbpWJWpdrhFZVV1LRgALjgTcysbOzg9Bl9-QJCocIYgA)) +Parse and Compile Types from TypeScript Syntax ([Example](https://www.typescriptlang.org/play/?moduleResolution=99&module=199&ts=5.8.0-beta#code/JYWwDg9gTgLgBAbzgYQuYAbApnAvnAMyjTgHIABAZ2ADsBjDAQ2CgHoYBPMLERsUgFBxhI0WJEC6EGpXgA3RhmAATRjGhwAvCjRhMWABQADJAA8AXHBoBXEACMsUADRwOlm-cd4jASjitWOCkZeUUVNWhLADUw1XUoAB4AFQB5OwArLDoYBIQhcQLCouKS4QCRCzgkgDlbB2d80qbmpvLhNyrazyhGlr7+kXLcAD5hgUlpWTgoLEprDHhtBSU46AA6ZAALLIBrAyQBwcDGSkR8yoBGF0Obgra4So96p3yOgCZbz7F7jqfHAVwfi+wNEQyAA)) ```typescript -import { Compile as Type } from '@sinclair/typemap' +import { Compile } from '@sinclair/typemap' -const result = Type('string | null').Parse('Hello World') -// │ │ │ -// │ │ └─── Parse Value -// │ │ -// │ └── TUnion<[TString, TNull]> | Abstract Type -// │ -// └── const result: string | null = 'Hello World' +const validator = Compile(`{ x: number, y: number }`) // const validator: Validator> + +const result = validator.Check({ // as { + x: 1, // x: number, + y: 2 // y: number +}) // } ``` ## Overview TypeMap is a syntax frontend and compiler backend for the [TypeBox](https://github.com/sinclairzx81/typebox), [Valibot](https://github.com/fabian-hiller/valibot) and [Zod](https://github.com/colinhacks/zod) runtime type libraries. It offers a common TypeScript syntax for type construction, a runtime compiler for high-performance validation and type translation from one library to another. -TypeMap is written as an advanced type translation system for the [TypeBox](https://github.com/sinclairzx81/typebox) project. It is designed to accelerate remote type libraries on TypeBox infrastructure as well as to integrate TypeBox into remote type library infrastructure via reverse type remapping. This project also provides high-performance validation for frameworks that orientate around the [Standard Schema](https://github.com/standard-schema/standard-schema) TypeScript interface. +TypeMap is written as an advanced type mapping system for the TypeBox project. It is designed to accelerate remote type libraries on TypeBox infrastructure as well enabling TypeBox to integrate with remote type library infrastructure via reverse type remapping. This project also offers high-performance validation for frameworks that orientate around the [Standard Schema](https://github.com/standard-schema/standard-schema) TypeScript interface. License: MIT