@sinclair/typebox 0.32.14 → 0.32.15

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.
Files changed (37) hide show
  1. package/build/import/compiler/index.d.mts +1 -1
  2. package/build/import/compiler/index.mjs +1 -1
  3. package/build/import/errors/index.d.mts +2 -2
  4. package/build/import/errors/index.mjs +2 -2
  5. package/build/import/system/index.d.mts +2 -2
  6. package/build/import/system/index.mjs +2 -2
  7. package/build/import/value/cast/cast.mjs +2 -2
  8. package/build/import/value/clone/clone.mjs +2 -2
  9. package/build/import/value/delta/delta.mjs +3 -3
  10. package/build/import/value/equal/equal.mjs +3 -3
  11. package/build/import/value/guard/guard.d.mts +34 -6
  12. package/build/import/value/guard/guard.mjs +71 -12
  13. package/build/import/value/hash/hash.mjs +2 -2
  14. package/build/import/value/index.d.mts +14 -14
  15. package/build/import/value/index.mjs +18 -18
  16. package/build/import/value/mutate/mutate.mjs +5 -5
  17. package/build/import/value/transform/decode.mjs +4 -4
  18. package/build/import/value/transform/encode.mjs +4 -4
  19. package/build/require/compiler/index.d.ts +1 -1
  20. package/build/require/compiler/index.js +16 -6
  21. package/build/require/errors/index.d.ts +2 -2
  22. package/build/require/errors/index.js +16 -10
  23. package/build/require/system/index.d.ts +2 -2
  24. package/build/require/system/index.js +16 -7
  25. package/build/require/value/cast/cast.js +1 -1
  26. package/build/require/value/clone/clone.js +1 -1
  27. package/build/require/value/delta/delta.js +2 -2
  28. package/build/require/value/equal/equal.js +2 -2
  29. package/build/require/value/guard/guard.d.ts +34 -6
  30. package/build/require/value/guard/guard.js +89 -16
  31. package/build/require/value/hash/hash.js +1 -1
  32. package/build/require/value/index.d.ts +14 -14
  33. package/build/require/value/index.js +35 -71
  34. package/build/require/value/mutate/mutate.js +4 -4
  35. package/build/require/value/transform/decode.js +3 -3
  36. package/build/require/value/transform/encode.js +3 -3
  37. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
1
  export { ValueError, ValueErrorType, ValueErrorIterator } from '../errors/index.mjs';
2
- export { TypeCompiler, TypeCheck, type TypeCompilerCodegenOptions, type TypeCompilerLanguageOption, TypeCompilerTypeGuardError, TypeCompilerUnknownTypeError } from './compiler.mjs';
2
+ export * from './compiler.mjs';
@@ -1,2 +1,2 @@
1
1
  export { ValueErrorType, ValueErrorIterator } from '../errors/index.mjs';
2
- export { TypeCompiler, TypeCheck, TypeCompilerTypeGuardError, TypeCompilerUnknownTypeError } from './compiler.mjs';
2
+ export * from './compiler.mjs';
@@ -1,2 +1,2 @@
1
- export { Errors, ValueError, ValueErrorIterator, ValueErrorType, ValueErrorsUnknownTypeError } from './errors.mjs';
2
- export { DefaultErrorFunction, GetErrorFunction, SetErrorFunction, type ErrorFunction, type ErrorFunctionParameter } from './function.mjs';
1
+ export * from './errors.mjs';
2
+ export * from './function.mjs';
@@ -1,2 +1,2 @@
1
- export { Errors, ValueErrorIterator, ValueErrorType, ValueErrorsUnknownTypeError } from './errors.mjs';
2
- export { DefaultErrorFunction, GetErrorFunction, SetErrorFunction } from './function.mjs';
1
+ export * from './errors.mjs';
2
+ export * from './function.mjs';
@@ -1,2 +1,2 @@
1
- export { TypeSystemPolicy } from './policy.mjs';
2
- export { TypeSystem, TypeSystemDuplicateFormat, TypeSystemDuplicateTypeKind } from './system.mjs';
1
+ export * from './policy.mjs';
2
+ export * from './system.mjs';
@@ -1,2 +1,2 @@
1
- export { TypeSystemPolicy } from './policy.mjs';
2
- export { TypeSystem, TypeSystemDuplicateFormat, TypeSystemDuplicateTypeKind } from './system.mjs';
1
+ export * from './policy.mjs';
2
+ export * from './system.mjs';
@@ -1,4 +1,4 @@
1
- import { IsPlainObject, IsArray, IsString, IsNumber, IsNull } from '../guard/index.mjs';
1
+ import { IsStandardObject, IsArray, IsString, IsNumber, IsNull } from '../guard/index.mjs';
2
2
  import { TypeBoxError } from '../../type/error/index.mjs';
3
3
  import { Kind } from '../../type/symbols/index.mjs';
4
4
  import { Create } from '../create/index.mjs';
@@ -100,7 +100,7 @@ function FromConstructor(schema, references, value) {
100
100
  }
101
101
  function FromIntersect(schema, references, value) {
102
102
  const created = Create(schema, references);
103
- const mapped = IsPlainObject(created) && IsPlainObject(value) ? { ...created, ...value } : value;
103
+ const mapped = IsStandardObject(created) && IsStandardObject(value) ? { ...created, ...value } : value;
104
104
  return Check(schema, references, mapped) ? mapped : Create(schema, references);
105
105
  }
106
106
  function FromNever(schema, references, value) {
@@ -1,7 +1,7 @@
1
1
  // ------------------------------------------------------------------
2
2
  // ValueGuard
3
3
  // ------------------------------------------------------------------
4
- import { IsArray, IsDate, IsPlainObject, IsTypedArray, IsValueType } from '../guard/index.mjs';
4
+ import { IsArray, IsDate, IsStandardObject, IsTypedArray, IsValueType } from '../guard/index.mjs';
5
5
  // ------------------------------------------------------------------
6
6
  // Clonable
7
7
  // ------------------------------------------------------------------
@@ -30,7 +30,7 @@ export function Clone(value) {
30
30
  return ArrayType(value);
31
31
  if (IsDate(value))
32
32
  return DateType(value);
33
- if (IsPlainObject(value))
33
+ if (IsStandardObject(value))
34
34
  return ObjectType(value);
35
35
  if (IsTypedArray(value))
36
36
  return TypedArrayType(value);
@@ -1,4 +1,4 @@
1
- import { IsPlainObject, IsArray, IsTypedArray, IsValueType, IsSymbol, IsUndefined } from '../guard/index.mjs';
1
+ import { IsStandardObject, IsArray, IsTypedArray, IsValueType, IsSymbol, IsUndefined } from '../guard/index.mjs';
2
2
  import { ValuePointer } from '../pointer/index.mjs';
3
3
  import { Clone } from '../clone/index.mjs';
4
4
  import { TypeBoxError } from '../../type/error/index.mjs';
@@ -55,7 +55,7 @@ function CreateDelete(path) {
55
55
  // Diffing Generators
56
56
  // ------------------------------------------------------------------
57
57
  function* ObjectType(path, current, next) {
58
- if (!IsPlainObject(next))
58
+ if (!IsStandardObject(next))
59
59
  return yield CreateUpdate(path, next);
60
60
  const currentKeys = [...globalThis.Object.keys(current), ...globalThis.Object.getOwnPropertySymbols(current)];
61
61
  const nextKeys = [...globalThis.Object.keys(next), ...globalThis.Object.getOwnPropertySymbols(next)];
@@ -115,7 +115,7 @@ function* ValueType(path, current, next) {
115
115
  yield CreateUpdate(path, next);
116
116
  }
117
117
  function* Visit(path, current, next) {
118
- if (IsPlainObject(current))
118
+ if (IsStandardObject(current))
119
119
  return yield* ObjectType(path, current, next);
120
120
  if (IsArray(current))
121
121
  return yield* ArrayType(path, current, next);
@@ -1,9 +1,9 @@
1
- import { IsPlainObject, IsDate, IsArray, IsTypedArray, IsValueType } from '../guard/index.mjs';
1
+ import { IsStandardObject, IsDate, IsArray, IsTypedArray, IsValueType } from '../guard/index.mjs';
2
2
  // ------------------------------------------------------------------
3
3
  // Equality Checks
4
4
  // ------------------------------------------------------------------
5
5
  function ObjectType(left, right) {
6
- if (!IsPlainObject(right))
6
+ if (!IsStandardObject(right))
7
7
  return false;
8
8
  const leftKeys = [...Object.keys(left), ...Object.getOwnPropertySymbols(left)];
9
9
  const rightKeys = [...Object.keys(right), ...Object.getOwnPropertySymbols(right)];
@@ -32,7 +32,7 @@ function ValueType(left, right) {
32
32
  // ------------------------------------------------------------------
33
33
  /** Returns true if the left value deep-equals the right */
34
34
  export function Equal(left, right) {
35
- if (IsPlainObject(left))
35
+ if (IsStandardObject(left))
36
36
  return ObjectType(left, right);
37
37
  if (IsDate(left))
38
38
  return DateType(left, right);
@@ -6,18 +6,46 @@ export type TypedArrayType = Int8Array | Uint8Array | Uint8ClampedArray | Int16A
6
6
  export declare function IsAsyncIterator(value: unknown): value is AsyncIterableIterator<any>;
7
7
  /** Returns true if this value is an iterator */
8
8
  export declare function IsIterator(value: unknown): value is IterableIterator<any>;
9
- /** Returns true if this value is a typed array */
10
- export declare function IsTypedArray(value: unknown): value is TypedArrayType;
9
+ /** Returns true if this value is not an instance of a class */
10
+ export declare function IsStandardObject(value: unknown): value is ObjectType;
11
+ /** Returns true if this value is an instance of a class */
12
+ export declare function IsInstanceObject(value: unknown): value is ObjectType;
11
13
  /** Returns true if this value is a Promise */
12
14
  export declare function IsPromise(value: unknown): value is Promise<unknown>;
13
- /** Returns true if the value is a Uint8Array */
14
- export declare function IsUint8Array(value: unknown): value is Uint8Array;
15
15
  /** Returns true if this value is a Date */
16
16
  export declare function IsDate(value: unknown): value is Date;
17
+ /** Returns true if this value is an instance of Map<K, T> */
18
+ export declare function IsMap(value: unknown): value is Map<unknown, unknown>;
19
+ /** Returns true if this value is an instance of Set<T> */
20
+ export declare function IsSet(value: unknown): value is Set<unknown>;
21
+ /** Returns true if this value is RegExp */
22
+ export declare function IsRegExp(value: unknown): value is RegExp;
23
+ /** Returns true if this value is a typed array */
24
+ export declare function IsTypedArray(value: unknown): value is TypedArrayType;
25
+ /** Returns true if the value is a Int8Array */
26
+ export declare function IsInt8Array(value: unknown): value is Int8Array;
27
+ /** Returns true if the value is a Uint8Array */
28
+ export declare function IsUint8Array(value: unknown): value is Uint8Array;
29
+ /** Returns true if the value is a Uint8ClampedArray */
30
+ export declare function IsUint8ClampedArray(value: unknown): value is Uint8ClampedArray;
31
+ /** Returns true if the value is a Int16Array */
32
+ export declare function IsInt16Array(value: unknown): value is Int16Array;
33
+ /** Returns true if the value is a Uint16Array */
34
+ export declare function IsUint16Array(value: unknown): value is Uint16Array;
35
+ /** Returns true if the value is a Int32Array */
36
+ export declare function IsInt32Array(value: unknown): value is Int32Array;
37
+ /** Returns true if the value is a Uint32Array */
38
+ export declare function IsUint32Array(value: unknown): value is Uint32Array;
39
+ /** Returns true if the value is a Float32Array */
40
+ export declare function IsFloat32Array(value: unknown): value is Float32Array;
41
+ /** Returns true if the value is a Float64Array */
42
+ export declare function IsFloat64Array(value: unknown): value is Float64Array;
43
+ /** Returns true if the value is a BigInt64Array */
44
+ export declare function IsBigInt64Array(value: unknown): value is BigInt64Array;
45
+ /** Returns true if the value is a BigUint64Array */
46
+ export declare function IsBigUint64Array(value: unknown): value is BigUint64Array;
17
47
  /** Returns true if this value has this property key */
18
48
  export declare function HasPropertyKey<K extends PropertyKey>(value: Record<any, unknown>, key: K): value is ObjectType & Record<K, unknown>;
19
- /** Returns true if this object is not an instance of any other type */
20
- export declare function IsPlainObject(value: unknown): value is ObjectType;
21
49
  /** Returns true of this value is an object type */
22
50
  export declare function IsObject(value: unknown): value is ObjectType;
23
51
  /** Returns true if this value is an array, but not a typed array */
@@ -10,24 +10,87 @@ export function IsIterator(value) {
10
10
  return IsObject(value) && Symbol.iterator in value;
11
11
  }
12
12
  // --------------------------------------------------------------------------
13
- // Nominal
13
+ // Object Instances
14
14
  // --------------------------------------------------------------------------
15
- /** Returns true if this value is a typed array */
16
- export function IsTypedArray(value) {
17
- return ArrayBuffer.isView(value);
15
+ /** Returns true if this value is not an instance of a class */
16
+ export function IsStandardObject(value) {
17
+ return IsObject(value) && !IsArray(value) && IsFunction(value.constructor) && value.constructor.name === 'Object';
18
+ }
19
+ /** Returns true if this value is an instance of a class */
20
+ export function IsInstanceObject(value) {
21
+ return IsObject(value) && !IsArray(value) && IsFunction(value.constructor) && value.constructor.name !== 'Object';
18
22
  }
23
+ // --------------------------------------------------------------------------
24
+ // JavaScript
25
+ // --------------------------------------------------------------------------
19
26
  /** Returns true if this value is a Promise */
20
27
  export function IsPromise(value) {
21
28
  return value instanceof Promise;
22
29
  }
23
- /** Returns true if the value is a Uint8Array */
24
- export function IsUint8Array(value) {
25
- return value instanceof Uint8Array;
26
- }
27
30
  /** Returns true if this value is a Date */
28
31
  export function IsDate(value) {
29
32
  return value instanceof Date && Number.isFinite(value.getTime());
30
33
  }
34
+ /** Returns true if this value is an instance of Map<K, T> */
35
+ export function IsMap(value) {
36
+ return value instanceof globalThis.Map;
37
+ }
38
+ /** Returns true if this value is an instance of Set<T> */
39
+ export function IsSet(value) {
40
+ return value instanceof globalThis.Set;
41
+ }
42
+ /** Returns true if this value is RegExp */
43
+ export function IsRegExp(value) {
44
+ return value instanceof globalThis.RegExp;
45
+ }
46
+ /** Returns true if this value is a typed array */
47
+ export function IsTypedArray(value) {
48
+ return ArrayBuffer.isView(value);
49
+ }
50
+ /** Returns true if the value is a Int8Array */
51
+ export function IsInt8Array(value) {
52
+ return value instanceof globalThis.Int8Array;
53
+ }
54
+ /** Returns true if the value is a Uint8Array */
55
+ export function IsUint8Array(value) {
56
+ return value instanceof globalThis.Uint8Array;
57
+ }
58
+ /** Returns true if the value is a Uint8ClampedArray */
59
+ export function IsUint8ClampedArray(value) {
60
+ return value instanceof globalThis.Uint8ClampedArray;
61
+ }
62
+ /** Returns true if the value is a Int16Array */
63
+ export function IsInt16Array(value) {
64
+ return value instanceof globalThis.Int16Array;
65
+ }
66
+ /** Returns true if the value is a Uint16Array */
67
+ export function IsUint16Array(value) {
68
+ return value instanceof globalThis.Uint16Array;
69
+ }
70
+ /** Returns true if the value is a Int32Array */
71
+ export function IsInt32Array(value) {
72
+ return value instanceof globalThis.Int32Array;
73
+ }
74
+ /** Returns true if the value is a Uint32Array */
75
+ export function IsUint32Array(value) {
76
+ return value instanceof globalThis.Uint32Array;
77
+ }
78
+ /** Returns true if the value is a Float32Array */
79
+ export function IsFloat32Array(value) {
80
+ return value instanceof globalThis.Float32Array;
81
+ }
82
+ /** Returns true if the value is a Float64Array */
83
+ export function IsFloat64Array(value) {
84
+ return value instanceof globalThis.Float64Array;
85
+ }
86
+ /** Returns true if the value is a BigInt64Array */
87
+ export function IsBigInt64Array(value) {
88
+ return value instanceof globalThis.BigInt64Array;
89
+ }
90
+ /** Returns true if the value is a BigUint64Array */
91
+ export function IsBigUint64Array(value) {
92
+ return value instanceof globalThis.BigUint64Array;
93
+ }
31
94
  // --------------------------------------------------------------------------
32
95
  // Standard
33
96
  // --------------------------------------------------------------------------
@@ -35,10 +98,6 @@ export function IsDate(value) {
35
98
  export function HasPropertyKey(value, key) {
36
99
  return key in value;
37
100
  }
38
- /** Returns true if this object is not an instance of any other type */
39
- export function IsPlainObject(value) {
40
- return IsObject(value) && IsFunction(value.constructor) && value.constructor.name === 'Object';
41
- }
42
101
  /** Returns true of this value is an object type */
43
102
  export function IsObject(value) {
44
103
  return value !== null && typeof value === 'object';
@@ -1,4 +1,4 @@
1
- import { IsArray, IsBoolean, IsBigInt, IsDate, IsNull, IsNumber, IsPlainObject, IsString, IsSymbol, IsUint8Array, IsUndefined } from '../guard/index.mjs';
1
+ import { IsArray, IsBoolean, IsBigInt, IsDate, IsNull, IsNumber, IsStandardObject, IsString, IsSymbol, IsUint8Array, IsUndefined } from '../guard/index.mjs';
2
2
  import { TypeBoxError } from '../../type/error/index.mjs';
3
3
  // ------------------------------------------------------------------
4
4
  // Errors
@@ -120,7 +120,7 @@ function Visit(value) {
120
120
  return NullType(value);
121
121
  if (IsNumber(value))
122
122
  return NumberType(value);
123
- if (IsPlainObject(value))
123
+ if (IsStandardObject(value))
124
124
  return ObjectType(value);
125
125
  if (IsString(value))
126
126
  return StringType(value);
@@ -1,16 +1,16 @@
1
1
  export { ValueError, ValueErrorType, ValueErrorIterator } from '../errors/index.mjs';
2
- export { Cast, ValueCastError } from './cast/index.mjs';
3
- export { Check } from './check/index.mjs';
4
- export { Clean } from './clean/index.mjs';
5
- export { Clone } from './clone/index.mjs';
6
- export { Convert } from './convert/index.mjs';
7
- export { Create, ValueCreateError } from './create/index.mjs';
8
- export { Default } from './default/index.mjs';
9
- export { Diff, Patch, Edit, Delete, Insert, Update, ValueDeltaError } from './delta/index.mjs';
10
- export { Equal } from './equal/index.mjs';
11
- export { Hash, ValueHashError } from './hash/index.mjs';
12
- export { Mutate, ValueMutateError, type Mutable } from './mutate/index.mjs';
13
- export { ValuePointer } from './pointer/index.mjs';
14
- export { TransformDecode, TransformEncode, HasTransform, TransformDecodeCheckError, TransformDecodeError, TransformEncodeCheckError, TransformEncodeError } from './transform/index.mjs';
15
- export { ArrayType, HasPropertyKey, IsArray, IsAsyncIterator, IsBigInt, IsBoolean, IsDate, IsFunction, IsInteger, IsIterator, IsNull, IsNumber, IsObject, IsPlainObject, IsPromise, IsString, IsSymbol, IsTypedArray, IsUint8Array, IsUndefined, IsValueType, type ObjectType, type TypedArrayType, type ValueType, } from './guard/index.mjs';
2
+ export * from './guard/index.mjs';
3
+ export * from './cast/index.mjs';
4
+ export * from './check/index.mjs';
5
+ export * from './clean/index.mjs';
6
+ export * from './clone/index.mjs';
7
+ export * from './convert/index.mjs';
8
+ export * from './create/index.mjs';
9
+ export * from './default/index.mjs';
10
+ export * from './delta/index.mjs';
11
+ export * from './equal/index.mjs';
12
+ export * from './hash/index.mjs';
13
+ export * from './mutate/index.mjs';
14
+ export * from './pointer/index.mjs';
15
+ export * from './transform/index.mjs';
16
16
  export { Value } from './value/index.mjs';
@@ -1,28 +1,28 @@
1
1
  // ------------------------------------------------------------------
2
- // Value Errors (re-export)
2
+ // Errors (re-export)
3
3
  // ------------------------------------------------------------------
4
4
  export { ValueErrorType, ValueErrorIterator } from '../errors/index.mjs';
5
5
  // ------------------------------------------------------------------
6
- // Value Operators
6
+ // Guards
7
7
  // ------------------------------------------------------------------
8
- export { Cast, ValueCastError } from './cast/index.mjs';
9
- export { Check } from './check/index.mjs';
10
- export { Clean } from './clean/index.mjs';
11
- export { Clone } from './clone/index.mjs';
12
- export { Convert } from './convert/index.mjs';
13
- export { Create, ValueCreateError } from './create/index.mjs';
14
- export { Default } from './default/index.mjs';
15
- export { Diff, Patch, Edit, Delete, Insert, Update, ValueDeltaError } from './delta/index.mjs';
16
- export { Equal } from './equal/index.mjs';
17
- export { Hash, ValueHashError } from './hash/index.mjs';
18
- export { Mutate, ValueMutateError } from './mutate/index.mjs';
19
- export { ValuePointer } from './pointer/index.mjs';
20
- export { TransformDecode, TransformEncode, HasTransform, TransformDecodeCheckError, TransformDecodeError, TransformEncodeCheckError, TransformEncodeError } from './transform/index.mjs';
8
+ export * from './guard/index.mjs';
21
9
  // ------------------------------------------------------------------
22
- // Value Guards
10
+ // Operators
23
11
  // ------------------------------------------------------------------
24
- export { HasPropertyKey, IsArray, IsAsyncIterator, IsBigInt, IsBoolean, IsDate, IsFunction, IsInteger, IsIterator, IsNull, IsNumber, IsObject, IsPlainObject, IsPromise, IsString, IsSymbol, IsTypedArray, IsUint8Array, IsUndefined, IsValueType, } from './guard/index.mjs';
12
+ export * from './cast/index.mjs';
13
+ export * from './check/index.mjs';
14
+ export * from './clean/index.mjs';
15
+ export * from './clone/index.mjs';
16
+ export * from './convert/index.mjs';
17
+ export * from './create/index.mjs';
18
+ export * from './default/index.mjs';
19
+ export * from './delta/index.mjs';
20
+ export * from './equal/index.mjs';
21
+ export * from './hash/index.mjs';
22
+ export * from './mutate/index.mjs';
23
+ export * from './pointer/index.mjs';
24
+ export * from './transform/index.mjs';
25
25
  // ------------------------------------------------------------------
26
- // Value Namespace
26
+ // Namespace
27
27
  // ------------------------------------------------------------------
28
28
  export { Value } from './value/index.mjs';
@@ -1,4 +1,4 @@
1
- import { IsPlainObject, IsArray, IsTypedArray, IsValueType } from '../guard/index.mjs';
1
+ import { IsStandardObject, IsArray, IsTypedArray, IsValueType } from '../guard/index.mjs';
2
2
  import { ValuePointer } from '../pointer/index.mjs';
3
3
  import { Clone } from '../clone/index.mjs';
4
4
  import { TypeBoxError } from '../../type/error/index.mjs';
@@ -11,7 +11,7 @@ export class ValueMutateError extends TypeBoxError {
11
11
  }
12
12
  }
13
13
  function ObjectType(root, path, current, next) {
14
- if (!IsPlainObject(current)) {
14
+ if (!IsStandardObject(current)) {
15
15
  ValuePointer.Set(root, path, Clone(next));
16
16
  }
17
17
  else {
@@ -63,7 +63,7 @@ function Visit(root, path, current, next) {
63
63
  return ArrayType(root, path, current, next);
64
64
  if (IsTypedArray(next))
65
65
  return TypedArrayType(root, path, current, next);
66
- if (IsPlainObject(next))
66
+ if (IsStandardObject(next))
67
67
  return ObjectType(root, path, current, next);
68
68
  if (IsValueType(next))
69
69
  return ValueType(root, path, current, next);
@@ -76,8 +76,8 @@ function IsNonMutableValue(value) {
76
76
  }
77
77
  function IsMismatchedValue(current, next) {
78
78
  // prettier-ignore
79
- return ((IsPlainObject(current) && IsArray(next)) ||
80
- (IsArray(current) && IsPlainObject(next)));
79
+ return ((IsStandardObject(current) && IsArray(next)) ||
80
+ (IsArray(current) && IsStandardObject(next)));
81
81
  }
82
82
  // ------------------------------------------------------------------
83
83
  // Mutate
@@ -7,7 +7,7 @@ import { Check } from '../check/index.mjs';
7
7
  // ------------------------------------------------------------------
8
8
  // ValueGuard
9
9
  // ------------------------------------------------------------------
10
- import { IsPlainObject, IsArray, IsValueType } from '../guard/index.mjs';
10
+ import { IsStandardObject, IsArray, IsValueType } from '../guard/index.mjs';
11
11
  // ------------------------------------------------------------------
12
12
  // TypeGuard
13
13
  // ------------------------------------------------------------------
@@ -56,7 +56,7 @@ function FromArray(schema, references, value) {
56
56
  }
57
57
  // prettier-ignore
58
58
  function FromIntersect(schema, references, value) {
59
- if (!IsPlainObject(value) || IsValueType(value))
59
+ if (!IsStandardObject(value) || IsValueType(value))
60
60
  return Default(schema, value);
61
61
  const knownKeys = KeyOfPropertyKeys(schema);
62
62
  const knownProperties = knownKeys.reduce((value, key) => {
@@ -81,7 +81,7 @@ function FromNot(schema, references, value) {
81
81
  }
82
82
  // prettier-ignore
83
83
  function FromObject(schema, references, value) {
84
- if (!IsPlainObject(value))
84
+ if (!IsStandardObject(value))
85
85
  return Default(schema, value);
86
86
  const knownKeys = KeyOfPropertyKeys(schema);
87
87
  const knownProperties = knownKeys.reduce((value, key) => {
@@ -103,7 +103,7 @@ function FromObject(schema, references, value) {
103
103
  }
104
104
  // prettier-ignore
105
105
  function FromRecord(schema, references, value) {
106
- if (!IsPlainObject(value))
106
+ if (!IsStandardObject(value))
107
107
  return Default(schema, value);
108
108
  const pattern = Object.getOwnPropertyNames(schema.patternProperties)[0];
109
109
  const knownKeys = new RegExp(pattern);
@@ -7,7 +7,7 @@ import { Check } from '../check/index.mjs';
7
7
  // ------------------------------------------------------------------
8
8
  // ValueGuard
9
9
  // ------------------------------------------------------------------
10
- import { IsPlainObject, IsArray, IsValueType } from '../guard/index.mjs';
10
+ import { IsStandardObject, IsArray, IsValueType } from '../guard/index.mjs';
11
11
  // ------------------------------------------------------------------
12
12
  // TypeGuard
13
13
  // ------------------------------------------------------------------
@@ -57,7 +57,7 @@ function FromArray(schema, references, value) {
57
57
  // prettier-ignore
58
58
  function FromIntersect(schema, references, value) {
59
59
  const defaulted = Default(schema, value);
60
- if (!IsPlainObject(value) || IsValueType(value))
60
+ if (!IsStandardObject(value) || IsValueType(value))
61
61
  return defaulted;
62
62
  const knownKeys = KeyOfPropertyKeys(schema);
63
63
  const knownProperties = knownKeys.reduce((value, key) => {
@@ -83,7 +83,7 @@ function FromNot(schema, references, value) {
83
83
  // prettier-ignore
84
84
  function FromObject(schema, references, value) {
85
85
  const defaulted = Default(schema, value);
86
- if (!IsPlainObject(value))
86
+ if (!IsStandardObject(value))
87
87
  return defaulted;
88
88
  const knownKeys = KeyOfPropertyKeys(schema);
89
89
  const knownProperties = knownKeys.reduce((value, key) => {
@@ -105,7 +105,7 @@ function FromObject(schema, references, value) {
105
105
  // prettier-ignore
106
106
  function FromRecord(schema, references, value) {
107
107
  const defaulted = Default(schema, value);
108
- if (!IsPlainObject(value))
108
+ if (!IsStandardObject(value))
109
109
  return defaulted;
110
110
  const pattern = Object.getOwnPropertyNames(schema.patternProperties)[0];
111
111
  const knownKeys = new RegExp(pattern);
@@ -1,2 +1,2 @@
1
1
  export { ValueError, ValueErrorType, ValueErrorIterator } from '../errors/index';
2
- export { TypeCompiler, TypeCheck, type TypeCompilerCodegenOptions, type TypeCompilerLanguageOption, TypeCompilerTypeGuardError, TypeCompilerUnknownTypeError } from './compiler';
2
+ export * from './compiler';
@@ -1,12 +1,22 @@
1
1
  "use strict";
2
2
 
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
+ };
3
17
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.TypeCompilerUnknownTypeError = exports.TypeCompilerTypeGuardError = exports.TypeCheck = exports.TypeCompiler = exports.ValueErrorIterator = exports.ValueErrorType = void 0;
18
+ exports.ValueErrorIterator = exports.ValueErrorType = void 0;
5
19
  var index_1 = require("../errors/index");
6
20
  Object.defineProperty(exports, "ValueErrorType", { enumerable: true, get: function () { return index_1.ValueErrorType; } });
7
21
  Object.defineProperty(exports, "ValueErrorIterator", { enumerable: true, get: function () { return index_1.ValueErrorIterator; } });
8
- var compiler_1 = require("./compiler");
9
- Object.defineProperty(exports, "TypeCompiler", { enumerable: true, get: function () { return compiler_1.TypeCompiler; } });
10
- Object.defineProperty(exports, "TypeCheck", { enumerable: true, get: function () { return compiler_1.TypeCheck; } });
11
- Object.defineProperty(exports, "TypeCompilerTypeGuardError", { enumerable: true, get: function () { return compiler_1.TypeCompilerTypeGuardError; } });
12
- Object.defineProperty(exports, "TypeCompilerUnknownTypeError", { enumerable: true, get: function () { return compiler_1.TypeCompilerUnknownTypeError; } });
22
+ __exportStar(require("./compiler"), exports);
@@ -1,2 +1,2 @@
1
- export { Errors, ValueError, ValueErrorIterator, ValueErrorType, ValueErrorsUnknownTypeError } from './errors';
2
- export { DefaultErrorFunction, GetErrorFunction, SetErrorFunction, type ErrorFunction, type ErrorFunctionParameter } from './function';
1
+ export * from './errors';
2
+ export * from './function';
@@ -1,13 +1,19 @@
1
1
  "use strict";
2
2
 
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
+ };
3
17
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.SetErrorFunction = exports.GetErrorFunction = exports.DefaultErrorFunction = exports.ValueErrorsUnknownTypeError = exports.ValueErrorType = exports.ValueErrorIterator = exports.Errors = void 0;
5
- var errors_1 = require("./errors");
6
- Object.defineProperty(exports, "Errors", { enumerable: true, get: function () { return errors_1.Errors; } });
7
- Object.defineProperty(exports, "ValueErrorIterator", { enumerable: true, get: function () { return errors_1.ValueErrorIterator; } });
8
- Object.defineProperty(exports, "ValueErrorType", { enumerable: true, get: function () { return errors_1.ValueErrorType; } });
9
- Object.defineProperty(exports, "ValueErrorsUnknownTypeError", { enumerable: true, get: function () { return errors_1.ValueErrorsUnknownTypeError; } });
10
- var function_1 = require("./function");
11
- Object.defineProperty(exports, "DefaultErrorFunction", { enumerable: true, get: function () { return function_1.DefaultErrorFunction; } });
12
- Object.defineProperty(exports, "GetErrorFunction", { enumerable: true, get: function () { return function_1.GetErrorFunction; } });
13
- Object.defineProperty(exports, "SetErrorFunction", { enumerable: true, get: function () { return function_1.SetErrorFunction; } });
18
+ __exportStar(require("./errors"), exports);
19
+ __exportStar(require("./function"), exports);
@@ -1,2 +1,2 @@
1
- export { TypeSystemPolicy } from './policy';
2
- export { TypeSystem, TypeSystemDuplicateFormat, TypeSystemDuplicateTypeKind } from './system';
1
+ export * from './policy';
2
+ export * from './system';
@@ -1,10 +1,19 @@
1
1
  "use strict";
2
2
 
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
+ };
3
17
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.TypeSystemDuplicateTypeKind = exports.TypeSystemDuplicateFormat = exports.TypeSystem = exports.TypeSystemPolicy = void 0;
5
- var policy_1 = require("./policy");
6
- Object.defineProperty(exports, "TypeSystemPolicy", { enumerable: true, get: function () { return policy_1.TypeSystemPolicy; } });
7
- var system_1 = require("./system");
8
- Object.defineProperty(exports, "TypeSystem", { enumerable: true, get: function () { return system_1.TypeSystem; } });
9
- Object.defineProperty(exports, "TypeSystemDuplicateFormat", { enumerable: true, get: function () { return system_1.TypeSystemDuplicateFormat; } });
10
- Object.defineProperty(exports, "TypeSystemDuplicateTypeKind", { enumerable: true, get: function () { return system_1.TypeSystemDuplicateTypeKind; } });
18
+ __exportStar(require("./policy"), exports);
19
+ __exportStar(require("./system"), exports);
@@ -104,7 +104,7 @@ function FromConstructor(schema, references, value) {
104
104
  }
105
105
  function FromIntersect(schema, references, value) {
106
106
  const created = (0, index_4.Create)(schema, references);
107
- const mapped = (0, index_1.IsPlainObject)(created) && (0, index_1.IsPlainObject)(value) ? { ...created, ...value } : value;
107
+ const mapped = (0, index_1.IsStandardObject)(created) && (0, index_1.IsStandardObject)(value) ? { ...created, ...value } : value;
108
108
  return (0, index_5.Check)(schema, references, mapped) ? mapped : (0, index_4.Create)(schema, references);
109
109
  }
110
110
  function FromNever(schema, references, value) {
@@ -34,7 +34,7 @@ function Clone(value) {
34
34
  return ArrayType(value);
35
35
  if ((0, index_1.IsDate)(value))
36
36
  return DateType(value);
37
- if ((0, index_1.IsPlainObject)(value))
37
+ if ((0, index_1.IsStandardObject)(value))
38
38
  return ObjectType(value);
39
39
  if ((0, index_1.IsTypedArray)(value))
40
40
  return TypedArrayType(value);
@@ -59,7 +59,7 @@ function CreateDelete(path) {
59
59
  // Diffing Generators
60
60
  // ------------------------------------------------------------------
61
61
  function* ObjectType(path, current, next) {
62
- if (!(0, index_1.IsPlainObject)(next))
62
+ if (!(0, index_1.IsStandardObject)(next))
63
63
  return yield CreateUpdate(path, next);
64
64
  const currentKeys = [...globalThis.Object.keys(current), ...globalThis.Object.getOwnPropertySymbols(current)];
65
65
  const nextKeys = [...globalThis.Object.keys(next), ...globalThis.Object.getOwnPropertySymbols(next)];
@@ -119,7 +119,7 @@ function* ValueType(path, current, next) {
119
119
  yield CreateUpdate(path, next);
120
120
  }
121
121
  function* Visit(path, current, next) {
122
- if ((0, index_1.IsPlainObject)(current))
122
+ if ((0, index_1.IsStandardObject)(current))
123
123
  return yield* ObjectType(path, current, next);
124
124
  if ((0, index_1.IsArray)(current))
125
125
  return yield* ArrayType(path, current, next);
@@ -7,7 +7,7 @@ const index_1 = require("../guard/index");
7
7
  // Equality Checks
8
8
  // ------------------------------------------------------------------
9
9
  function ObjectType(left, right) {
10
- if (!(0, index_1.IsPlainObject)(right))
10
+ if (!(0, index_1.IsStandardObject)(right))
11
11
  return false;
12
12
  const leftKeys = [...Object.keys(left), ...Object.getOwnPropertySymbols(left)];
13
13
  const rightKeys = [...Object.keys(right), ...Object.getOwnPropertySymbols(right)];
@@ -36,7 +36,7 @@ function ValueType(left, right) {
36
36
  // ------------------------------------------------------------------
37
37
  /** Returns true if the left value deep-equals the right */
38
38
  function Equal(left, right) {
39
- if ((0, index_1.IsPlainObject)(left))
39
+ if ((0, index_1.IsStandardObject)(left))
40
40
  return ObjectType(left, right);
41
41
  if ((0, index_1.IsDate)(left))
42
42
  return DateType(left, right);
@@ -6,18 +6,46 @@ export type TypedArrayType = Int8Array | Uint8Array | Uint8ClampedArray | Int16A
6
6
  export declare function IsAsyncIterator(value: unknown): value is AsyncIterableIterator<any>;
7
7
  /** Returns true if this value is an iterator */
8
8
  export declare function IsIterator(value: unknown): value is IterableIterator<any>;
9
- /** Returns true if this value is a typed array */
10
- export declare function IsTypedArray(value: unknown): value is TypedArrayType;
9
+ /** Returns true if this value is not an instance of a class */
10
+ export declare function IsStandardObject(value: unknown): value is ObjectType;
11
+ /** Returns true if this value is an instance of a class */
12
+ export declare function IsInstanceObject(value: unknown): value is ObjectType;
11
13
  /** Returns true if this value is a Promise */
12
14
  export declare function IsPromise(value: unknown): value is Promise<unknown>;
13
- /** Returns true if the value is a Uint8Array */
14
- export declare function IsUint8Array(value: unknown): value is Uint8Array;
15
15
  /** Returns true if this value is a Date */
16
16
  export declare function IsDate(value: unknown): value is Date;
17
+ /** Returns true if this value is an instance of Map<K, T> */
18
+ export declare function IsMap(value: unknown): value is Map<unknown, unknown>;
19
+ /** Returns true if this value is an instance of Set<T> */
20
+ export declare function IsSet(value: unknown): value is Set<unknown>;
21
+ /** Returns true if this value is RegExp */
22
+ export declare function IsRegExp(value: unknown): value is RegExp;
23
+ /** Returns true if this value is a typed array */
24
+ export declare function IsTypedArray(value: unknown): value is TypedArrayType;
25
+ /** Returns true if the value is a Int8Array */
26
+ export declare function IsInt8Array(value: unknown): value is Int8Array;
27
+ /** Returns true if the value is a Uint8Array */
28
+ export declare function IsUint8Array(value: unknown): value is Uint8Array;
29
+ /** Returns true if the value is a Uint8ClampedArray */
30
+ export declare function IsUint8ClampedArray(value: unknown): value is Uint8ClampedArray;
31
+ /** Returns true if the value is a Int16Array */
32
+ export declare function IsInt16Array(value: unknown): value is Int16Array;
33
+ /** Returns true if the value is a Uint16Array */
34
+ export declare function IsUint16Array(value: unknown): value is Uint16Array;
35
+ /** Returns true if the value is a Int32Array */
36
+ export declare function IsInt32Array(value: unknown): value is Int32Array;
37
+ /** Returns true if the value is a Uint32Array */
38
+ export declare function IsUint32Array(value: unknown): value is Uint32Array;
39
+ /** Returns true if the value is a Float32Array */
40
+ export declare function IsFloat32Array(value: unknown): value is Float32Array;
41
+ /** Returns true if the value is a Float64Array */
42
+ export declare function IsFloat64Array(value: unknown): value is Float64Array;
43
+ /** Returns true if the value is a BigInt64Array */
44
+ export declare function IsBigInt64Array(value: unknown): value is BigInt64Array;
45
+ /** Returns true if the value is a BigUint64Array */
46
+ export declare function IsBigUint64Array(value: unknown): value is BigUint64Array;
17
47
  /** Returns true if this value has this property key */
18
48
  export declare function HasPropertyKey<K extends PropertyKey>(value: Record<any, unknown>, key: K): value is ObjectType & Record<K, unknown>;
19
- /** Returns true if this object is not an instance of any other type */
20
- export declare function IsPlainObject(value: unknown): value is ObjectType;
21
49
  /** Returns true of this value is an object type */
22
50
  export declare function IsObject(value: unknown): value is ObjectType;
23
51
  /** Returns true if this value is an array, but not a typed array */
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.IsValueType = exports.IsSymbol = exports.IsFunction = exports.IsString = exports.IsBigInt = exports.IsInteger = exports.IsNumber = exports.IsBoolean = exports.IsNull = exports.IsUndefined = exports.IsArray = exports.IsObject = exports.IsPlainObject = exports.HasPropertyKey = exports.IsDate = exports.IsUint8Array = exports.IsPromise = exports.IsTypedArray = exports.IsIterator = exports.IsAsyncIterator = void 0;
4
+ exports.IsValueType = exports.IsSymbol = exports.IsFunction = exports.IsString = exports.IsBigInt = exports.IsInteger = exports.IsNumber = exports.IsBoolean = exports.IsNull = exports.IsUndefined = exports.IsArray = exports.IsObject = exports.HasPropertyKey = exports.IsBigUint64Array = exports.IsBigInt64Array = exports.IsFloat64Array = exports.IsFloat32Array = exports.IsUint32Array = exports.IsInt32Array = exports.IsUint16Array = exports.IsInt16Array = exports.IsUint8ClampedArray = exports.IsUint8Array = exports.IsInt8Array = exports.IsTypedArray = exports.IsRegExp = exports.IsSet = exports.IsMap = exports.IsDate = exports.IsPromise = exports.IsInstanceObject = exports.IsStandardObject = exports.IsIterator = exports.IsAsyncIterator = void 0;
5
5
  // --------------------------------------------------------------------------
6
6
  // Iterators
7
7
  // --------------------------------------------------------------------------
@@ -16,28 +16,106 @@ function IsIterator(value) {
16
16
  }
17
17
  exports.IsIterator = IsIterator;
18
18
  // --------------------------------------------------------------------------
19
- // Nominal
19
+ // Object Instances
20
20
  // --------------------------------------------------------------------------
21
- /** Returns true if this value is a typed array */
22
- function IsTypedArray(value) {
23
- return ArrayBuffer.isView(value);
21
+ /** Returns true if this value is not an instance of a class */
22
+ function IsStandardObject(value) {
23
+ return IsObject(value) && !IsArray(value) && IsFunction(value.constructor) && value.constructor.name === 'Object';
24
24
  }
25
- exports.IsTypedArray = IsTypedArray;
25
+ exports.IsStandardObject = IsStandardObject;
26
+ /** Returns true if this value is an instance of a class */
27
+ function IsInstanceObject(value) {
28
+ return IsObject(value) && !IsArray(value) && IsFunction(value.constructor) && value.constructor.name !== 'Object';
29
+ }
30
+ exports.IsInstanceObject = IsInstanceObject;
31
+ // --------------------------------------------------------------------------
32
+ // JavaScript
33
+ // --------------------------------------------------------------------------
26
34
  /** Returns true if this value is a Promise */
27
35
  function IsPromise(value) {
28
36
  return value instanceof Promise;
29
37
  }
30
38
  exports.IsPromise = IsPromise;
31
- /** Returns true if the value is a Uint8Array */
32
- function IsUint8Array(value) {
33
- return value instanceof Uint8Array;
34
- }
35
- exports.IsUint8Array = IsUint8Array;
36
39
  /** Returns true if this value is a Date */
37
40
  function IsDate(value) {
38
41
  return value instanceof Date && Number.isFinite(value.getTime());
39
42
  }
40
43
  exports.IsDate = IsDate;
44
+ /** Returns true if this value is an instance of Map<K, T> */
45
+ function IsMap(value) {
46
+ return value instanceof globalThis.Map;
47
+ }
48
+ exports.IsMap = IsMap;
49
+ /** Returns true if this value is an instance of Set<T> */
50
+ function IsSet(value) {
51
+ return value instanceof globalThis.Set;
52
+ }
53
+ exports.IsSet = IsSet;
54
+ /** Returns true if this value is RegExp */
55
+ function IsRegExp(value) {
56
+ return value instanceof globalThis.RegExp;
57
+ }
58
+ exports.IsRegExp = IsRegExp;
59
+ /** Returns true if this value is a typed array */
60
+ function IsTypedArray(value) {
61
+ return ArrayBuffer.isView(value);
62
+ }
63
+ exports.IsTypedArray = IsTypedArray;
64
+ /** Returns true if the value is a Int8Array */
65
+ function IsInt8Array(value) {
66
+ return value instanceof globalThis.Int8Array;
67
+ }
68
+ exports.IsInt8Array = IsInt8Array;
69
+ /** Returns true if the value is a Uint8Array */
70
+ function IsUint8Array(value) {
71
+ return value instanceof globalThis.Uint8Array;
72
+ }
73
+ exports.IsUint8Array = IsUint8Array;
74
+ /** Returns true if the value is a Uint8ClampedArray */
75
+ function IsUint8ClampedArray(value) {
76
+ return value instanceof globalThis.Uint8ClampedArray;
77
+ }
78
+ exports.IsUint8ClampedArray = IsUint8ClampedArray;
79
+ /** Returns true if the value is a Int16Array */
80
+ function IsInt16Array(value) {
81
+ return value instanceof globalThis.Int16Array;
82
+ }
83
+ exports.IsInt16Array = IsInt16Array;
84
+ /** Returns true if the value is a Uint16Array */
85
+ function IsUint16Array(value) {
86
+ return value instanceof globalThis.Uint16Array;
87
+ }
88
+ exports.IsUint16Array = IsUint16Array;
89
+ /** Returns true if the value is a Int32Array */
90
+ function IsInt32Array(value) {
91
+ return value instanceof globalThis.Int32Array;
92
+ }
93
+ exports.IsInt32Array = IsInt32Array;
94
+ /** Returns true if the value is a Uint32Array */
95
+ function IsUint32Array(value) {
96
+ return value instanceof globalThis.Uint32Array;
97
+ }
98
+ exports.IsUint32Array = IsUint32Array;
99
+ /** Returns true if the value is a Float32Array */
100
+ function IsFloat32Array(value) {
101
+ return value instanceof globalThis.Float32Array;
102
+ }
103
+ exports.IsFloat32Array = IsFloat32Array;
104
+ /** Returns true if the value is a Float64Array */
105
+ function IsFloat64Array(value) {
106
+ return value instanceof globalThis.Float64Array;
107
+ }
108
+ exports.IsFloat64Array = IsFloat64Array;
109
+ /** Returns true if the value is a BigInt64Array */
110
+ function IsBigInt64Array(value) {
111
+ return value instanceof globalThis.BigInt64Array;
112
+ }
113
+ exports.IsBigInt64Array = IsBigInt64Array;
114
+ /** Returns true if the value is a BigUint64Array */
115
+ function IsBigUint64Array(value) {
116
+ return value instanceof globalThis.BigUint64Array;
117
+ }
118
+ exports.IsBigUint64Array = IsBigUint64Array;
41
119
  // --------------------------------------------------------------------------
42
120
  // Standard
43
121
  // --------------------------------------------------------------------------
@@ -46,11 +124,6 @@ function HasPropertyKey(value, key) {
46
124
  return key in value;
47
125
  }
48
126
  exports.HasPropertyKey = HasPropertyKey;
49
- /** Returns true if this object is not an instance of any other type */
50
- function IsPlainObject(value) {
51
- return IsObject(value) && IsFunction(value.constructor) && value.constructor.name === 'Object';
52
- }
53
- exports.IsPlainObject = IsPlainObject;
54
127
  /** Returns true of this value is an object type */
55
128
  function IsObject(value) {
56
129
  return value !== null && typeof value === 'object';
@@ -124,7 +124,7 @@ function Visit(value) {
124
124
  return NullType(value);
125
125
  if ((0, index_1.IsNumber)(value))
126
126
  return NumberType(value);
127
- if ((0, index_1.IsPlainObject)(value))
127
+ if ((0, index_1.IsStandardObject)(value))
128
128
  return ObjectType(value);
129
129
  if ((0, index_1.IsString)(value))
130
130
  return StringType(value);
@@ -1,16 +1,16 @@
1
1
  export { ValueError, ValueErrorType, ValueErrorIterator } from '../errors/index';
2
- export { Cast, ValueCastError } from './cast/index';
3
- export { Check } from './check/index';
4
- export { Clean } from './clean/index';
5
- export { Clone } from './clone/index';
6
- export { Convert } from './convert/index';
7
- export { Create, ValueCreateError } from './create/index';
8
- export { Default } from './default/index';
9
- export { Diff, Patch, Edit, Delete, Insert, Update, ValueDeltaError } from './delta/index';
10
- export { Equal } from './equal/index';
11
- export { Hash, ValueHashError } from './hash/index';
12
- export { Mutate, ValueMutateError, type Mutable } from './mutate/index';
13
- export { ValuePointer } from './pointer/index';
14
- export { TransformDecode, TransformEncode, HasTransform, TransformDecodeCheckError, TransformDecodeError, TransformEncodeCheckError, TransformEncodeError } from './transform/index';
15
- export { ArrayType, HasPropertyKey, IsArray, IsAsyncIterator, IsBigInt, IsBoolean, IsDate, IsFunction, IsInteger, IsIterator, IsNull, IsNumber, IsObject, IsPlainObject, IsPromise, IsString, IsSymbol, IsTypedArray, IsUint8Array, IsUndefined, IsValueType, type ObjectType, type TypedArrayType, type ValueType, } from './guard/index';
2
+ export * from './guard/index';
3
+ export * from './cast/index';
4
+ export * from './check/index';
5
+ export * from './clean/index';
6
+ export * from './clone/index';
7
+ export * from './convert/index';
8
+ export * from './create/index';
9
+ export * from './default/index';
10
+ export * from './delta/index';
11
+ export * from './equal/index';
12
+ export * from './hash/index';
13
+ export * from './mutate/index';
14
+ export * from './pointer/index';
15
+ export * from './transform/index';
16
16
  export { Value } from './value/index';
@@ -1,85 +1,49 @@
1
1
  "use strict";
2
2
 
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
+ };
3
17
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.IsUndefined = exports.IsUint8Array = exports.IsTypedArray = exports.IsSymbol = exports.IsString = exports.IsPromise = exports.IsPlainObject = exports.IsObject = exports.IsNumber = exports.IsNull = exports.IsIterator = exports.IsInteger = exports.IsFunction = exports.IsDate = exports.IsBoolean = exports.IsBigInt = exports.IsAsyncIterator = exports.IsArray = exports.HasPropertyKey = exports.TransformEncodeError = exports.TransformEncodeCheckError = exports.TransformDecodeError = exports.TransformDecodeCheckError = exports.HasTransform = exports.TransformEncode = exports.TransformDecode = exports.ValuePointer = exports.ValueMutateError = exports.Mutate = exports.ValueHashError = exports.Hash = exports.Equal = exports.ValueDeltaError = exports.Update = exports.Insert = exports.Delete = exports.Edit = exports.Patch = exports.Diff = exports.Default = exports.ValueCreateError = exports.Create = exports.Convert = exports.Clone = exports.Clean = exports.Check = exports.ValueCastError = exports.Cast = exports.ValueErrorIterator = exports.ValueErrorType = void 0;
5
- exports.Value = exports.IsValueType = void 0;
18
+ exports.Value = exports.ValueErrorIterator = exports.ValueErrorType = void 0;
6
19
  // ------------------------------------------------------------------
7
- // Value Errors (re-export)
20
+ // Errors (re-export)
8
21
  // ------------------------------------------------------------------
9
22
  var index_1 = require("../errors/index");
10
23
  Object.defineProperty(exports, "ValueErrorType", { enumerable: true, get: function () { return index_1.ValueErrorType; } });
11
24
  Object.defineProperty(exports, "ValueErrorIterator", { enumerable: true, get: function () { return index_1.ValueErrorIterator; } });
12
25
  // ------------------------------------------------------------------
13
- // Value Operators
26
+ // Guards
14
27
  // ------------------------------------------------------------------
15
- var index_2 = require("./cast/index");
16
- Object.defineProperty(exports, "Cast", { enumerable: true, get: function () { return index_2.Cast; } });
17
- Object.defineProperty(exports, "ValueCastError", { enumerable: true, get: function () { return index_2.ValueCastError; } });
18
- var index_3 = require("./check/index");
19
- Object.defineProperty(exports, "Check", { enumerable: true, get: function () { return index_3.Check; } });
20
- var index_4 = require("./clean/index");
21
- Object.defineProperty(exports, "Clean", { enumerable: true, get: function () { return index_4.Clean; } });
22
- var index_5 = require("./clone/index");
23
- Object.defineProperty(exports, "Clone", { enumerable: true, get: function () { return index_5.Clone; } });
24
- var index_6 = require("./convert/index");
25
- Object.defineProperty(exports, "Convert", { enumerable: true, get: function () { return index_6.Convert; } });
26
- var index_7 = require("./create/index");
27
- Object.defineProperty(exports, "Create", { enumerable: true, get: function () { return index_7.Create; } });
28
- Object.defineProperty(exports, "ValueCreateError", { enumerable: true, get: function () { return index_7.ValueCreateError; } });
29
- var index_8 = require("./default/index");
30
- Object.defineProperty(exports, "Default", { enumerable: true, get: function () { return index_8.Default; } });
31
- var index_9 = require("./delta/index");
32
- Object.defineProperty(exports, "Diff", { enumerable: true, get: function () { return index_9.Diff; } });
33
- Object.defineProperty(exports, "Patch", { enumerable: true, get: function () { return index_9.Patch; } });
34
- Object.defineProperty(exports, "Edit", { enumerable: true, get: function () { return index_9.Edit; } });
35
- Object.defineProperty(exports, "Delete", { enumerable: true, get: function () { return index_9.Delete; } });
36
- Object.defineProperty(exports, "Insert", { enumerable: true, get: function () { return index_9.Insert; } });
37
- Object.defineProperty(exports, "Update", { enumerable: true, get: function () { return index_9.Update; } });
38
- Object.defineProperty(exports, "ValueDeltaError", { enumerable: true, get: function () { return index_9.ValueDeltaError; } });
39
- var index_10 = require("./equal/index");
40
- Object.defineProperty(exports, "Equal", { enumerable: true, get: function () { return index_10.Equal; } });
41
- var index_11 = require("./hash/index");
42
- Object.defineProperty(exports, "Hash", { enumerable: true, get: function () { return index_11.Hash; } });
43
- Object.defineProperty(exports, "ValueHashError", { enumerable: true, get: function () { return index_11.ValueHashError; } });
44
- var index_12 = require("./mutate/index");
45
- Object.defineProperty(exports, "Mutate", { enumerable: true, get: function () { return index_12.Mutate; } });
46
- Object.defineProperty(exports, "ValueMutateError", { enumerable: true, get: function () { return index_12.ValueMutateError; } });
47
- var index_13 = require("./pointer/index");
48
- Object.defineProperty(exports, "ValuePointer", { enumerable: true, get: function () { return index_13.ValuePointer; } });
49
- var index_14 = require("./transform/index");
50
- Object.defineProperty(exports, "TransformDecode", { enumerable: true, get: function () { return index_14.TransformDecode; } });
51
- Object.defineProperty(exports, "TransformEncode", { enumerable: true, get: function () { return index_14.TransformEncode; } });
52
- Object.defineProperty(exports, "HasTransform", { enumerable: true, get: function () { return index_14.HasTransform; } });
53
- Object.defineProperty(exports, "TransformDecodeCheckError", { enumerable: true, get: function () { return index_14.TransformDecodeCheckError; } });
54
- Object.defineProperty(exports, "TransformDecodeError", { enumerable: true, get: function () { return index_14.TransformDecodeError; } });
55
- Object.defineProperty(exports, "TransformEncodeCheckError", { enumerable: true, get: function () { return index_14.TransformEncodeCheckError; } });
56
- Object.defineProperty(exports, "TransformEncodeError", { enumerable: true, get: function () { return index_14.TransformEncodeError; } });
28
+ __exportStar(require("./guard/index"), exports);
57
29
  // ------------------------------------------------------------------
58
- // Value Guards
30
+ // Operators
59
31
  // ------------------------------------------------------------------
60
- var index_15 = require("./guard/index");
61
- Object.defineProperty(exports, "HasPropertyKey", { enumerable: true, get: function () { return index_15.HasPropertyKey; } });
62
- Object.defineProperty(exports, "IsArray", { enumerable: true, get: function () { return index_15.IsArray; } });
63
- Object.defineProperty(exports, "IsAsyncIterator", { enumerable: true, get: function () { return index_15.IsAsyncIterator; } });
64
- Object.defineProperty(exports, "IsBigInt", { enumerable: true, get: function () { return index_15.IsBigInt; } });
65
- Object.defineProperty(exports, "IsBoolean", { enumerable: true, get: function () { return index_15.IsBoolean; } });
66
- Object.defineProperty(exports, "IsDate", { enumerable: true, get: function () { return index_15.IsDate; } });
67
- Object.defineProperty(exports, "IsFunction", { enumerable: true, get: function () { return index_15.IsFunction; } });
68
- Object.defineProperty(exports, "IsInteger", { enumerable: true, get: function () { return index_15.IsInteger; } });
69
- Object.defineProperty(exports, "IsIterator", { enumerable: true, get: function () { return index_15.IsIterator; } });
70
- Object.defineProperty(exports, "IsNull", { enumerable: true, get: function () { return index_15.IsNull; } });
71
- Object.defineProperty(exports, "IsNumber", { enumerable: true, get: function () { return index_15.IsNumber; } });
72
- Object.defineProperty(exports, "IsObject", { enumerable: true, get: function () { return index_15.IsObject; } });
73
- Object.defineProperty(exports, "IsPlainObject", { enumerable: true, get: function () { return index_15.IsPlainObject; } });
74
- Object.defineProperty(exports, "IsPromise", { enumerable: true, get: function () { return index_15.IsPromise; } });
75
- Object.defineProperty(exports, "IsString", { enumerable: true, get: function () { return index_15.IsString; } });
76
- Object.defineProperty(exports, "IsSymbol", { enumerable: true, get: function () { return index_15.IsSymbol; } });
77
- Object.defineProperty(exports, "IsTypedArray", { enumerable: true, get: function () { return index_15.IsTypedArray; } });
78
- Object.defineProperty(exports, "IsUint8Array", { enumerable: true, get: function () { return index_15.IsUint8Array; } });
79
- Object.defineProperty(exports, "IsUndefined", { enumerable: true, get: function () { return index_15.IsUndefined; } });
80
- Object.defineProperty(exports, "IsValueType", { enumerable: true, get: function () { return index_15.IsValueType; } });
32
+ __exportStar(require("./cast/index"), exports);
33
+ __exportStar(require("./check/index"), exports);
34
+ __exportStar(require("./clean/index"), exports);
35
+ __exportStar(require("./clone/index"), exports);
36
+ __exportStar(require("./convert/index"), exports);
37
+ __exportStar(require("./create/index"), exports);
38
+ __exportStar(require("./default/index"), exports);
39
+ __exportStar(require("./delta/index"), exports);
40
+ __exportStar(require("./equal/index"), exports);
41
+ __exportStar(require("./hash/index"), exports);
42
+ __exportStar(require("./mutate/index"), exports);
43
+ __exportStar(require("./pointer/index"), exports);
44
+ __exportStar(require("./transform/index"), exports);
81
45
  // ------------------------------------------------------------------
82
- // Value Namespace
46
+ // Namespace
83
47
  // ------------------------------------------------------------------
84
- var index_16 = require("./value/index");
85
- Object.defineProperty(exports, "Value", { enumerable: true, get: function () { return index_16.Value; } });
48
+ var index_2 = require("./value/index");
49
+ Object.defineProperty(exports, "Value", { enumerable: true, get: function () { return index_2.Value; } });
@@ -16,7 +16,7 @@ class ValueMutateError extends index_4.TypeBoxError {
16
16
  }
17
17
  exports.ValueMutateError = ValueMutateError;
18
18
  function ObjectType(root, path, current, next) {
19
- if (!(0, index_1.IsPlainObject)(current)) {
19
+ if (!(0, index_1.IsStandardObject)(current)) {
20
20
  index_2.ValuePointer.Set(root, path, (0, index_3.Clone)(next));
21
21
  }
22
22
  else {
@@ -68,7 +68,7 @@ function Visit(root, path, current, next) {
68
68
  return ArrayType(root, path, current, next);
69
69
  if ((0, index_1.IsTypedArray)(next))
70
70
  return TypedArrayType(root, path, current, next);
71
- if ((0, index_1.IsPlainObject)(next))
71
+ if ((0, index_1.IsStandardObject)(next))
72
72
  return ObjectType(root, path, current, next);
73
73
  if ((0, index_1.IsValueType)(next))
74
74
  return ValueType(root, path, current, next);
@@ -81,8 +81,8 @@ function IsNonMutableValue(value) {
81
81
  }
82
82
  function IsMismatchedValue(current, next) {
83
83
  // prettier-ignore
84
- return (((0, index_1.IsPlainObject)(current) && (0, index_1.IsArray)(next)) ||
85
- ((0, index_1.IsArray)(current) && (0, index_1.IsPlainObject)(next)));
84
+ return (((0, index_1.IsStandardObject)(current) && (0, index_1.IsArray)(next)) ||
85
+ ((0, index_1.IsArray)(current) && (0, index_1.IsStandardObject)(next)));
86
86
  }
87
87
  // ------------------------------------------------------------------
88
88
  // Mutate
@@ -57,7 +57,7 @@ function FromArray(schema, references, value) {
57
57
  }
58
58
  // prettier-ignore
59
59
  function FromIntersect(schema, references, value) {
60
- if (!(0, index_7.IsPlainObject)(value) || (0, index_7.IsValueType)(value))
60
+ if (!(0, index_7.IsStandardObject)(value) || (0, index_7.IsValueType)(value))
61
61
  return Default(schema, value);
62
62
  const knownKeys = (0, index_3.KeyOfPropertyKeys)(schema);
63
63
  const knownProperties = knownKeys.reduce((value, key) => {
@@ -82,7 +82,7 @@ function FromNot(schema, references, value) {
82
82
  }
83
83
  // prettier-ignore
84
84
  function FromObject(schema, references, value) {
85
- if (!(0, index_7.IsPlainObject)(value))
85
+ if (!(0, index_7.IsStandardObject)(value))
86
86
  return Default(schema, value);
87
87
  const knownKeys = (0, index_3.KeyOfPropertyKeys)(schema);
88
88
  const knownProperties = knownKeys.reduce((value, key) => {
@@ -104,7 +104,7 @@ function FromObject(schema, references, value) {
104
104
  }
105
105
  // prettier-ignore
106
106
  function FromRecord(schema, references, value) {
107
- if (!(0, index_7.IsPlainObject)(value))
107
+ if (!(0, index_7.IsStandardObject)(value))
108
108
  return Default(schema, value);
109
109
  const pattern = Object.getOwnPropertyNames(schema.patternProperties)[0];
110
110
  const knownKeys = new RegExp(pattern);
@@ -58,7 +58,7 @@ function FromArray(schema, references, value) {
58
58
  // prettier-ignore
59
59
  function FromIntersect(schema, references, value) {
60
60
  const defaulted = Default(schema, value);
61
- if (!(0, index_7.IsPlainObject)(value) || (0, index_7.IsValueType)(value))
61
+ if (!(0, index_7.IsStandardObject)(value) || (0, index_7.IsValueType)(value))
62
62
  return defaulted;
63
63
  const knownKeys = (0, index_3.KeyOfPropertyKeys)(schema);
64
64
  const knownProperties = knownKeys.reduce((value, key) => {
@@ -84,7 +84,7 @@ function FromNot(schema, references, value) {
84
84
  // prettier-ignore
85
85
  function FromObject(schema, references, value) {
86
86
  const defaulted = Default(schema, value);
87
- if (!(0, index_7.IsPlainObject)(value))
87
+ if (!(0, index_7.IsStandardObject)(value))
88
88
  return defaulted;
89
89
  const knownKeys = (0, index_3.KeyOfPropertyKeys)(schema);
90
90
  const knownProperties = knownKeys.reduce((value, key) => {
@@ -106,7 +106,7 @@ function FromObject(schema, references, value) {
106
106
  // prettier-ignore
107
107
  function FromRecord(schema, references, value) {
108
108
  const defaulted = Default(schema, value);
109
- if (!(0, index_7.IsPlainObject)(value))
109
+ if (!(0, index_7.IsStandardObject)(value))
110
110
  return defaulted;
111
111
  const pattern = Object.getOwnPropertyNames(schema.patternProperties)[0];
112
112
  const knownKeys = new RegExp(pattern);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinclair/typebox",
3
- "version": "0.32.14",
3
+ "version": "0.32.15",
4
4
  "description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
5
5
  "keywords": [
6
6
  "typescript",