@augment-vir/assert 30.0.0 → 30.0.1
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/README.md +11 -0
- package/dist/assertions/boolean.d.ts +443 -17
- package/dist/assertions/boolean.js +365 -8
- package/dist/assertions/boundary.d.ts +657 -13
- package/dist/assertions/boundary.js +537 -5
- package/dist/assertions/enum.d.ts +236 -8
- package/dist/assertions/enum.js +197 -5
- package/dist/assertions/equality/entry-equality.d.ts +287 -11
- package/dist/assertions/equality/entry-equality.js +243 -6
- package/dist/assertions/equality/json-equality.d.ts +244 -15
- package/dist/assertions/equality/json-equality.js +207 -11
- package/dist/assertions/equality/simple-equality.d.ts +849 -28
- package/dist/assertions/equality/simple-equality.js +712 -6
- package/dist/assertions/equality/ts-type-equality.d.ts +37 -1
- package/dist/assertions/equality/ts-type-equality.js +13 -1
- package/dist/assertions/extendable-assertions.d.ts +288 -120
- package/dist/assertions/extendable-assertions.js +32 -60
- package/dist/assertions/http.d.ts +217 -10
- package/dist/assertions/http.js +182 -6
- package/dist/assertions/instance.d.ts +189 -8
- package/dist/assertions/instance.js +159 -5
- package/dist/assertions/keys.d.ts +658 -13
- package/dist/assertions/keys.js +556 -5
- package/dist/assertions/length.d.ts +381 -9
- package/dist/assertions/length.js +309 -5
- package/dist/assertions/nullish.d.ts +169 -7
- package/dist/assertions/nullish.js +137 -6
- package/dist/assertions/numeric.d.ts +965 -11
- package/dist/assertions/numeric.js +819 -1
- package/dist/assertions/output.d.ts +107 -7
- package/dist/assertions/output.js +92 -5
- package/dist/assertions/primitive.d.ts +416 -13
- package/dist/assertions/primitive.js +352 -6
- package/dist/assertions/promise.d.ts +640 -21
- package/dist/assertions/promise.js +536 -15
- package/dist/assertions/regexp.d.ts +202 -3
- package/dist/assertions/regexp.js +173 -1
- package/dist/assertions/runtime-type.d.ts +1822 -41
- package/dist/assertions/runtime-type.js +1558 -35
- package/dist/assertions/throws.d.ts +265 -17
- package/dist/assertions/throws.js +229 -17
- package/dist/assertions/uuid.d.ts +233 -10
- package/dist/assertions/uuid.js +195 -6
- package/dist/assertions/values.d.ts +1086 -15
- package/dist/assertions/values.js +907 -6
- package/dist/augments/assertion.error.d.ts +2 -1
- package/dist/augments/assertion.error.js +2 -1
- package/dist/augments/guards/assert-wrap.d.ts +82 -37
- package/dist/augments/guards/assert-wrap.js +13 -2
- package/dist/augments/guards/assert.d.ts +30 -14
- package/dist/augments/guards/assert.js +21 -4
- package/dist/augments/guards/check-wrap.d.ts +94 -51
- package/dist/augments/guards/check-wrap.js +11 -3
- package/dist/augments/guards/check.d.ts +87 -37
- package/dist/augments/guards/check.js +9 -2
- package/dist/augments/guards/wait-until.d.ts +110 -103
- package/dist/augments/guards/wait-until.js +18 -3
- package/dist/augments/if-equals.d.ts +4 -2
- package/dist/guard-types/assert-wrap-function.d.ts +5 -2
- package/dist/guard-types/check-function.d.ts +5 -2
- package/dist/guard-types/check-wrap-wrapper-function.d.ts +4 -1
- package/dist/guard-types/guard-group.d.ts +7 -8
- package/dist/guard-types/wait-until-function.d.ts +8 -3
- package/dist/guard-types/wait-until-function.js +1 -1
- package/package.json +17 -4
|
@@ -1,38 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* 1. Run the method's assertion on the given inputs.
|
|
5
|
-
* 2. If the assertion fails, return `undefined`.
|
|
6
|
-
* 3. If the assertion succeeds, the first input is returned and (when possible) type guarded.
|
|
7
|
-
*
|
|
8
|
-
* This is a combination of {@link assertWrap} and {@link check}.
|
|
9
|
-
*
|
|
10
|
-
* @category Assert
|
|
11
|
-
* @example
|
|
12
|
-
*
|
|
13
|
-
* ```ts
|
|
14
|
-
* import {checkWrap} from '@augment-vir/assert';
|
|
15
|
-
*
|
|
16
|
-
* // `result1` will be `['a']`
|
|
17
|
-
* const result1 = checkWrap.deepEquals(['a'], ['a']);
|
|
18
|
-
*
|
|
19
|
-
* const value: unknown = 'some value' as unknown;
|
|
20
|
-
* // `result2` will be `'some value'` and it will have the type of `string`
|
|
21
|
-
* const result2 = checkWrap.isString(value);
|
|
22
|
-
*
|
|
23
|
-
* const value2: unknown = 'some value' as unknown;
|
|
24
|
-
* // `result` will be `undefined`
|
|
25
|
-
* const result3 = checkWrap.isNumber(value2);
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* @returns The original given value (type guarded when possible) or, if the expectation fails,
|
|
29
|
-
* `undefined`.
|
|
30
|
-
* @package @augment-vir/assert
|
|
31
|
-
*/
|
|
32
|
-
export declare const checkWrap: import("../../guard-types/check-wrap-wrapper-function.js").CheckWrapGroup<{
|
|
1
|
+
import { AnyFunction } from '@augment-vir/core';
|
|
2
|
+
declare const checkWrapGroup: import("../../guard-types/check-wrap-wrapper-function.js").CheckWrapGroup<{
|
|
33
3
|
output: {
|
|
34
|
-
<const FunctionToCall extends
|
|
35
|
-
<const FunctionToCall extends
|
|
4
|
+
<const FunctionToCall extends AnyFunction>(functionToCall: FunctionToCall, inputs: Parameters<NoInfer<FunctionToCall>>, expectedOutput: Awaited<ReturnType<NoInfer<FunctionToCall>>>, failureMessage?: string | undefined): Promise<any> extends ReturnType<NoInfer<FunctionToCall>> ? import("type-fest").IsAny<ReturnType<NoInfer<FunctionToCall>>> extends true ? void : Promise<void> : void;
|
|
5
|
+
<const FunctionToCall extends AnyFunction>(asserter: import("../assertion-exports.js").CustomOutputAsserter<NoInfer<FunctionToCall>>, functionToCall: FunctionToCall, inputs: Parameters<NoInfer<FunctionToCall>>, expectedOutput: Awaited<ReturnType<NoInfer<FunctionToCall>>>, failureMessage?: string | undefined): Promise<any> extends ReturnType<NoInfer<FunctionToCall>> ? import("type-fest").IsAny<ReturnType<NoInfer<FunctionToCall>>> extends true ? void : Promise<void> : void;
|
|
36
6
|
};
|
|
37
7
|
isHttpStatus: (actual: unknown, failureMessage?: string | undefined) => asserts actual is import("@augment-vir/core").HttpStatus;
|
|
38
8
|
isHttpStatusCategory: <const Actual, const Category extends import("@augment-vir/core").HttpStatusCategory>(actual: Actual, category: Category, failureMessage?: string | undefined) => asserts actual is import("@augment-vir/core").NarrowToExpected<Actual, import("@augment-vir/core").HttpStatusByCategory<Category>>;
|
|
@@ -46,13 +16,13 @@ export declare const checkWrap: import("../../guard-types/check-wrap-wrapper-fun
|
|
|
46
16
|
isNotEmpty: <const Actual extends import("../assertion-exports.js").CanBeEmpty>(actual: Actual, failureMessage?: string | undefined) => asserts actual is Exclude<Actual, import("../assertion-exports.js").Empty>;
|
|
47
17
|
isUuid: (actual: unknown, failureMessage?: string | undefined) => asserts actual is import("@augment-vir/core").Uuid;
|
|
48
18
|
isNotUuid: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is Exclude<Actual, import("@augment-vir/core").Uuid>;
|
|
49
|
-
isError: (actual: unknown, matchOptions?: import("../assertion-exports.js").ErrorMatchOptions | undefined, failureMessage?: string | undefined) => asserts actual is Error;
|
|
50
19
|
throws: {
|
|
51
20
|
(callbackOrPromise: import("@augment-vir/core").TypedFunction<void, never>, matchOptions?: import("../assertion-exports.js").ErrorMatchOptions | undefined, failureMessage?: string | undefined): void;
|
|
52
21
|
(callbackOrPromise: import("@augment-vir/core").TypedFunction<void, Promise<any>> | Promise<any>, matchOptions?: import("../assertion-exports.js").ErrorMatchOptions | undefined, failureMessage?: string | undefined): Promise<void>;
|
|
53
22
|
(callback: import("@augment-vir/core").TypedFunction<void, any>, matchOptions?: import("../assertion-exports.js").ErrorMatchOptions | undefined, failureMessage?: string | undefined): void;
|
|
54
23
|
(callback: import("@augment-vir/core").TypedFunction<void, import("@augment-vir/core").MaybePromise<any>> | Promise<any>, matchOptions?: import("../assertion-exports.js").ErrorMatchOptions | undefined, failureMessage?: string | undefined): import("@augment-vir/core").MaybePromise<void>;
|
|
55
24
|
};
|
|
25
|
+
isError: (actual: unknown, matchOptions?: import("../assertion-exports.js").ErrorMatchOptions | undefined, failureMessage?: string | undefined) => asserts actual is Error;
|
|
56
26
|
strictEquals: typeof import("../../assertions/equality/simple-equality.js").strictEquals;
|
|
57
27
|
notStrictEquals: (actual: unknown, expected: unknown, failureMessage?: string | undefined) => void;
|
|
58
28
|
looseEquals: (actual: unknown, expected: unknown, failureMessage?: string | undefined) => void;
|
|
@@ -62,7 +32,7 @@ export declare const checkWrap: import("../../guard-types/check-wrap-wrapper-fun
|
|
|
62
32
|
isArray: (actual: unknown, failureMessage?: string | undefined) => asserts actual is unknown[];
|
|
63
33
|
isBigInt: (actual: unknown, failureMessage?: string | undefined) => asserts actual is bigint;
|
|
64
34
|
isBoolean: (actual: unknown, failureMessage?: string | undefined) => asserts actual is boolean;
|
|
65
|
-
isFunction: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is import("@augment-vir/core").NarrowToActual<Actual,
|
|
35
|
+
isFunction: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is import("@augment-vir/core").NarrowToActual<Actual, AnyFunction>;
|
|
66
36
|
isNull: (actual: unknown, failureMessage?: string | undefined) => asserts actual is null;
|
|
67
37
|
isNumber: (actual: unknown, failureMessage?: string | undefined) => asserts actual is number;
|
|
68
38
|
isObject: (actual: unknown, failureMessage?: string | undefined) => asserts actual is import("@augment-vir/core").UnknownObject;
|
|
@@ -72,13 +42,13 @@ export declare const checkWrap: import("../../guard-types/check-wrap-wrapper-fun
|
|
|
72
42
|
isNotArray: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is Exclude<Actual, ReadonlyArray<unknown>>;
|
|
73
43
|
isNotBigInt: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is Exclude<Actual, bigint>;
|
|
74
44
|
isNotBoolean: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is Exclude<Actual, boolean>;
|
|
75
|
-
isNotFunction: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is Exclude<Actual,
|
|
45
|
+
isNotFunction: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is Exclude<Actual, AnyFunction>;
|
|
46
|
+
isNotNull: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is Exclude<Actual, null>;
|
|
76
47
|
isNotNumber: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is Exclude<Actual, number>;
|
|
77
48
|
isNotObject: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is Exclude<Actual, import("@augment-vir/core").UnknownObject>;
|
|
78
49
|
isNotString: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is Exclude<Actual, string>;
|
|
79
50
|
isNotSymbol: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is Exclude<Actual, symbol>;
|
|
80
51
|
isNotUndefined: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is Exclude<Actual, undefined>;
|
|
81
|
-
isNotNull: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is Exclude<Actual, null>;
|
|
82
52
|
matches: (actual: string, expected: RegExp, failureMessage?: string | undefined) => void;
|
|
83
53
|
mismatches: (actual: string, expected: RegExp, failureMessage?: string | undefined) => void;
|
|
84
54
|
isPromiseLike: (actual: unknown, failureMessage?: string | undefined) => asserts actual is PromiseLike<any>;
|
|
@@ -110,9 +80,9 @@ export declare const checkWrap: import("../../guard-types/check-wrap-wrapper-fun
|
|
|
110
80
|
};
|
|
111
81
|
isKeyOf: <const Parent>(key: PropertyKey, parent: Parent, failureMessage?: string | undefined) => asserts key is keyof Parent;
|
|
112
82
|
isNotKeyOf: <const Key extends PropertyKey, const Parent>(key: Key, parent: Parent, failureMessage?: string | undefined) => asserts key is Exclude<Key, import("@augment-vir/core").RequiredKeysOf<Parent>>;
|
|
113
|
-
hasKey: <const Key extends PropertyKey, const Parent>(parent: Parent, key: Key, failureMessage?: string | undefined) => asserts parent is Parent & Record<Key, (Key extends keyof Parent ? import("
|
|
83
|
+
hasKey: <const Key extends PropertyKey, const Parent>(parent: Parent, key: Key, failureMessage?: string | undefined) => asserts parent is Parent & Record<Key, (Key extends keyof Parent ? import("@augment-vir/core").SetRequired<Parent, Key>[Key] : Key extends keyof Extract<Parent, Record<Key, any>> ? import("@augment-vir/core").SetRequired<Extract<Parent, Record<Key, any>>, Key>[Key] : never) extends never ? unknown : Key extends keyof Parent ? import("@augment-vir/core").SetRequired<Parent, Key>[Key] : Key extends keyof Extract<Parent, Record<Key, any>> ? import("@augment-vir/core").SetRequired<Extract<Parent, Record<Key, any>>, Key>[Key] : never>;
|
|
114
84
|
lacksKey: <const Parent, const Key extends PropertyKey>(parent: Parent, key: Key, failureMessage?: string | undefined) => asserts parent is Exclude<Parent, Record<Key, any>>;
|
|
115
|
-
hasKeys: <const Keys extends PropertyKey, const Parent>(parent: Parent, keys: ReadonlyArray<Keys>, failureMessage?: string | undefined) => asserts parent is Parent & Record<Keys, (Keys extends keyof Parent ? import("
|
|
85
|
+
hasKeys: <const Keys extends PropertyKey, const Parent>(parent: Parent, keys: ReadonlyArray<Keys>, failureMessage?: string | undefined) => asserts parent is Parent & Record<Keys, (Keys extends keyof Parent ? import("@augment-vir/core").SetRequired<Parent, Keys>[Keys] : Keys extends keyof Extract<Parent, Record<Keys, any>> ? import("@augment-vir/core").SetRequired<Extract<Parent, Record<Keys, any>>, Keys>[Keys] : never) extends never ? unknown : Keys extends keyof Parent ? import("@augment-vir/core").SetRequired<Parent, Keys>[Keys] : Keys extends keyof Extract<Parent, Record<Keys, any>> ? import("@augment-vir/core").SetRequired<Extract<Parent, Record<Keys, any>>, Keys>[Keys] : never>;
|
|
116
86
|
lacksKeys: <const Parent, const Key extends PropertyKey>(parent: Parent, keys: ReadonlyArray<Key>, failureMessage?: string | undefined) => asserts parent is Exclude<Parent, Partial<Record<Key, any>>>;
|
|
117
87
|
jsonEquals: <const Actual, const Expected extends Actual>(actual: Actual, expected: Expected, failureMessage?: string | undefined) => asserts actual is Expected;
|
|
118
88
|
notJsonEquals: (actual: unknown, expected: unknown, failureMessage?: string | undefined) => void;
|
|
@@ -142,34 +112,48 @@ export declare const checkWrap: import("../../guard-types/check-wrap-wrapper-fun
|
|
|
142
112
|
(parent: string, child: string, failureMessage?: string | undefined): void;
|
|
143
113
|
(parent: string | ReadonlyArray<string>, child: string, failureMessage?: string | undefined): void;
|
|
144
114
|
};
|
|
115
|
+
isFalse: (input: unknown, failureMessage?: string | undefined) => asserts input is false;
|
|
145
116
|
isFalsy: (input: unknown, failureMessage?: string | undefined) => asserts input is import("../assertion-exports.js").FalsyValue;
|
|
146
|
-
isTruthy: <const Actual>(input: Actual, failureMessage?: string | undefined) => asserts input is import("../assertion-exports.js").Truthy<Actual>;
|
|
147
117
|
isTrue: (input: unknown, failureMessage?: string | undefined) => asserts input is true;
|
|
148
|
-
|
|
118
|
+
isTruthy: <const Actual>(input: Actual, failureMessage?: string | undefined) => asserts input is import("../assertion-exports.js").Truthy<Actual>;
|
|
149
119
|
}, {
|
|
120
|
+
isFalse: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
150
121
|
isFalsy: <T>(input: T) => import("../assertion-exports.js").Falsy<T> | undefined;
|
|
122
|
+
isTrue: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
151
123
|
isTruthy: <T>(input: T) => import("../assertion-exports.js").Truthy<T> | undefined;
|
|
152
124
|
} & {
|
|
153
125
|
strictEquals: <Actual, Expected extends Actual>(actual: Actual, expected: Expected) => Expected | undefined;
|
|
126
|
+
notStrictEquals: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
127
|
+
looseEquals: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
128
|
+
notLooseEquals: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
154
129
|
deepEquals: <Actual, Expected extends Actual>(actual: Actual, expected: Expected) => import("@augment-vir/core").NarrowToExpected<Actual, Expected> | undefined;
|
|
130
|
+
notDeepEquals: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
155
131
|
} & {
|
|
156
132
|
output: {
|
|
157
|
-
<const FunctionToCall extends
|
|
158
|
-
<const FunctionToCall extends
|
|
133
|
+
<const FunctionToCall extends AnyFunction>(functionToCall: FunctionToCall, inputs: Parameters<NoInfer<FunctionToCall>>, expectedOutput: Awaited<ReturnType<NoInfer<FunctionToCall>>>, failureMessage?: string | undefined): Promise<any> extends ReturnType<NoInfer<FunctionToCall>> ? import("type-fest").IsAny<ReturnType<FunctionToCall>> extends true ? Awaited<ReturnType<NoInfer<FunctionToCall>>> | undefined : Promise<Awaited<ReturnType<NoInfer<FunctionToCall>>> | undefined> : Awaited<ReturnType<NoInfer<FunctionToCall>>> | undefined;
|
|
134
|
+
<const FunctionToCall extends AnyFunction>(asserter: import("../assertion-exports.js").CustomOutputAsserter<NoInfer<FunctionToCall>>, functionToCall: FunctionToCall, inputs: Parameters<NoInfer<FunctionToCall>>, expectedOutput: Awaited<ReturnType<NoInfer<FunctionToCall>>>, failureMessage?: string | undefined): Promise<any> extends ReturnType<NoInfer<FunctionToCall>> ? import("type-fest").IsAny<ReturnType<FunctionToCall>> extends true ? Awaited<ReturnType<NoInfer<FunctionToCall>>> | undefined : Promise<Awaited<ReturnType<NoInfer<FunctionToCall>>> | undefined> : Awaited<ReturnType<NoInfer<FunctionToCall>>> | undefined;
|
|
159
135
|
};
|
|
160
136
|
} & {
|
|
161
|
-
|
|
137
|
+
isArray: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
138
|
+
isBigInt: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
139
|
+
isBoolean: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
140
|
+
isFunction: <const Actual>(actual: Actual) => import("@augment-vir/core").NarrowToActual<Actual, AnyFunction> | undefined;
|
|
141
|
+
isNull: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
142
|
+
isNumber: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
143
|
+
isObject: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
144
|
+
isString: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
145
|
+
isSymbol: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
162
146
|
isUndefined: undefined;
|
|
163
|
-
isNotUndefined: undefined;
|
|
164
147
|
isNotArray: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, ReadonlyArray<unknown>> | undefined;
|
|
165
148
|
isNotBigInt: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, bigint> | undefined;
|
|
166
149
|
isNotBoolean: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, boolean> | undefined;
|
|
167
|
-
isNotFunction: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual,
|
|
150
|
+
isNotFunction: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, AnyFunction> | undefined;
|
|
168
151
|
isNotNull: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, null> | undefined;
|
|
169
152
|
isNotNumber: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, number> | undefined;
|
|
170
153
|
isNotObject: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, import("@augment-vir/core").UnknownObject> | undefined;
|
|
171
154
|
isNotString: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, string> | undefined;
|
|
172
155
|
isNotSymbol: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, symbol> | undefined;
|
|
156
|
+
isNotUndefined: undefined;
|
|
173
157
|
} & {
|
|
174
158
|
throws: {
|
|
175
159
|
(callbackOrPromise: import("@augment-vir/core").TypedFunction<void, never>, matchOptions?: import("../assertion-exports.js").ErrorMatchOptions | undefined, failureMessage?: string | undefined): Error | undefined;
|
|
@@ -177,7 +161,12 @@ export declare const checkWrap: import("../../guard-types/check-wrap-wrapper-fun
|
|
|
177
161
|
(callback: import("@augment-vir/core").TypedFunction<void, any>, matchOptions?: import("../assertion-exports.js").ErrorMatchOptions | undefined, failureMessage?: string | undefined): Error | undefined;
|
|
178
162
|
(callback: import("@augment-vir/core").TypedFunction<void, import("@augment-vir/core").MaybePromise<any>> | Promise<any>, matchOptions?: import("../assertion-exports.js").ErrorMatchOptions | undefined, failureMessage?: string | undefined): import("@augment-vir/core").MaybePromise<Error | undefined>;
|
|
179
163
|
};
|
|
164
|
+
isError: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
180
165
|
} & {
|
|
166
|
+
hasValue: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
167
|
+
lacksValue: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
168
|
+
hasValues: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
169
|
+
lacksValues: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
181
170
|
isIn: <const Child, const Parent>(child: Child, parent: Parent) => import("@augment-vir/core").NarrowToExpected<Child, import("@augment-vir/core").Values<Parent>> | undefined;
|
|
182
171
|
isNotIn: <const Parent, const Child>(child: Child, parent: Parent, failureMessage?: string | undefined) => Exclude<Child, import("@augment-vir/core").Values<Parent>> | undefined;
|
|
183
172
|
isEmpty: <const Actual extends import("../assertion-exports.js").CanBeEmpty>(actual: Actual) => import("@augment-vir/core").NarrowToActual<Actual, import("../assertion-exports.js").Empty> | undefined;
|
|
@@ -208,9 +197,12 @@ export declare const checkWrap: import("../../guard-types/check-wrap-wrapper-fun
|
|
|
208
197
|
isNotEnumValue: <const Actual, const Expected extends import("@augment-vir/core").EnumBaseType>(child: Actual, checkEnum: Expected) => Exclude<Actual, Expected[keyof Expected] | `${Expected[keyof Expected]}`> | undefined;
|
|
209
198
|
} & {
|
|
210
199
|
entriesEqual: <Actual, Expected extends Actual>(actual: Actual, expected: Expected) => import("@augment-vir/core").NarrowToExpected<Actual, Expected> | undefined;
|
|
200
|
+
notEntriesEqual: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
211
201
|
} & {
|
|
212
202
|
jsonEquals: <Actual, Expected extends Actual>(actual: Actual, expected: Expected) => import("@augment-vir/core").NarrowToExpected<Actual, Expected> | undefined;
|
|
203
|
+
notJsonEquals: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
213
204
|
} & {
|
|
205
|
+
isHttpStatus: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
214
206
|
isHttpStatusCategory: <const Actual, const Category extends import("@augment-vir/core").HttpStatusCategory>(actual: Actual, category: Category, failureMessage?: string | undefined) => import("@augment-vir/core").NarrowToExpected<Actual, import("@augment-vir/core").HttpStatusByCategory<Category>> | undefined;
|
|
215
207
|
} & {
|
|
216
208
|
instanceOf: <const Instance>(instance: unknown, constructor: import("type-fest").Constructor<Instance>) => Instance | undefined;
|
|
@@ -218,9 +210,9 @@ export declare const checkWrap: import("../../guard-types/check-wrap-wrapper-fun
|
|
|
218
210
|
} & {
|
|
219
211
|
isKeyOf: <const Key extends PropertyKey, const Parent>(key: Key, parent: Parent) => import("@augment-vir/core").NarrowToExpected<Key, keyof Parent> | undefined;
|
|
220
212
|
isNotKeyOf: <const Key extends PropertyKey, const Parent>(key: Key, parent: Parent, failureMessage?: string | undefined) => Exclude<Key, import("@augment-vir/core").RequiredKeysOf<Parent>> | undefined;
|
|
221
|
-
hasKey: <const Parent, const Key extends PropertyKey>(parent: Parent, key: Key) => (Parent & Record<Key, (Key extends keyof Parent ? import("
|
|
213
|
+
hasKey: <const Parent, const Key extends PropertyKey>(parent: Parent, key: Key) => (Parent & Record<Key, (Key extends keyof Parent ? import("@augment-vir/core").SetRequired<Parent, Key>[Key] : Key extends keyof Extract<Parent, Record<Key, any>> ? import("@augment-vir/core").SetRequired<Extract<Parent, Record<Key, any>>, Key>[Key] : never) extends never ? unknown : Key extends keyof Parent ? import("@augment-vir/core").SetRequired<Parent, Key>[Key] : Key extends keyof Extract<Parent, Record<Key, any>> ? import("@augment-vir/core").SetRequired<Extract<Parent, Record<Key, any>>, Key>[Key] : never>) | undefined;
|
|
222
214
|
lacksKey: <const Parent, const Key extends PropertyKey>(parent: Parent, key: Key, failureMessage?: string | undefined) => Exclude<Parent, Record<Key, any>> | undefined;
|
|
223
|
-
hasKeys: <const Keys extends PropertyKey, const Parent>(parent: Parent, keys: ReadonlyArray<Keys>) => (Parent & Record<Keys, (Keys extends keyof Parent ? import("
|
|
215
|
+
hasKeys: <const Keys extends PropertyKey, const Parent>(parent: Parent, keys: ReadonlyArray<Keys>) => (Parent & Record<Keys, (Keys extends keyof Parent ? import("@augment-vir/core").SetRequired<Parent, Keys>[Keys] : Keys extends keyof Extract<Parent, Record<Keys, any>> ? import("@augment-vir/core").SetRequired<Extract<Parent, Record<Keys, any>>, Keys>[Keys] : never) extends never ? unknown : Keys extends keyof Parent ? import("@augment-vir/core").SetRequired<Parent, Keys>[Keys] : Keys extends keyof Extract<Parent, Record<Keys, any>> ? import("@augment-vir/core").SetRequired<Extract<Parent, Record<Keys, any>>, Keys>[Keys] : never>) | undefined;
|
|
224
216
|
lacksKeys: <const Parent, const Key extends PropertyKey>(parent: Parent, key: ReadonlyArray<Key>) => Exclude<Parent, Partial<Record<Key, any>>> | undefined;
|
|
225
217
|
} & {
|
|
226
218
|
isLengthAtLeast: {
|
|
@@ -234,14 +226,65 @@ export declare const checkWrap: import("../../guard-types/check-wrap-wrapper-fun
|
|
|
234
226
|
} & {
|
|
235
227
|
isDefined: undefined;
|
|
236
228
|
isNullish: undefined;
|
|
229
|
+
} & {
|
|
230
|
+
isAbove: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
231
|
+
isAtLeast: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
232
|
+
isBelow: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
233
|
+
isAtMost: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
234
|
+
isNaN: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
235
|
+
isFinite: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
236
|
+
isInfinite: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
237
|
+
isApproximately: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
238
|
+
isNotApproximately: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
237
239
|
} & {
|
|
238
240
|
isNotPrimitive: <const Actual>(input: Actual) => Exclude<Actual, import("type-fest").Primitive> | undefined;
|
|
239
241
|
isNotPropertyKey: <const Actual>(input: Actual) => Exclude<Actual, PropertyKey> | undefined;
|
|
242
|
+
isPrimitive: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
243
|
+
isPropertyKey: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
240
244
|
} & {
|
|
241
245
|
isNotPromise: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, Promise<any>> | undefined;
|
|
242
246
|
isNotPromiseLike: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, PromiseLike<any>> | undefined;
|
|
247
|
+
isPromise: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
248
|
+
isPromiseLike: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
243
249
|
} & {
|
|
250
|
+
matches: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
251
|
+
mismatches: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
252
|
+
} & {
|
|
253
|
+
isUuid: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
244
254
|
isNotUuid: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, import("@augment-vir/core").Uuid> | undefined;
|
|
245
255
|
}>;
|
|
246
|
-
/**
|
|
247
|
-
|
|
256
|
+
/**
|
|
257
|
+
* A group of guard methods that do the following:
|
|
258
|
+
*
|
|
259
|
+
* 1. Run the method's assertion on the given inputs.
|
|
260
|
+
* 2. If the assertion fails, return `undefined`.
|
|
261
|
+
* 3. If the assertion succeeds, the first input is returned and (when possible) type guarded.
|
|
262
|
+
*
|
|
263
|
+
* This can also be called as a standalone check function which checks that its input is truthy and
|
|
264
|
+
* returns it if so, else `undefined`.
|
|
265
|
+
*
|
|
266
|
+
* @category Assert
|
|
267
|
+
* @category Package : @augment-vir/assert
|
|
268
|
+
* @example
|
|
269
|
+
*
|
|
270
|
+
* ```ts
|
|
271
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
272
|
+
*
|
|
273
|
+
* // `result1` will be `['a']`
|
|
274
|
+
* const result1 = checkWrap.deepEquals(['a'], ['a']);
|
|
275
|
+
*
|
|
276
|
+
* const value: unknown = 'some value' as unknown;
|
|
277
|
+
* // `result2` will be `'some value'` and it will have the type of `string`
|
|
278
|
+
* const result2 = checkWrap.isString(value);
|
|
279
|
+
*
|
|
280
|
+
* const value2: unknown = 'some value' as unknown;
|
|
281
|
+
* // `result` will be `undefined`
|
|
282
|
+
* const result3 = checkWrap.isNumber(value2);
|
|
283
|
+
* ```
|
|
284
|
+
*
|
|
285
|
+
* @returns The original given value (type guarded when possible) or, if the expectation fails,
|
|
286
|
+
* `undefined`.
|
|
287
|
+
* @package [`@augment-vir/assert`](https://www.npmjs.com/package/@augment-vir/assert)
|
|
288
|
+
*/
|
|
289
|
+
export declare const checkWrap: (<T>(input: T) => undefined | T) & typeof checkWrapGroup & Record<keyof AnyFunction, never>;
|
|
290
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { checkWrapOverrides, extendableAssertions } from '../../assertions/extendable-assertions.js';
|
|
2
2
|
import { createCheckWrapGroup } from '../../guard-types/check-wrap-wrapper-function.js';
|
|
3
|
+
const checkWrapGroup = createCheckWrapGroup(extendableAssertions, checkWrapOverrides);
|
|
3
4
|
/**
|
|
4
5
|
* A group of guard methods that do the following:
|
|
5
6
|
*
|
|
@@ -7,9 +8,11 @@ import { createCheckWrapGroup } from '../../guard-types/check-wrap-wrapper-funct
|
|
|
7
8
|
* 2. If the assertion fails, return `undefined`.
|
|
8
9
|
* 3. If the assertion succeeds, the first input is returned and (when possible) type guarded.
|
|
9
10
|
*
|
|
10
|
-
* This
|
|
11
|
+
* This can also be called as a standalone check function which checks that its input is truthy and
|
|
12
|
+
* returns it if so, else `undefined`.
|
|
11
13
|
*
|
|
12
14
|
* @category Assert
|
|
15
|
+
* @category Package : @augment-vir/assert
|
|
13
16
|
* @example
|
|
14
17
|
*
|
|
15
18
|
* ```ts
|
|
@@ -29,6 +32,11 @@ import { createCheckWrapGroup } from '../../guard-types/check-wrap-wrapper-funct
|
|
|
29
32
|
*
|
|
30
33
|
* @returns The original given value (type guarded when possible) or, if the expectation fails,
|
|
31
34
|
* `undefined`.
|
|
32
|
-
* @package
|
|
35
|
+
* @package [`@augment-vir/assert`](https://www.npmjs.com/package/@augment-vir/assert)
|
|
33
36
|
*/
|
|
34
|
-
export const checkWrap =
|
|
37
|
+
export const checkWrap = Object.assign(function checkWrap(input) {
|
|
38
|
+
if (!input) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
return input;
|
|
42
|
+
}, checkWrapGroup);
|
|
@@ -1,25 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* @category Assert
|
|
5
|
-
* @example
|
|
6
|
-
*
|
|
7
|
-
* ```ts
|
|
8
|
-
* import {check} from '@augment-vir/assert';
|
|
9
|
-
*
|
|
10
|
-
* const value: unknown = 'some value' as unknown;
|
|
11
|
-
* if (check.isString(value)) {
|
|
12
|
-
* // `value` will now be typed as a `string` in here
|
|
13
|
-
* }
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* @returns A boolean (as a type guard when possible).
|
|
17
|
-
* @package @augment-vir/assert
|
|
18
|
-
*/
|
|
19
|
-
export declare const check: import("../../guard-types/check-function.js").CheckGroup<{
|
|
1
|
+
import { AnyFunction } from '@augment-vir/core';
|
|
2
|
+
declare const checkGroup: import("../../guard-types/check-function.js").CheckGroup<{
|
|
20
3
|
output: {
|
|
21
|
-
<const FunctionToCall extends
|
|
22
|
-
<const FunctionToCall extends
|
|
4
|
+
<const FunctionToCall extends AnyFunction>(functionToCall: FunctionToCall, inputs: Parameters<NoInfer<FunctionToCall>>, expectedOutput: Awaited<ReturnType<NoInfer<FunctionToCall>>>, failureMessage?: string | undefined): Promise<any> extends ReturnType<NoInfer<FunctionToCall>> ? import("type-fest").IsAny<ReturnType<NoInfer<FunctionToCall>>> extends true ? void : Promise<void> : void;
|
|
5
|
+
<const FunctionToCall extends AnyFunction>(asserter: import("../assertion-exports.js").CustomOutputAsserter<NoInfer<FunctionToCall>>, functionToCall: FunctionToCall, inputs: Parameters<NoInfer<FunctionToCall>>, expectedOutput: Awaited<ReturnType<NoInfer<FunctionToCall>>>, failureMessage?: string | undefined): Promise<any> extends ReturnType<NoInfer<FunctionToCall>> ? import("type-fest").IsAny<ReturnType<NoInfer<FunctionToCall>>> extends true ? void : Promise<void> : void;
|
|
23
6
|
};
|
|
24
7
|
isHttpStatus: (actual: unknown, failureMessage?: string | undefined) => asserts actual is import("@augment-vir/core").HttpStatus;
|
|
25
8
|
isHttpStatusCategory: <const Actual, const Category extends import("@augment-vir/core").HttpStatusCategory>(actual: Actual, category: Category, failureMessage?: string | undefined) => asserts actual is import("@augment-vir/core").NarrowToExpected<Actual, import("@augment-vir/core").HttpStatusByCategory<Category>>;
|
|
@@ -33,13 +16,13 @@ export declare const check: import("../../guard-types/check-function.js").CheckG
|
|
|
33
16
|
isNotEmpty: <const Actual extends import("../assertion-exports.js").CanBeEmpty>(actual: Actual, failureMessage?: string | undefined) => asserts actual is Exclude<Actual, import("../assertion-exports.js").Empty>;
|
|
34
17
|
isUuid: (actual: unknown, failureMessage?: string | undefined) => asserts actual is import("@augment-vir/core").Uuid;
|
|
35
18
|
isNotUuid: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is Exclude<Actual, import("@augment-vir/core").Uuid>;
|
|
36
|
-
isError: (actual: unknown, matchOptions?: import("../assertion-exports.js").ErrorMatchOptions | undefined, failureMessage?: string | undefined) => asserts actual is Error;
|
|
37
19
|
throws: {
|
|
38
20
|
(callbackOrPromise: import("@augment-vir/core").TypedFunction<void, never>, matchOptions?: import("../assertion-exports.js").ErrorMatchOptions | undefined, failureMessage?: string | undefined): void;
|
|
39
21
|
(callbackOrPromise: import("@augment-vir/core").TypedFunction<void, Promise<any>> | Promise<any>, matchOptions?: import("../assertion-exports.js").ErrorMatchOptions | undefined, failureMessage?: string | undefined): Promise<void>;
|
|
40
22
|
(callback: import("@augment-vir/core").TypedFunction<void, any>, matchOptions?: import("../assertion-exports.js").ErrorMatchOptions | undefined, failureMessage?: string | undefined): void;
|
|
41
23
|
(callback: import("@augment-vir/core").TypedFunction<void, import("@augment-vir/core").MaybePromise<any>> | Promise<any>, matchOptions?: import("../assertion-exports.js").ErrorMatchOptions | undefined, failureMessage?: string | undefined): import("@augment-vir/core").MaybePromise<void>;
|
|
42
24
|
};
|
|
25
|
+
isError: (actual: unknown, matchOptions?: import("../assertion-exports.js").ErrorMatchOptions | undefined, failureMessage?: string | undefined) => asserts actual is Error;
|
|
43
26
|
strictEquals: typeof import("../../assertions/equality/simple-equality.js").strictEquals;
|
|
44
27
|
notStrictEquals: (actual: unknown, expected: unknown, failureMessage?: string | undefined) => void;
|
|
45
28
|
looseEquals: (actual: unknown, expected: unknown, failureMessage?: string | undefined) => void;
|
|
@@ -49,7 +32,7 @@ export declare const check: import("../../guard-types/check-function.js").CheckG
|
|
|
49
32
|
isArray: (actual: unknown, failureMessage?: string | undefined) => asserts actual is unknown[];
|
|
50
33
|
isBigInt: (actual: unknown, failureMessage?: string | undefined) => asserts actual is bigint;
|
|
51
34
|
isBoolean: (actual: unknown, failureMessage?: string | undefined) => asserts actual is boolean;
|
|
52
|
-
isFunction: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is import("@augment-vir/core").NarrowToActual<Actual,
|
|
35
|
+
isFunction: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is import("@augment-vir/core").NarrowToActual<Actual, AnyFunction>;
|
|
53
36
|
isNull: (actual: unknown, failureMessage?: string | undefined) => asserts actual is null;
|
|
54
37
|
isNumber: (actual: unknown, failureMessage?: string | undefined) => asserts actual is number;
|
|
55
38
|
isObject: (actual: unknown, failureMessage?: string | undefined) => asserts actual is import("@augment-vir/core").UnknownObject;
|
|
@@ -59,13 +42,13 @@ export declare const check: import("../../guard-types/check-function.js").CheckG
|
|
|
59
42
|
isNotArray: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is Exclude<Actual, ReadonlyArray<unknown>>;
|
|
60
43
|
isNotBigInt: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is Exclude<Actual, bigint>;
|
|
61
44
|
isNotBoolean: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is Exclude<Actual, boolean>;
|
|
62
|
-
isNotFunction: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is Exclude<Actual,
|
|
45
|
+
isNotFunction: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is Exclude<Actual, AnyFunction>;
|
|
46
|
+
isNotNull: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is Exclude<Actual, null>;
|
|
63
47
|
isNotNumber: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is Exclude<Actual, number>;
|
|
64
48
|
isNotObject: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is Exclude<Actual, import("@augment-vir/core").UnknownObject>;
|
|
65
49
|
isNotString: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is Exclude<Actual, string>;
|
|
66
50
|
isNotSymbol: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is Exclude<Actual, symbol>;
|
|
67
51
|
isNotUndefined: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is Exclude<Actual, undefined>;
|
|
68
|
-
isNotNull: <const Actual>(actual: Actual, failureMessage?: string | undefined) => asserts actual is Exclude<Actual, null>;
|
|
69
52
|
matches: (actual: string, expected: RegExp, failureMessage?: string | undefined) => void;
|
|
70
53
|
mismatches: (actual: string, expected: RegExp, failureMessage?: string | undefined) => void;
|
|
71
54
|
isPromiseLike: (actual: unknown, failureMessage?: string | undefined) => asserts actual is PromiseLike<any>;
|
|
@@ -97,9 +80,9 @@ export declare const check: import("../../guard-types/check-function.js").CheckG
|
|
|
97
80
|
};
|
|
98
81
|
isKeyOf: <const Parent>(key: PropertyKey, parent: Parent, failureMessage?: string | undefined) => asserts key is keyof Parent;
|
|
99
82
|
isNotKeyOf: <const Key extends PropertyKey, const Parent>(key: Key, parent: Parent, failureMessage?: string | undefined) => asserts key is Exclude<Key, import("@augment-vir/core").RequiredKeysOf<Parent>>;
|
|
100
|
-
hasKey: <const Key extends PropertyKey, const Parent>(parent: Parent, key: Key, failureMessage?: string | undefined) => asserts parent is Parent & Record<Key, (Key extends keyof Parent ? import("
|
|
83
|
+
hasKey: <const Key extends PropertyKey, const Parent>(parent: Parent, key: Key, failureMessage?: string | undefined) => asserts parent is Parent & Record<Key, (Key extends keyof Parent ? import("@augment-vir/core").SetRequired<Parent, Key>[Key] : Key extends keyof Extract<Parent, Record<Key, any>> ? import("@augment-vir/core").SetRequired<Extract<Parent, Record<Key, any>>, Key>[Key] : never) extends never ? unknown : Key extends keyof Parent ? import("@augment-vir/core").SetRequired<Parent, Key>[Key] : Key extends keyof Extract<Parent, Record<Key, any>> ? import("@augment-vir/core").SetRequired<Extract<Parent, Record<Key, any>>, Key>[Key] : never>;
|
|
101
84
|
lacksKey: <const Parent, const Key extends PropertyKey>(parent: Parent, key: Key, failureMessage?: string | undefined) => asserts parent is Exclude<Parent, Record<Key, any>>;
|
|
102
|
-
hasKeys: <const Keys extends PropertyKey, const Parent>(parent: Parent, keys: ReadonlyArray<Keys>, failureMessage?: string | undefined) => asserts parent is Parent & Record<Keys, (Keys extends keyof Parent ? import("
|
|
85
|
+
hasKeys: <const Keys extends PropertyKey, const Parent>(parent: Parent, keys: ReadonlyArray<Keys>, failureMessage?: string | undefined) => asserts parent is Parent & Record<Keys, (Keys extends keyof Parent ? import("@augment-vir/core").SetRequired<Parent, Keys>[Keys] : Keys extends keyof Extract<Parent, Record<Keys, any>> ? import("@augment-vir/core").SetRequired<Extract<Parent, Record<Keys, any>>, Keys>[Keys] : never) extends never ? unknown : Keys extends keyof Parent ? import("@augment-vir/core").SetRequired<Parent, Keys>[Keys] : Keys extends keyof Extract<Parent, Record<Keys, any>> ? import("@augment-vir/core").SetRequired<Extract<Parent, Record<Keys, any>>, Keys>[Keys] : never>;
|
|
103
86
|
lacksKeys: <const Parent, const Key extends PropertyKey>(parent: Parent, keys: ReadonlyArray<Key>, failureMessage?: string | undefined) => asserts parent is Exclude<Parent, Partial<Record<Key, any>>>;
|
|
104
87
|
jsonEquals: <const Actual, const Expected extends Actual>(actual: Actual, expected: Expected, failureMessage?: string | undefined) => asserts actual is Expected;
|
|
105
88
|
notJsonEquals: (actual: unknown, expected: unknown, failureMessage?: string | undefined) => void;
|
|
@@ -129,32 +112,48 @@ export declare const check: import("../../guard-types/check-function.js").CheckG
|
|
|
129
112
|
(parent: string, child: string, failureMessage?: string | undefined): void;
|
|
130
113
|
(parent: string | ReadonlyArray<string>, child: string, failureMessage?: string | undefined): void;
|
|
131
114
|
};
|
|
115
|
+
isFalse: (input: unknown, failureMessage?: string | undefined) => asserts input is false;
|
|
132
116
|
isFalsy: (input: unknown, failureMessage?: string | undefined) => asserts input is import("../assertion-exports.js").FalsyValue;
|
|
133
|
-
isTruthy: <const Actual>(input: Actual, failureMessage?: string | undefined) => asserts input is import("../assertion-exports.js").Truthy<Actual>;
|
|
134
117
|
isTrue: (input: unknown, failureMessage?: string | undefined) => asserts input is true;
|
|
135
|
-
|
|
118
|
+
isTruthy: <const Actual>(input: Actual, failureMessage?: string | undefined) => asserts input is import("../assertion-exports.js").Truthy<Actual>;
|
|
136
119
|
}, {
|
|
120
|
+
isFalse: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
121
|
+
isFalsy: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
122
|
+
isTrue: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
137
123
|
isTruthy: <T>(input: T) => input is import("../assertion-exports.js").Truthy<T>;
|
|
138
124
|
} & {
|
|
139
125
|
strictEquals: <Actual, Expected extends Actual>(actual: Actual, expected: Expected) => actual is Expected;
|
|
126
|
+
notStrictEquals: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
127
|
+
looseEquals: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
128
|
+
notLooseEquals: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
140
129
|
deepEquals: <Actual, Expected extends Actual>(actual: Actual, expected: Expected) => actual is Expected;
|
|
130
|
+
notDeepEquals: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
141
131
|
} & {
|
|
142
132
|
output: {
|
|
143
|
-
<const FunctionToCall extends
|
|
144
|
-
<const FunctionToCall extends
|
|
133
|
+
<const FunctionToCall extends AnyFunction>(functionToCall: FunctionToCall, inputs: Parameters<NoInfer<FunctionToCall>>, expectedOutput: Awaited<ReturnType<NoInfer<FunctionToCall>>>, failureMessage?: string | undefined): Promise<any> extends ReturnType<NoInfer<FunctionToCall>> ? import("type-fest").IsAny<ReturnType<FunctionToCall>> extends true ? boolean : Promise<boolean> : boolean;
|
|
134
|
+
<const FunctionToCall extends AnyFunction>(asserter: import("../assertion-exports.js").CustomOutputAsserter<NoInfer<FunctionToCall>>, functionToCall: FunctionToCall, inputs: Parameters<NoInfer<FunctionToCall>>, expectedOutput: Awaited<ReturnType<NoInfer<FunctionToCall>>>, failureMessage?: string | undefined): Promise<any> extends ReturnType<NoInfer<FunctionToCall>> ? import("type-fest").IsAny<ReturnType<FunctionToCall>> extends true ? boolean : Promise<boolean> : boolean;
|
|
145
135
|
};
|
|
146
136
|
} & {
|
|
147
|
-
|
|
137
|
+
isArray: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
138
|
+
isBigInt: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
139
|
+
isBoolean: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
140
|
+
isFunction: <const Actual>(actual: Actual, failureMessage?: string | undefined) => actual is import("@augment-vir/core").NarrowToActual<Actual, AnyFunction>;
|
|
141
|
+
isNull: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
142
|
+
isNumber: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
143
|
+
isObject: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
144
|
+
isString: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
145
|
+
isSymbol: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
146
|
+
isUndefined: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
148
147
|
isNotArray: <const Actual>(actual: Actual, failureMessage?: string | undefined) => actual is Exclude<Actual, ReadonlyArray<unknown>>;
|
|
149
148
|
isNotBigInt: <const Actual>(actual: Actual, failureMessage?: string | undefined) => actual is Exclude<Actual, bigint>;
|
|
150
149
|
isNotBoolean: <const Actual>(actual: Actual, failureMessage?: string | undefined) => actual is Exclude<Actual, boolean>;
|
|
151
|
-
isNotFunction: <const Actual>(actual: Actual, failureMessage?: string | undefined) => actual is Exclude<Actual,
|
|
150
|
+
isNotFunction: <const Actual>(actual: Actual, failureMessage?: string | undefined) => actual is Exclude<Actual, AnyFunction>;
|
|
152
151
|
isNotNull: <const Actual>(actual: Actual, failureMessage?: string | undefined) => actual is Exclude<Actual, null>;
|
|
153
152
|
isNotNumber: <const Actual>(actual: Actual, failureMessage?: string | undefined) => actual is Exclude<Actual, number>;
|
|
154
153
|
isNotObject: <const Actual>(actual: Actual, failureMessage?: string | undefined) => actual is Exclude<Actual, import("@augment-vir/core").UnknownObject>;
|
|
155
154
|
isNotString: <const Actual>(actual: Actual, failureMessage?: string | undefined) => actual is Exclude<Actual, string>;
|
|
156
|
-
isNotUndefined: <const Actual>(actual: Actual, failureMessage?: string | undefined) => actual is Exclude<Actual, undefined>;
|
|
157
155
|
isNotSymbol: <const Actual>(actual: Actual, failureMessage?: string | undefined) => actual is Exclude<Actual, symbol>;
|
|
156
|
+
isNotUndefined: <const Actual>(actual: Actual, failureMessage?: string | undefined) => actual is Exclude<Actual, undefined>;
|
|
158
157
|
} & {
|
|
159
158
|
throws: {
|
|
160
159
|
(callbackOrPromise: import("@augment-vir/core").TypedFunction<void, never>, matchOptions?: import("../assertion-exports.js").ErrorMatchOptions | undefined): boolean;
|
|
@@ -162,7 +161,12 @@ export declare const check: import("../../guard-types/check-function.js").CheckG
|
|
|
162
161
|
(callback: import("@augment-vir/core").TypedFunction<void, any>, matchOptions?: import("../assertion-exports.js").ErrorMatchOptions | undefined): boolean;
|
|
163
162
|
(callback: import("@augment-vir/core").TypedFunction<void, import("@augment-vir/core").MaybePromise<any>> | Promise<any>, matchOptions?: import("../assertion-exports.js").ErrorMatchOptions | undefined): import("@augment-vir/core").MaybePromise<boolean>;
|
|
164
163
|
};
|
|
164
|
+
isError: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
165
165
|
} & {
|
|
166
|
+
hasValue: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
167
|
+
lacksValue: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
168
|
+
hasValues: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
169
|
+
lacksValues: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
166
170
|
isIn: <const Parent>(child: unknown, parent: Parent) => child is import("@augment-vir/core").Values<Parent>;
|
|
167
171
|
isNotIn: <const Parent, const Child>(child: Child, parent: Parent, failureMessage?: string | undefined) => child is Exclude<Child, import("@augment-vir/core").Values<Parent>>;
|
|
168
172
|
isEmpty: <const Actual extends import("../assertion-exports.js").CanBeEmpty>(actual: Actual) => actual is import("@augment-vir/core").NarrowToActual<Actual, import("../assertion-exports.js").Empty>;
|
|
@@ -193,9 +197,12 @@ export declare const check: import("../../guard-types/check-function.js").CheckG
|
|
|
193
197
|
isNotEnumValue: <const Actual, const Expected extends import("@augment-vir/core").EnumBaseType>(child: Actual, checkEnum: Expected) => child is Exclude<Actual, Expected[keyof Expected] | `${Expected[keyof Expected]}`>;
|
|
194
198
|
} & {
|
|
195
199
|
entriesEqual: <Actual, Expected extends Actual>(actual: Actual, expected: Expected) => actual is Expected;
|
|
200
|
+
notEntriesEqual: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
196
201
|
} & {
|
|
197
202
|
jsonEquals: <Actual, Expected extends Actual>(actual: Actual, expected: Expected) => actual is Expected;
|
|
203
|
+
notJsonEquals: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
198
204
|
} & {
|
|
205
|
+
isHttpStatus: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
199
206
|
isHttpStatusCategory: <const Actual, const Category extends import("@augment-vir/core").HttpStatusCategory>(actual: Actual, category: Category, failureMessage?: string | undefined) => actual is import("@augment-vir/core").NarrowToExpected<Actual, import("@augment-vir/core").HttpStatusByCategory<Category>>;
|
|
200
207
|
} & {
|
|
201
208
|
instanceOf: <const Instance>(instance: unknown, constructor: import("type-fest").Constructor<Instance>) => instance is Instance;
|
|
@@ -203,9 +210,9 @@ export declare const check: import("../../guard-types/check-function.js").CheckG
|
|
|
203
210
|
} & {
|
|
204
211
|
isKeyOf: <const Parent>(key: PropertyKey, parent: Parent) => key is keyof Parent;
|
|
205
212
|
isNotKeyOf: <const Key extends PropertyKey, const Parent>(key: Key, parent: Parent, failureMessage?: string | undefined) => key is Exclude<Key, import("@augment-vir/core").RequiredKeysOf<Parent>>;
|
|
206
|
-
hasKey: <const Parent, const Key extends PropertyKey>(parent: Parent, key: Key) => parent is Parent & Record<Key, (Key extends keyof Parent ? import("
|
|
213
|
+
hasKey: <const Parent, const Key extends PropertyKey>(parent: Parent, key: Key) => parent is Parent & Record<Key, (Key extends keyof Parent ? import("@augment-vir/core").SetRequired<Parent, Key>[Key] : Key extends keyof Extract<Parent, Record<Key, any>> ? import("@augment-vir/core").SetRequired<Extract<Parent, Record<Key, any>>, Key>[Key] : never) extends never ? unknown : Key extends keyof Parent ? import("@augment-vir/core").SetRequired<Parent, Key>[Key] : Key extends keyof Extract<Parent, Record<Key, any>> ? import("@augment-vir/core").SetRequired<Extract<Parent, Record<Key, any>>, Key>[Key] : never>;
|
|
207
214
|
lacksKey: <const Parent, const Key extends PropertyKey>(parent: Parent, key: Key, failureMessage?: string | undefined) => parent is Exclude<Parent, Record<Key, any>>;
|
|
208
|
-
hasKeys: <const Keys extends PropertyKey, const Parent>(parent: Parent, keys: ReadonlyArray<Keys>) => parent is Parent & Record<Keys, (Keys extends keyof Parent ? import("
|
|
215
|
+
hasKeys: <const Keys extends PropertyKey, const Parent>(parent: Parent, keys: ReadonlyArray<Keys>) => parent is Parent & Record<Keys, (Keys extends keyof Parent ? import("@augment-vir/core").SetRequired<Parent, Keys>[Keys] : Keys extends keyof Extract<Parent, Record<Keys, any>> ? import("@augment-vir/core").SetRequired<Extract<Parent, Record<Keys, any>>, Keys>[Keys] : never) extends never ? unknown : Keys extends keyof Parent ? import("@augment-vir/core").SetRequired<Parent, Keys>[Keys] : Keys extends keyof Extract<Parent, Record<Keys, any>> ? import("@augment-vir/core").SetRequired<Extract<Parent, Record<Keys, any>>, Keys>[Keys] : never>;
|
|
209
216
|
lacksKeys: <const Parent, const Key extends PropertyKey>(parent: Parent, key: ReadonlyArray<Key>) => parent is Exclude<Parent, Partial<Record<Key, any>>>;
|
|
210
217
|
} & {
|
|
211
218
|
isLengthAtLeast: {
|
|
@@ -218,12 +225,55 @@ export declare const check: import("../../guard-types/check-function.js").CheckG
|
|
|
218
225
|
};
|
|
219
226
|
} & {
|
|
220
227
|
isDefined: <Actual>(input: Actual) => input is Exclude<Actual, undefined | null>;
|
|
228
|
+
isNullish: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
229
|
+
} & {
|
|
230
|
+
isAbove: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
231
|
+
isAtLeast: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
232
|
+
isBelow: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
233
|
+
isAtMost: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
234
|
+
isNaN: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
235
|
+
isFinite: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
236
|
+
isInfinite: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
237
|
+
isApproximately: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
238
|
+
isNotApproximately: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
221
239
|
} & {
|
|
222
240
|
isNotPrimitive: <const Actual>(input: Actual) => input is Exclude<Actual, import("type-fest").Primitive>;
|
|
223
241
|
isNotPropertyKey: <const Actual>(input: Actual) => input is Exclude<Actual, PropertyKey>;
|
|
242
|
+
isPrimitive: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
243
|
+
isPropertyKey: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
224
244
|
} & {
|
|
225
|
-
|
|
245
|
+
isPromiseLike: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
226
246
|
isNotPromiseLike: <const Actual>(actual: Actual, failureMessage?: string | undefined) => actual is Exclude<Actual, PromiseLike<any>>;
|
|
247
|
+
isPromise: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
248
|
+
isNotPromise: <const Actual>(actual: Actual, failureMessage?: string | undefined) => actual is Exclude<Actual, Promise<any>>;
|
|
249
|
+
} & {
|
|
250
|
+
matches: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
251
|
+
mismatches: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
227
252
|
} & {
|
|
253
|
+
isUuid: typeof import("../../guard-types/guard-override.js").autoGuardSymbol;
|
|
228
254
|
isNotUuid: <const Actual>(actual: Actual, failureMessage?: string | undefined) => actual is Exclude<Actual, import("@augment-vir/core").Uuid>;
|
|
229
255
|
}>;
|
|
256
|
+
/**
|
|
257
|
+
* A group of guard methods that return a boolean type guard rather than an assertion type guard.
|
|
258
|
+
*
|
|
259
|
+
* This can also be called as a standalone check function which returns a boolean to indicate
|
|
260
|
+
* whether its input is truthy or not.
|
|
261
|
+
*
|
|
262
|
+
* @category Assert
|
|
263
|
+
* @category Package : @augment-vir/assert
|
|
264
|
+
* @example
|
|
265
|
+
*
|
|
266
|
+
* ```ts
|
|
267
|
+
* import {check} from '@augment-vir/assert';
|
|
268
|
+
*
|
|
269
|
+
* const value: unknown = 'some value' as unknown;
|
|
270
|
+
* if (check.isString(value)) {
|
|
271
|
+
* // `value` will now be typed as a `string` in here
|
|
272
|
+
* }
|
|
273
|
+
* ```
|
|
274
|
+
*
|
|
275
|
+
* @returns A boolean (as a type guard when possible).
|
|
276
|
+
* @package [`@augment-vir/assert`](https://www.npmjs.com/package/@augment-vir/assert)
|
|
277
|
+
*/
|
|
278
|
+
export declare const check: ((input: unknown) => boolean) & typeof checkGroup & Record<keyof AnyFunction, never>;
|
|
279
|
+
export {};
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { checkOverrides, extendableAssertions } from '../../assertions/extendable-assertions.js';
|
|
2
2
|
import { createCheckGroup } from '../../guard-types/check-function.js';
|
|
3
|
+
const checkGroup = createCheckGroup(extendableAssertions, checkOverrides);
|
|
3
4
|
/**
|
|
4
5
|
* A group of guard methods that return a boolean type guard rather than an assertion type guard.
|
|
5
6
|
*
|
|
7
|
+
* This can also be called as a standalone check function which returns a boolean to indicate
|
|
8
|
+
* whether its input is truthy or not.
|
|
9
|
+
*
|
|
6
10
|
* @category Assert
|
|
11
|
+
* @category Package : @augment-vir/assert
|
|
7
12
|
* @example
|
|
8
13
|
*
|
|
9
14
|
* ```ts
|
|
@@ -16,6 +21,8 @@ import { createCheckGroup } from '../../guard-types/check-function.js';
|
|
|
16
21
|
* ```
|
|
17
22
|
*
|
|
18
23
|
* @returns A boolean (as a type guard when possible).
|
|
19
|
-
* @package
|
|
24
|
+
* @package [`@augment-vir/assert`](https://www.npmjs.com/package/@augment-vir/assert)
|
|
20
25
|
*/
|
|
21
|
-
export const check =
|
|
26
|
+
export const check = Object.assign(function check(input) {
|
|
27
|
+
return !!input;
|
|
28
|
+
}, checkGroup);
|