is-kit 1.11.1 → 1.11.2
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.
- package/dist/index.d.mts +29 -14
- package/dist/index.d.ts +29 -14
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -63,6 +63,34 @@ type InferSchema<S extends SchemaShape<S>> = Simplify<{
|
|
|
63
63
|
} & {
|
|
64
64
|
readonly [K in OptionalSchemaKeys<S>]?: InferSchemaField<S[K]>;
|
|
65
65
|
}>;
|
|
66
|
+
/**
|
|
67
|
+
* Extracts optional keys from an object type.
|
|
68
|
+
*/
|
|
69
|
+
type OptionalObjectKeys<T> = {
|
|
70
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? K : never;
|
|
71
|
+
}[keyof T];
|
|
72
|
+
/**
|
|
73
|
+
* Extracts required keys from an object type.
|
|
74
|
+
*/
|
|
75
|
+
type RequiredObjectKeys<T> = Exclude<keyof T, OptionalObjectKeys<T>>;
|
|
76
|
+
/**
|
|
77
|
+
* Schema shape checked against an existing object type by `typedStruct`.
|
|
78
|
+
*/
|
|
79
|
+
type TypedStructShape<T extends object> = {
|
|
80
|
+
readonly [K in Extract<RequiredObjectKeys<T>, string>]-?: Predicate<T[K]>;
|
|
81
|
+
} & {
|
|
82
|
+
readonly [K in Extract<OptionalObjectKeys<T>, string>]-?: OptionalSchemaField<Predicate<T[K]>>;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Keeps a schema type while rejecting keys outside the expected shape.
|
|
86
|
+
*/
|
|
87
|
+
type NoExtraKeys<S, Shape> = S & {
|
|
88
|
+
readonly [K in Exclude<keyof S, keyof Shape>]: never;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Field set accepted by `typedStruct` for a target object type.
|
|
92
|
+
*/
|
|
93
|
+
type TypedStructFields<T extends object, S extends TypedStructShape<T>> = NoExtraKeys<S, TypedStructShape<T>>;
|
|
66
94
|
|
|
67
95
|
/**
|
|
68
96
|
* Asserts that a value satisfies a guard or refinement, otherwise throws.
|
|
@@ -662,19 +690,6 @@ declare function struct<const S extends SchemaShape<S>>(schema: S, options?: {
|
|
|
662
690
|
exact?: boolean;
|
|
663
691
|
}): Predicate<InferSchema<S>>;
|
|
664
692
|
|
|
665
|
-
type OptionalKeys<T> = {
|
|
666
|
-
[K in keyof T]-?: {} extends Pick<T, K> ? K : never;
|
|
667
|
-
}[keyof T];
|
|
668
|
-
type RequiredKeys<T> = Exclude<keyof T, OptionalKeys<T>>;
|
|
669
|
-
type TypedStructShape<T extends object> = {
|
|
670
|
-
readonly [K in Extract<RequiredKeys<T>, string>]-?: Predicate<T[K]>;
|
|
671
|
-
} & {
|
|
672
|
-
readonly [K in Extract<OptionalKeys<T>, string>]-?: OptionalSchemaField<Predicate<T[K]>>;
|
|
673
|
-
};
|
|
674
|
-
type NoExtraKeys<S, Shape> = S & {
|
|
675
|
-
readonly [K in Exclude<keyof S, keyof Shape>]: never;
|
|
676
|
-
};
|
|
677
|
-
type TypedStructFields<T extends object, S extends TypedStructShape<T>> = NoExtraKeys<S, TypedStructShape<T>>;
|
|
678
693
|
/**
|
|
679
694
|
* Creates a `struct` builder checked against an existing object type.
|
|
680
695
|
* Optional target keys must also be declared with `optionalKey` so type drift
|
|
@@ -748,4 +763,4 @@ declare const everyOwnEnumerableEntry: (values: Record<string, unknown>, keyPred
|
|
|
748
763
|
*/
|
|
749
764
|
declare const toBooleanPredicates: <A>(predicates: readonly ((value: A) => boolean)[]) => ReadonlyArray<(value: A) => boolean>;
|
|
750
765
|
|
|
751
|
-
export { type ChainResult, type Guard, type GuardedOf, type GuardedWithin, type InferSchema, type OptionalSchemaField, type OutOfGuards, type ParseResult, type Predicate, type Primitive, type Refine, type RefineChain, type Refinement, type Schema, type SchemaField, and, andAll, arrayOf, assert, define, equals, equalsBy, equalsKey, everyArrayValue, everyMapEntry, everyOwnEnumerableEntry, everySetValue, everyTupleValue, guardIn, hasKey, hasKeys, isArray, isArrayBuffer, isAsyncIterable, isBigInt, isBlob, isBoolean, isDataView, isDate, isError, isFile, isFiniteNumber, isFunction, isInfiniteNumber, isInstanceOf, isInteger, isIterable, isMap, isNaN, isNegative, isNil, isNull, isNumber, isNumberPrimitive, isObject, isPlainObject, isPositive, isPrimitive, isPromiseLike, isRegExp, isSafeInteger, isSet, isString, isSymbol, isTypedArray, isURL, isUndefined, isWeakMap, isWeakSet, isZero, lazy, mapOf, narrowKeyTo, nonEmptyArrayOf, nonNull, not, nullable, nullish, oneOf, oneOfValues, optional, optionalKey, or, predicateToRefine, recordOf, required, safeJsonParse, safeParse, safeParseWith, setOf, struct, toBooleanPredicates, tupleOf, typedStruct };
|
|
766
|
+
export { type ChainResult, type Guard, type GuardedOf, type GuardedWithin, type InferSchema, type NoExtraKeys, type OptionalObjectKeys, type OptionalSchemaField, type OutOfGuards, type ParseResult, type Predicate, type Primitive, type Refine, type RefineChain, type Refinement, type RequiredObjectKeys, type Schema, type SchemaField, type TypedStructFields, type TypedStructShape, and, andAll, arrayOf, assert, define, equals, equalsBy, equalsKey, everyArrayValue, everyMapEntry, everyOwnEnumerableEntry, everySetValue, everyTupleValue, guardIn, hasKey, hasKeys, isArray, isArrayBuffer, isAsyncIterable, isBigInt, isBlob, isBoolean, isDataView, isDate, isError, isFile, isFiniteNumber, isFunction, isInfiniteNumber, isInstanceOf, isInteger, isIterable, isMap, isNaN, isNegative, isNil, isNull, isNumber, isNumberPrimitive, isObject, isPlainObject, isPositive, isPrimitive, isPromiseLike, isRegExp, isSafeInteger, isSet, isString, isSymbol, isTypedArray, isURL, isUndefined, isWeakMap, isWeakSet, isZero, lazy, mapOf, narrowKeyTo, nonEmptyArrayOf, nonNull, not, nullable, nullish, oneOf, oneOfValues, optional, optionalKey, or, predicateToRefine, recordOf, required, safeJsonParse, safeParse, safeParseWith, setOf, struct, toBooleanPredicates, tupleOf, typedStruct };
|
package/dist/index.d.ts
CHANGED
|
@@ -63,6 +63,34 @@ type InferSchema<S extends SchemaShape<S>> = Simplify<{
|
|
|
63
63
|
} & {
|
|
64
64
|
readonly [K in OptionalSchemaKeys<S>]?: InferSchemaField<S[K]>;
|
|
65
65
|
}>;
|
|
66
|
+
/**
|
|
67
|
+
* Extracts optional keys from an object type.
|
|
68
|
+
*/
|
|
69
|
+
type OptionalObjectKeys<T> = {
|
|
70
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? K : never;
|
|
71
|
+
}[keyof T];
|
|
72
|
+
/**
|
|
73
|
+
* Extracts required keys from an object type.
|
|
74
|
+
*/
|
|
75
|
+
type RequiredObjectKeys<T> = Exclude<keyof T, OptionalObjectKeys<T>>;
|
|
76
|
+
/**
|
|
77
|
+
* Schema shape checked against an existing object type by `typedStruct`.
|
|
78
|
+
*/
|
|
79
|
+
type TypedStructShape<T extends object> = {
|
|
80
|
+
readonly [K in Extract<RequiredObjectKeys<T>, string>]-?: Predicate<T[K]>;
|
|
81
|
+
} & {
|
|
82
|
+
readonly [K in Extract<OptionalObjectKeys<T>, string>]-?: OptionalSchemaField<Predicate<T[K]>>;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Keeps a schema type while rejecting keys outside the expected shape.
|
|
86
|
+
*/
|
|
87
|
+
type NoExtraKeys<S, Shape> = S & {
|
|
88
|
+
readonly [K in Exclude<keyof S, keyof Shape>]: never;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Field set accepted by `typedStruct` for a target object type.
|
|
92
|
+
*/
|
|
93
|
+
type TypedStructFields<T extends object, S extends TypedStructShape<T>> = NoExtraKeys<S, TypedStructShape<T>>;
|
|
66
94
|
|
|
67
95
|
/**
|
|
68
96
|
* Asserts that a value satisfies a guard or refinement, otherwise throws.
|
|
@@ -662,19 +690,6 @@ declare function struct<const S extends SchemaShape<S>>(schema: S, options?: {
|
|
|
662
690
|
exact?: boolean;
|
|
663
691
|
}): Predicate<InferSchema<S>>;
|
|
664
692
|
|
|
665
|
-
type OptionalKeys<T> = {
|
|
666
|
-
[K in keyof T]-?: {} extends Pick<T, K> ? K : never;
|
|
667
|
-
}[keyof T];
|
|
668
|
-
type RequiredKeys<T> = Exclude<keyof T, OptionalKeys<T>>;
|
|
669
|
-
type TypedStructShape<T extends object> = {
|
|
670
|
-
readonly [K in Extract<RequiredKeys<T>, string>]-?: Predicate<T[K]>;
|
|
671
|
-
} & {
|
|
672
|
-
readonly [K in Extract<OptionalKeys<T>, string>]-?: OptionalSchemaField<Predicate<T[K]>>;
|
|
673
|
-
};
|
|
674
|
-
type NoExtraKeys<S, Shape> = S & {
|
|
675
|
-
readonly [K in Exclude<keyof S, keyof Shape>]: never;
|
|
676
|
-
};
|
|
677
|
-
type TypedStructFields<T extends object, S extends TypedStructShape<T>> = NoExtraKeys<S, TypedStructShape<T>>;
|
|
678
693
|
/**
|
|
679
694
|
* Creates a `struct` builder checked against an existing object type.
|
|
680
695
|
* Optional target keys must also be declared with `optionalKey` so type drift
|
|
@@ -748,4 +763,4 @@ declare const everyOwnEnumerableEntry: (values: Record<string, unknown>, keyPred
|
|
|
748
763
|
*/
|
|
749
764
|
declare const toBooleanPredicates: <A>(predicates: readonly ((value: A) => boolean)[]) => ReadonlyArray<(value: A) => boolean>;
|
|
750
765
|
|
|
751
|
-
export { type ChainResult, type Guard, type GuardedOf, type GuardedWithin, type InferSchema, type OptionalSchemaField, type OutOfGuards, type ParseResult, type Predicate, type Primitive, type Refine, type RefineChain, type Refinement, type Schema, type SchemaField, and, andAll, arrayOf, assert, define, equals, equalsBy, equalsKey, everyArrayValue, everyMapEntry, everyOwnEnumerableEntry, everySetValue, everyTupleValue, guardIn, hasKey, hasKeys, isArray, isArrayBuffer, isAsyncIterable, isBigInt, isBlob, isBoolean, isDataView, isDate, isError, isFile, isFiniteNumber, isFunction, isInfiniteNumber, isInstanceOf, isInteger, isIterable, isMap, isNaN, isNegative, isNil, isNull, isNumber, isNumberPrimitive, isObject, isPlainObject, isPositive, isPrimitive, isPromiseLike, isRegExp, isSafeInteger, isSet, isString, isSymbol, isTypedArray, isURL, isUndefined, isWeakMap, isWeakSet, isZero, lazy, mapOf, narrowKeyTo, nonEmptyArrayOf, nonNull, not, nullable, nullish, oneOf, oneOfValues, optional, optionalKey, or, predicateToRefine, recordOf, required, safeJsonParse, safeParse, safeParseWith, setOf, struct, toBooleanPredicates, tupleOf, typedStruct };
|
|
766
|
+
export { type ChainResult, type Guard, type GuardedOf, type GuardedWithin, type InferSchema, type NoExtraKeys, type OptionalObjectKeys, type OptionalSchemaField, type OutOfGuards, type ParseResult, type Predicate, type Primitive, type Refine, type RefineChain, type Refinement, type RequiredObjectKeys, type Schema, type SchemaField, type TypedStructFields, type TypedStructShape, and, andAll, arrayOf, assert, define, equals, equalsBy, equalsKey, everyArrayValue, everyMapEntry, everyOwnEnumerableEntry, everySetValue, everyTupleValue, guardIn, hasKey, hasKeys, isArray, isArrayBuffer, isAsyncIterable, isBigInt, isBlob, isBoolean, isDataView, isDate, isError, isFile, isFiniteNumber, isFunction, isInfiniteNumber, isInstanceOf, isInteger, isIterable, isMap, isNaN, isNegative, isNil, isNull, isNumber, isNumberPrimitive, isObject, isPlainObject, isPositive, isPrimitive, isPromiseLike, isRegExp, isSafeInteger, isSet, isString, isSymbol, isTypedArray, isURL, isUndefined, isWeakMap, isWeakSet, isZero, lazy, mapOf, narrowKeyTo, nonEmptyArrayOf, nonNull, not, nullable, nullish, oneOf, oneOfValues, optional, optionalKey, or, predicateToRefine, recordOf, required, safeJsonParse, safeParse, safeParseWith, setOf, struct, toBooleanPredicates, tupleOf, typedStruct };
|