typia
v7.5.1
// RUNTIME VALIDATORS
export function is < T > ( input : unknown ) : input is T ; // returns boolean
export function assert < T > ( input : unknown ) : T ; // throws TypeGuardError
export function assertGuard < T > ( input : unknown ) : asserts input is T ;
export function validate < T > ( input : unknown ) : IValidation < T > ; // detailed
// JSON FUNCTIONS
export namespace json {
export function application < T > ( ) : IJsonApplication ; // JSON schema
export function assertParse < T > ( input : string ) : T ; // type safe parser
export function assertStringify < T > ( input : T ) : string ; // safe and faster
}
// LLM FUNCTION CALLING SCHEMA
export namespace llm {
// application schema from a class or interface type
export function application < App , Model > ( ) : ILlmApplication < Model > ;
// structured output
export function parameters < P , Moodel > ( ) : ILlmSchema . IParameters < Model > ;
export function schema < T , Model > ( ) : ILlmSchema < Model > ; // type schema
}
// PROTOCOL BUFFER
export namespace protobuf {
export function message < T > ( ) : string ; // Protocol Buffer message
export function assertDecode < T > ( buffer : Uint8Array ) : T ; // safe decoder
export function assertEncode < T > ( input : T ) : Uint8Array ; // safe encoder
}
// RANDOM GENERATOR
export function random < T > ( g ?: Partial < IRandomGenerator > ) : T ; typia 는 아래 기능을 지원하는 변압기 라이브러리입니다.
메모
class-validator 보다 20,000 배 빠릅니다class-transformer 보다 200 배 빠릅니다 typia function을 호출하면 아래와 같이 컴파일됩니다.
이것은 typia 의 핵심 개념으로, TypeScript 유형을 런타임 함수로 변환합니다. typia.is<T>() 함수는 컴파일 레벨에서 대상 유형 T 분석하여 전용 유형 검사기로 변환됩니다.
이 기능을 통해 개발자는 응용 프로그램의 유형 안전을 보장하고 TypeScript의 정적 타이핑을 활용하면서 런타임 유효성 검사를 제공 할 수 있습니다. 추가 스키마를 정의하는 대신 순수한 TypeScript 유형 자체를 활용할 수 있습니다.
//----
// examples/checkString.ts
//----
import typia , { tags } from "typia" ;
export const checkString = typia . createIs < string > ( ) ;
//----
// examples/checkUUID.js
//----
import typia from "typia" ;
export const checkString = ( ( ) => {
return ( input ) => "string" === typeof input ;
} ) ( ) ; 지원해 주셔서 감사합니다.
귀하의 기부금은 typia 개발을 장려합니다.
또한 typia 기부금의 절반을 typia 의 핵심 기고자에게 재분배하고 있습니다.
nonara/ts-patchryoppippi/unplugin-typiaPlayground 웹 사이트에서 Typia의 작동 방식을 경험할 수 있습니다.
웹 사이트에서 문서를 확인하십시오.
assert() 함수is()validate()stringify() 함수parse() 함수application() 함수parameters() 함수schema() 함수decode() 함수encode() 함수dev.to . 기사