From 38f05613fc92063fc3f8bbe470e4d600b3a6d6b4 Mon Sep 17 00:00:00 2001 From: sinclairzx81 Date: Tue, 28 Jan 2025 06:06:39 +0900 Subject: [PATCH] Revision 0.8.5 (#14) * Remove WeakMap lookup on Validator (Optimization) * Version --- package-lock.json | 4 ++-- package.json | 2 +- src/compile/compile.ts | 18 +++++++++--------- src/guard.ts | 2 +- src/typebox/typebox.ts | 3 +-- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index 25e5127..6574ea6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@sinclair/typemap", - "version": "0.8.4", + "version": "0.8.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@sinclair/typemap", - "version": "0.8.4", + "version": "0.8.5", "license": "MIT", "devDependencies": { "@arethetypeswrong/cli": "^0.17.2", diff --git a/package.json b/package.json index dc3a57a..d5ab2f0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@sinclair/typemap", - "version": "0.8.4", + "version": "0.8.5", "description": "Unified Syntax and Type Compiler for Runtime Type Systems", "author": "sinclairzx81", "license": "MIT", diff --git a/src/compile/compile.ts b/src/compile/compile.ts index 892a54a..14dfd94 100644 --- a/src/compile/compile.ts +++ b/src/compile/compile.ts @@ -72,31 +72,31 @@ export class StandardSchemaProps implements StandardSche // Validator // ------------------------------------------------------------------ export class Validator implements StandardSchemaV1> { - readonly #standard: StandardSchemaProps - readonly #check: TypeCheck + private readonly _standard: StandardSchemaProps + private readonly _check: TypeCheck constructor(check: TypeCheck) { - this.#standard = new StandardSchemaProps(check) - this.#check = check + this._standard = new StandardSchemaProps(check) + this._check = check } /** Standard Schema Interface */ public get ['~standard'](): StandardSchemaProps { - return this.#standard + return this._standard } /** Returns the code used by this validator. */ public Code(): string { - return this.#check.Code() + return this._check.Code() } /** Parses this value. Do not use this function for high throughput validation */ public Parse(value: unknown): t.StaticDecode { - return Value.Parse(this.#check.Schema(), value) + return Value.Parse(this._check.Schema(), value) } /** Checks if this value matches the type */ public Check(value: unknown): value is t.Static { - return this.#check.Check(value) + return this._check.Check(value) } /** Returns errors for this value */ public Errors(value: unknown): ValueErrorIterator { - return this.#check.Errors(value) + return this._check.Errors(value) } } // ------------------------------------------------------------------ diff --git a/src/guard.ts b/src/guard.ts index 059df32..439c27e 100644 --- a/src/guard.ts +++ b/src/guard.ts @@ -108,4 +108,4 @@ export function Signature(args: any[]): [parameter: Record, Signature4(args) ? [{}, args[0], {}] : [{}, 'never', {}] ) -} \ No newline at end of file +} diff --git a/src/typebox/typebox.ts b/src/typebox/typebox.ts index 1e1626e..bdaec9f 100644 --- a/src/typebox/typebox.ts +++ b/src/typebox/typebox.ts @@ -90,7 +90,6 @@ export function TypeBox(...args: any[]): never { options) as never } - /** Creates a TypeBox type from Syntax or another Type */ export function Type(parameter: Parameter, type: Type, options?: TSyntaxOptions): TTypeBox /** Creates a TypeBox type from Syntax or another Type */ @@ -99,4 +98,4 @@ export function Type(type: Type, options?: TSyntax // prettier-ignore export function Type(...args: any[]): never { return TypeBox.apply(null, args as never) as never -} \ No newline at end of file +}