@webdeveric/utils 0.57.0 → 0.58.0
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/types/predicate/factory/shape.d.ts +7 -6
- package/dist/types/predicate/isPromiseFulfilledResult.d.ts +1 -1
- package/dist/types/predicate/isPromiseLike.d.ts +1 -1
- package/dist/types/predicate/isPromiseRejectedResult.d.ts +1 -1
- package/dist/types/types/branded.d.ts +1 -2
- package/package.json +1 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
import type { Branded } from '../../types/branded.js';
|
|
1
2
|
import type { Primitive } from '../../types/common.js';
|
|
2
3
|
import type { InferPredicateReturnType, TypePredicateFn } from '../../types/functions.js';
|
|
3
4
|
import type { Pretty } from '../../types/utils.js';
|
|
4
5
|
export type WithRegExp<Type> = Type extends string ? Type | RegExp : Type;
|
|
5
|
-
export type ObjectShapeValue<Type> = Type extends object ? Type extends Function ? TypePredicateFn<Function> : ObjectShapeRecord<Type> : WithRegExp<Extract<Type, Primitive>>;
|
|
6
|
-
export type ObjectShapeRecord<Type extends object
|
|
6
|
+
export type ObjectShapeValue<Type> = Type extends Branded<unknown, unknown> ? TypePredicateFn<Type> : Type extends object ? Type extends Function ? TypePredicateFn<Function> : ObjectShapeRecord<Type> : WithRegExp<Extract<Type, Primitive>>;
|
|
7
|
+
export type ObjectShapeRecord<Type extends object> = {
|
|
7
8
|
[Property in keyof Type]: ObjectShapeValue<Type[Property]> | TypePredicateFn<Type[Property]>;
|
|
8
9
|
};
|
|
9
10
|
export type InferTypeFromShapeValue<Type> = Type extends RegExp ? string : Type extends Primitive ? Type : Type extends TypePredicateFn<unknown> ? InferPredicateReturnType<Type> : Type extends ObjectShapeRecord<object> ? InferTypeFromShape<Type> : never;
|
|
10
|
-
export type InferTypeFromShape<Shape extends ObjectShapeRecord<object>> =
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
export declare const shape: <Type extends object, const Shape extends ObjectShapeRecord<Type> = ObjectShapeRecord<Type>>(objectShape: Shape) => TypePredicateFn<InferTypeFromShape<Shape
|
|
11
|
+
export type InferTypeFromShape<Shape extends ObjectShapeRecord<object>> = {
|
|
12
|
+
[Property in keyof Shape]: InferTypeFromShapeValue<Shape[Property]>;
|
|
13
|
+
};
|
|
14
|
+
export declare const shape: <Type extends object, const Shape extends ObjectShapeRecord<Type> = ObjectShapeRecord<Type>>(objectShape: Shape) => TypePredicateFn<Pretty<Type & InferTypeFromShape<Shape>>>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare const isPromiseLike: import("../index.js").TypePredicateFn<{
|
|
2
|
-
then:
|
|
2
|
+
then: (<TResult1 = unknown, TResult2 = never>(onfulfilled?: ((value: unknown) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined) => PromiseLike<TResult1 | TResult2>) | ((<TResult1 = unknown, TResult2 = never>(onfulfilled?: ((value: unknown) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined) => PromiseLike<TResult1 | TResult2>) & Function);
|
|
3
3
|
}>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Primitive } from './common.js';
|
|
2
|
-
declare const brand: unique symbol;
|
|
2
|
+
export declare const brand: unique symbol;
|
|
3
3
|
export type Brand<Id> = {
|
|
4
4
|
[brand]: Id;
|
|
5
5
|
};
|
|
@@ -8,4 +8,3 @@ export type Unbranded<Type> = Type extends Branded<infer Inner, unknown> ? Omit<
|
|
|
8
8
|
export type RemoveBranding<Type> = Type extends Primitive ? Unbranded<Type> : {
|
|
9
9
|
[Property in keyof Type]: Type extends Primitive ? Unbranded<Type[Property]> : RemoveBranding<Type[Property]>;
|
|
10
10
|
};
|
|
11
|
-
export {};
|