@sinclair/typebox 0.32.25 → 0.32.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -177,7 +177,7 @@ export var Policy;
177
177
  }
178
178
  Policy.IsRecordLike = IsRecordLike;
179
179
  function IsNumberLike(value) {
180
- return !TypeSystemPolicy.AllowNaN ? `(typeof ${value} === 'number' && Number.isFinite(${value}))` : `typeof ${value} === 'number'`;
180
+ return TypeSystemPolicy.AllowNaN ? `typeof ${value} === 'number'` : `Number.isFinite(${value})`;
181
181
  }
182
182
  Policy.IsNumberLike = IsNumberLike;
183
183
  function IsVoidLike(value) {
@@ -263,7 +263,7 @@ export var TypeCompiler;
263
263
  yield `(typeof ${value} === 'function')`;
264
264
  }
265
265
  function* FromInteger(schema, references, value) {
266
- yield `(typeof ${value} === 'number' && Number.isInteger(${value}))`;
266
+ yield `Number.isInteger(${value})`;
267
267
  if (IsNumber(schema.exclusiveMaximum))
268
268
  yield `${value} < ${schema.exclusiveMaximum}`;
269
269
  if (IsNumber(schema.exclusiveMinimum))
@@ -31,8 +31,7 @@ export var TypeSystemPolicy;
31
31
  TypeSystemPolicy.IsRecordLike = IsRecordLike;
32
32
  /** Asserts this value using the AllowNaN policy */
33
33
  function IsNumberLike(value) {
34
- const isNumber = IsNumber(value);
35
- return TypeSystemPolicy.AllowNaN ? isNumber : isNumber && Number.isFinite(value);
34
+ return TypeSystemPolicy.AllowNaN ? IsNumber(value) : Number.isFinite(value);
36
35
  }
37
36
  TypeSystemPolicy.IsNumberLike = IsNumberLike;
38
37
  /** Asserts this value using the AllowVoidNull policy */
@@ -124,7 +124,7 @@ export function IsNumber(value) {
124
124
  }
125
125
  /** Returns true if this value is an integer */
126
126
  export function IsInteger(value) {
127
- return IsNumber(value) && Number.isInteger(value);
127
+ return Number.isInteger(value);
128
128
  }
129
129
  /** Returns true if this value is bigint */
130
130
  export function IsBigInt(value) {
@@ -177,7 +177,7 @@ var Policy;
177
177
  }
178
178
  Policy.IsRecordLike = IsRecordLike;
179
179
  function IsNumberLike(value) {
180
- return !index_3.TypeSystemPolicy.AllowNaN ? `(typeof ${value} === 'number' && Number.isFinite(${value}))` : `typeof ${value} === 'number'`;
180
+ return index_3.TypeSystemPolicy.AllowNaN ? `typeof ${value} === 'number'` : `Number.isFinite(${value})`;
181
181
  }
182
182
  Policy.IsNumberLike = IsNumberLike;
183
183
  function IsVoidLike(value) {
@@ -263,7 +263,7 @@ var TypeCompiler;
263
263
  yield `(typeof ${value} === 'function')`;
264
264
  }
265
265
  function* FromInteger(schema, references, value) {
266
- yield `(typeof ${value} === 'number' && Number.isInteger(${value}))`;
266
+ yield `Number.isInteger(${value})`;
267
267
  if ((0, index_11.IsNumber)(schema.exclusiveMaximum))
268
268
  yield `${value} < ${schema.exclusiveMaximum}`;
269
269
  if ((0, index_11.IsNumber)(schema.exclusiveMinimum))
@@ -35,8 +35,7 @@ var TypeSystemPolicy;
35
35
  TypeSystemPolicy.IsRecordLike = IsRecordLike;
36
36
  /** Asserts this value using the AllowNaN policy */
37
37
  function IsNumberLike(value) {
38
- const isNumber = (0, index_1.IsNumber)(value);
39
- return TypeSystemPolicy.AllowNaN ? isNumber : isNumber && Number.isFinite(value);
38
+ return TypeSystemPolicy.AllowNaN ? (0, index_1.IsNumber)(value) : Number.isFinite(value);
40
39
  }
41
40
  TypeSystemPolicy.IsNumberLike = IsNumberLike;
42
41
  /** Asserts this value using the AllowVoidNull policy */
@@ -156,7 +156,7 @@ function IsNumber(value) {
156
156
  exports.IsNumber = IsNumber;
157
157
  /** Returns true if this value is an integer */
158
158
  function IsInteger(value) {
159
- return IsNumber(value) && Number.isInteger(value);
159
+ return Number.isInteger(value);
160
160
  }
161
161
  exports.IsInteger = IsInteger;
162
162
  /** Returns true if this value is bigint */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinclair/typebox",
3
- "version": "0.32.25",
3
+ "version": "0.32.26",
4
4
  "description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
5
5
  "keywords": [
6
6
  "typescript",
package/readme.md CHANGED
@@ -53,7 +53,7 @@ type T = Static<typeof T> // type T = {
53
53
 
54
54
  TypeBox is a runtime type builder that creates in-memory Json Schema objects that infer as TypeScript types. The schematics produced by this library are designed to match the static type checking rules of the TypeScript compiler. TypeBox offers a unified type that can be statically checked by TypeScript and runtime asserted using standard Json Schema validation.
55
55
 
56
- This library is designed to allow Json Schema to compose with the same flexibility as TypeScript's programmable type system. It can be used as a simple tool to build up complex schematics or integrated into REST and RPC services to help validate data received over the wire.
56
+ This library is designed to allow Json Schema to compose similar to how types compose within TypeScript's type system. It can be used as a simple tool to build up complex schematics or integrated into REST and RPC services to help validate data received over the wire.
57
57
 
58
58
  License MIT
59
59
 
@@ -895,9 +895,9 @@ const K = Type.TemplateLiteral('prop${A|B|C}') // const K: TTemplateLitera
895
895
  // ]>
896
896
 
897
897
  const R = Type.Record(K, Type.String()) // const R: TObject<{
898
- // hello1: TString,
899
- // hello2: TString,
900
- // hello3: TString,
898
+ // propA: TString,
899
+ // propB: TString,
900
+ // propC: TString,
901
901
  // }>
902
902
  ```
903
903