Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sinclair/typebox

Package Overview
Dependencies
Maintainers
1
Versions
338
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sinclair/typebox - npm Package Compare versions

Comparing version 0.24.0 to 0.24.1

8

compiler/compiler.d.ts
import * as Types from '../typebox';
export declare type CheckFunction = (value: unknown) => CheckOk | CheckFail;
export interface CheckOk {
ok: true;
}
export interface CheckFail {
ok: false;
}
export declare type CheckFunction = (value: unknown) => boolean;
export declare class TypeCheckAssertError extends Error {

@@ -10,0 +4,0 @@ readonly schema: Types.TSchema;

16

compiler/compiler.js

@@ -54,4 +54,3 @@ "use strict";

Check(value) {
const result = this.checkFunc(value);
return result.ok;
return this.checkFunc(value);
}

@@ -63,4 +62,3 @@ /** Asserts the given value and throws a TypeCheckAssertError if invalid. */

// https://github.com/microsoft/TypeScript/issues/36931
const result = this.checkFunc(value);
if (!result.ok)
if (!this.checkFunc(value))
throw new TypeCheckAssertError(this.schema, value);

@@ -192,7 +190,7 @@ }

const func = CreateFunctionName(schema.$ref);
yield CreateCondition(schema, path, `(${func}(${path}).ok)`);
yield CreateCondition(schema, path, `(${func}(${path}))`);
}
function* Self(schema, path) {
const func = CreateFunctionName(schema.$ref);
yield CreateCondition(schema, path, `(${func}(${path}).ok)`);
yield CreateCondition(schema, path, `(${func}(${path}))`);
}

@@ -246,3 +244,3 @@ function* String(schema, path) {

PushLocal(body);
yield CreateCondition(schema, path, `(${name}(${path}).ok)`);
yield CreateCondition(schema, path, `(${name}(${path}))`);
return;

@@ -333,4 +331,4 @@ }

function CreateFunction(name, conditions) {
const statements = conditions.map((condition, index) => ` if(!${condition.expr}) { return { ok: false } }`);
return `function ${name}(value) {\n${statements.join('\n')}\n return { ok: true }\n}`;
const statements = conditions.map((condition, index) => ` if(!${condition.expr}) { return false }`);
return `function ${name}(value) {\n${statements.join('\n')}\n return true\n}`;
}

@@ -337,0 +335,0 @@ // -------------------------------------------------------------------

{
"name": "@sinclair/typebox",
"version": "0.24.0",
"version": "0.24.1",
"description": "JSONSchema Type Builder with Static Type Resolution for TypeScript",

@@ -5,0 +5,0 @@ "keywords": [

@@ -87,11 +87,2 @@ export declare const Kind: unique symbol;

}
export interface TExclude<T extends TUnion, U extends TUnion> extends TUnion {
[Kind]: 'Union';
static: Exclude<Static<T, this['params']>, Static<U, this['params']>>;
}
export interface TExtract<T extends TSchema, U extends TUnion> extends TUnion {
[Kind]: 'Union';
static: Extract<Static<T, this['params']>, Static<U, this['params']>>;
}
export declare type TExtends<T extends TSchema, U extends TSchema, X extends TSchema, Y extends TSchema> = T extends TAny ? (U extends TUnknown ? X : U extends TAny ? X : TUnion<[X, Y]>) : T extends U ? X : Y;
export declare type TFunctionParameters<T extends readonly TSchema[], P extends unknown[]> = [...{

@@ -98,0 +89,0 @@ [K in keyof T]: T[K] extends TSchema ? Static<T[K], P> : never;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc