bupkis 0.2.0 → 0.4.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/CHANGELOG.md +27 -0
- package/README.md +35 -11
- package/dist/commonjs/assertion/assertion-async.d.ts +2 -1
- package/dist/commonjs/assertion/assertion-async.d.ts.map +1 -1
- package/dist/commonjs/assertion/assertion-async.js +84 -2
- package/dist/commonjs/assertion/assertion-async.js.map +1 -1
- package/dist/commonjs/assertion/assertion-sync.d.ts +1 -1
- package/dist/commonjs/assertion/assertion-sync.d.ts.map +1 -1
- package/dist/commonjs/assertion/assertion-sync.js +5 -1
- package/dist/commonjs/assertion/assertion-sync.js.map +1 -1
- package/dist/commonjs/assertion/assertion-types.d.ts +6 -2
- package/dist/commonjs/assertion/assertion-types.d.ts.map +1 -1
- package/dist/commonjs/assertion/assertion.d.ts +1 -1
- package/dist/commonjs/assertion/assertion.d.ts.map +1 -1
- package/dist/commonjs/assertion/assertion.js +1 -14
- package/dist/commonjs/assertion/assertion.js.map +1 -1
- package/dist/commonjs/assertion/impl/async.d.ts +122 -21
- package/dist/commonjs/assertion/impl/async.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/async.js +118 -90
- package/dist/commonjs/assertion/impl/async.js.map +1 -1
- package/dist/commonjs/assertion/impl/callback.d.ts +104 -0
- package/dist/commonjs/assertion/impl/callback.d.ts.map +1 -0
- package/dist/commonjs/assertion/impl/callback.js +694 -0
- package/dist/commonjs/assertion/impl/callback.js.map +1 -0
- package/dist/commonjs/assertion/impl/index.d.ts +1 -1
- package/dist/commonjs/assertion/impl/index.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/index.js.map +1 -1
- package/dist/commonjs/assertion/impl/sync-basic.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/sync-basic.js +1 -1
- package/dist/commonjs/assertion/impl/sync-basic.js.map +1 -1
- package/dist/commonjs/assertion/impl/sync-collection.d.ts +1 -1
- package/dist/commonjs/assertion/impl/sync-collection.js +3 -3
- package/dist/commonjs/assertion/impl/sync-collection.js.map +1 -1
- package/dist/commonjs/assertion/impl/sync-esoteric.js +1 -1
- package/dist/commonjs/assertion/impl/sync-esoteric.js.map +1 -1
- package/dist/commonjs/assertion/impl/sync-parametric.d.ts +22 -28
- package/dist/commonjs/assertion/impl/sync-parametric.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/sync-parametric.js +35 -50
- package/dist/commonjs/assertion/impl/sync-parametric.js.map +1 -1
- package/dist/commonjs/assertion/impl/sync.d.ts +68 -30
- package/dist/commonjs/assertion/impl/sync.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/sync.js +4 -1
- package/dist/commonjs/assertion/impl/sync.js.map +1 -1
- package/dist/commonjs/bootstrap.d.ts +147 -52
- package/dist/commonjs/bootstrap.d.ts.map +1 -1
- package/dist/commonjs/bootstrap.js +2 -3
- package/dist/commonjs/bootstrap.js.map +1 -1
- package/dist/commonjs/constant.d.ts +1 -1
- package/dist/commonjs/constant.d.ts.map +1 -1
- package/dist/commonjs/constant.js +8 -1
- package/dist/commonjs/constant.js.map +1 -1
- package/dist/commonjs/error.d.ts +22 -2
- package/dist/commonjs/error.d.ts.map +1 -1
- package/dist/commonjs/error.js +44 -4
- package/dist/commonjs/error.js.map +1 -1
- package/dist/commonjs/expect.d.ts.map +1 -1
- package/dist/commonjs/expect.js +1 -1
- package/dist/commonjs/expect.js.map +1 -1
- package/dist/commonjs/guards.d.ts +96 -5
- package/dist/commonjs/guards.d.ts.map +1 -1
- package/dist/commonjs/guards.js +104 -25
- package/dist/commonjs/guards.js.map +1 -1
- package/dist/commonjs/index.d.ts +146 -51
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/schema.d.ts +84 -18
- package/dist/commonjs/schema.d.ts.map +1 -1
- package/dist/commonjs/schema.js +107 -22
- package/dist/commonjs/schema.js.map +1 -1
- package/dist/commonjs/types.d.ts +171 -9
- package/dist/commonjs/types.d.ts.map +1 -1
- package/dist/commonjs/use.d.ts.map +1 -1
- package/dist/commonjs/use.js +15 -1
- package/dist/commonjs/use.js.map +1 -1
- package/dist/commonjs/util.d.ts +66 -50
- package/dist/commonjs/util.d.ts.map +1 -1
- package/dist/commonjs/util.js +169 -156
- package/dist/commonjs/util.js.map +1 -1
- package/dist/commonjs/value-to-schema.d.ts +122 -0
- package/dist/commonjs/value-to-schema.d.ts.map +1 -0
- package/dist/commonjs/value-to-schema.js +329 -0
- package/dist/commonjs/value-to-schema.js.map +1 -0
- package/dist/esm/assertion/assertion-async.d.ts +2 -1
- package/dist/esm/assertion/assertion-async.d.ts.map +1 -1
- package/dist/esm/assertion/assertion-async.js +85 -3
- package/dist/esm/assertion/assertion-async.js.map +1 -1
- package/dist/esm/assertion/assertion-sync.d.ts +1 -1
- package/dist/esm/assertion/assertion-sync.d.ts.map +1 -1
- package/dist/esm/assertion/assertion-sync.js +6 -2
- package/dist/esm/assertion/assertion-sync.js.map +1 -1
- package/dist/esm/assertion/assertion-types.d.ts +6 -2
- package/dist/esm/assertion/assertion-types.d.ts.map +1 -1
- package/dist/esm/assertion/assertion.d.ts +1 -1
- package/dist/esm/assertion/assertion.d.ts.map +1 -1
- package/dist/esm/assertion/assertion.js +1 -14
- package/dist/esm/assertion/assertion.js.map +1 -1
- package/dist/esm/assertion/impl/async.d.ts +122 -21
- package/dist/esm/assertion/impl/async.d.ts.map +1 -1
- package/dist/esm/assertion/impl/async.js +118 -90
- package/dist/esm/assertion/impl/async.js.map +1 -1
- package/dist/esm/assertion/impl/callback.d.ts +104 -0
- package/dist/esm/assertion/impl/callback.d.ts.map +1 -0
- package/dist/esm/assertion/impl/callback.js +691 -0
- package/dist/esm/assertion/impl/callback.js.map +1 -0
- package/dist/esm/assertion/impl/index.d.ts +1 -1
- package/dist/esm/assertion/impl/index.d.ts.map +1 -1
- package/dist/esm/assertion/impl/index.js +1 -1
- package/dist/esm/assertion/impl/index.js.map +1 -1
- package/dist/esm/assertion/impl/sync-basic.d.ts.map +1 -1
- package/dist/esm/assertion/impl/sync-basic.js +2 -2
- package/dist/esm/assertion/impl/sync-basic.js.map +1 -1
- package/dist/esm/assertion/impl/sync-collection.d.ts +1 -1
- package/dist/esm/assertion/impl/sync-collection.js +3 -3
- package/dist/esm/assertion/impl/sync-collection.js.map +1 -1
- package/dist/esm/assertion/impl/sync-esoteric.js +2 -2
- package/dist/esm/assertion/impl/sync-esoteric.js.map +1 -1
- package/dist/esm/assertion/impl/sync-parametric.d.ts +22 -28
- package/dist/esm/assertion/impl/sync-parametric.d.ts.map +1 -1
- package/dist/esm/assertion/impl/sync-parametric.js +36 -51
- package/dist/esm/assertion/impl/sync-parametric.js.map +1 -1
- package/dist/esm/assertion/impl/sync.d.ts +68 -30
- package/dist/esm/assertion/impl/sync.d.ts.map +1 -1
- package/dist/esm/assertion/impl/sync.js +3 -1
- package/dist/esm/assertion/impl/sync.js.map +1 -1
- package/dist/esm/bootstrap.d.ts +147 -52
- package/dist/esm/bootstrap.d.ts.map +1 -1
- package/dist/esm/bootstrap.js +1 -2
- package/dist/esm/bootstrap.js.map +1 -1
- package/dist/esm/constant.d.ts +1 -1
- package/dist/esm/constant.d.ts.map +1 -1
- package/dist/esm/constant.js +7 -0
- package/dist/esm/constant.js.map +1 -1
- package/dist/esm/error.d.ts +22 -2
- package/dist/esm/error.d.ts.map +1 -1
- package/dist/esm/error.js +43 -4
- package/dist/esm/error.js.map +1 -1
- package/dist/esm/expect.d.ts.map +1 -1
- package/dist/esm/expect.js +2 -2
- package/dist/esm/expect.js.map +1 -1
- package/dist/esm/guards.d.ts +96 -5
- package/dist/esm/guards.d.ts.map +1 -1
- package/dist/esm/guards.js +98 -21
- package/dist/esm/guards.js.map +1 -1
- package/dist/esm/index.d.ts +146 -51
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/schema.d.ts +84 -18
- package/dist/esm/schema.d.ts.map +1 -1
- package/dist/esm/schema.js +107 -22
- package/dist/esm/schema.js.map +1 -1
- package/dist/esm/types.d.ts +171 -9
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/use.d.ts.map +1 -1
- package/dist/esm/use.js +15 -1
- package/dist/esm/use.js.map +1 -1
- package/dist/esm/util.d.ts +66 -50
- package/dist/esm/util.d.ts.map +1 -1
- package/dist/esm/util.js +153 -154
- package/dist/esm/util.js.map +1 -1
- package/dist/esm/value-to-schema.d.ts +122 -0
- package/dist/esm/value-to-schema.d.ts.map +1 -0
- package/dist/esm/value-to-schema.js +325 -0
- package/dist/esm/value-to-schema.js.map +1 -0
- package/package.json +16 -13
- package/src/assertion/assertion-async.ts +113 -3
- package/src/assertion/assertion-sync.ts +5 -2
- package/src/assertion/assertion-types.ts +14 -4
- package/src/assertion/assertion.ts +2 -17
- package/src/assertion/impl/async.ts +137 -93
- package/src/assertion/impl/callback.ts +882 -0
- package/src/assertion/impl/index.ts +1 -1
- package/src/assertion/impl/sync-basic.ts +5 -2
- package/src/assertion/impl/sync-collection.ts +3 -3
- package/src/assertion/impl/sync-esoteric.ts +2 -2
- package/src/assertion/impl/sync-parametric.ts +47 -54
- package/src/assertion/impl/sync.ts +3 -0
- package/src/bootstrap.ts +1 -2
- package/src/constant.ts +10 -0
- package/src/error.ts +57 -3
- package/src/expect.ts +6 -2
- package/src/guards.ts +125 -18
- package/src/index.ts +3 -0
- package/src/schema.ts +121 -23
- package/src/types.ts +205 -10
- package/src/use.ts +22 -0
- package/src/util.ts +168 -223
- package/src/value-to-schema.ts +489 -0
package/dist/esm/schema.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This module provides reusable Zod schemas for validating constructors,
|
|
5
5
|
* functions, property keys, promises, and other common JavaScript types used
|
|
6
|
-
* throughout the assertion system. These tend to work around the
|
|
6
|
+
* throughout the assertion system. These tend to work around the impedance
|
|
7
7
|
* mismatch between **BUPKIS** and Zod.
|
|
8
8
|
*
|
|
9
9
|
* These are used internally, but consumers may also find them useful.
|
|
@@ -32,39 +32,39 @@
|
|
|
32
32
|
* @packageDocumentation
|
|
33
33
|
*/
|
|
34
34
|
import { z } from 'zod/v4';
|
|
35
|
-
import { isA,
|
|
35
|
+
import { isA, isConstructible, isExpectItExecutor, isFunction, isNonNullObject, isPromiseLike, } from './guards.js';
|
|
36
36
|
import { BupkisRegistry } from './metadata.js';
|
|
37
37
|
/**
|
|
38
|
-
* A Zod schema that validates JavaScript
|
|
38
|
+
* A Zod schema that validates JavaScript constructible functions.
|
|
39
39
|
*
|
|
40
40
|
* This schema validates values that can be used as constructors, including ES6
|
|
41
41
|
* classes, traditional constructor functions, and built-in constructors. It
|
|
42
|
-
* uses the {@link
|
|
42
|
+
* uses the {@link isConstructible} guard function to determine if a value can be
|
|
43
43
|
* invoked with the `new` operator to create object instances.
|
|
44
44
|
*
|
|
45
45
|
* @privateRemarks
|
|
46
46
|
* The schema is registered in the {@link BupkisRegistry} with the name
|
|
47
|
-
* `
|
|
47
|
+
* `ConstructibleSchema` for later reference and type checking purposes.
|
|
48
48
|
* @example
|
|
49
49
|
*
|
|
50
50
|
* ```typescript
|
|
51
51
|
* class MyClass {}
|
|
52
52
|
* function MyConstructor() {}
|
|
53
53
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
54
|
+
* ConstructibleSchema.parse(MyClass); // ✓ Valid
|
|
55
|
+
* ConstructibleSchema.parse(MyConstructor); // ✓ Valid
|
|
56
|
+
* ConstructibleSchema.parse(Array); // ✓ Valid
|
|
57
|
+
* ConstructibleSchema.parse(Date); // ✓ Valid
|
|
58
|
+
* ConstructibleSchema.parse(() => {}); // ✗ Throws validation error
|
|
59
|
+
* ConstructibleSchema.parse({}); // ✗ Throws validation error
|
|
60
60
|
* ```
|
|
61
61
|
*
|
|
62
62
|
* @group Schema
|
|
63
63
|
*/
|
|
64
|
-
export const
|
|
65
|
-
.custom(
|
|
66
|
-
.register(BupkisRegistry, { name: '
|
|
67
|
-
.describe('
|
|
64
|
+
export const ConstructibleSchema = z
|
|
65
|
+
.custom(isConstructible)
|
|
66
|
+
.register(BupkisRegistry, { name: 'ConstructibleSchema' })
|
|
67
|
+
.describe('Constructible Function');
|
|
68
68
|
/**
|
|
69
69
|
* A Zod schema that validates any JavaScript function.
|
|
70
70
|
*
|
|
@@ -221,9 +221,12 @@ export const StrongSetSchema = z
|
|
|
221
221
|
* `Object.prototype`, making them useful as pure data containers or
|
|
222
222
|
* dictionaries.
|
|
223
223
|
*
|
|
224
|
-
* @
|
|
224
|
+
* @privateRemarks
|
|
225
225
|
* The schema is registered in the `BupkisRegistry` with the name
|
|
226
226
|
* `ObjectWithNullPrototype` for later reference and type checking purposes.
|
|
227
|
+
*
|
|
228
|
+
* Changing this to be a `ZodRecord` would be nice, but that would end up
|
|
229
|
+
* blasting away the original object's prototype.
|
|
227
230
|
* @example
|
|
228
231
|
*
|
|
229
232
|
* ```typescript
|
|
@@ -239,11 +242,18 @@ export const StrongSetSchema = z
|
|
|
239
242
|
* ```
|
|
240
243
|
*
|
|
241
244
|
* @group Schema
|
|
245
|
+
* @see Aliases: {@link NullProtoObjectSchema}, {@link DictionarySchema}
|
|
242
246
|
*/
|
|
243
|
-
export const
|
|
247
|
+
export const DictionarySchema = z
|
|
244
248
|
.custom((value) => isNonNullObject(value) && Object.getPrototypeOf(value) === null)
|
|
245
249
|
.describe('Object with null prototype')
|
|
246
250
|
.register(BupkisRegistry, { name: 'ObjectWithNullPrototype' });
|
|
251
|
+
/**
|
|
252
|
+
* {@inheritDoc DictionarySchema}
|
|
253
|
+
*
|
|
254
|
+
* @group Schema
|
|
255
|
+
*/
|
|
256
|
+
export const NullProtoObjectSchema = DictionarySchema;
|
|
247
257
|
/**
|
|
248
258
|
* A Zod schema that validates functions declared with the `async` keyword.
|
|
249
259
|
*
|
|
@@ -252,7 +262,7 @@ export const NullProtoObjectSchema = z
|
|
|
252
262
|
* function's internal `[[ToString]]` representation to distinguish async
|
|
253
263
|
* functions from regular functions that might return Promises.
|
|
254
264
|
*
|
|
255
|
-
* @
|
|
265
|
+
* @privateRemarks
|
|
256
266
|
* The schema is registered in the `BupkisRegistry` with the name
|
|
257
267
|
* `AsyncFunctionSchema` for later reference and type checking purposes. This
|
|
258
268
|
* schema cannot reliably detect functions that return Promises but are not
|
|
@@ -291,7 +301,7 @@ export const AsyncFunctionSchema = FunctionSchema.refine((value) => Object.proto
|
|
|
291
301
|
* if it converts to `true` when evaluated in a boolean context - essentially
|
|
292
302
|
* any value that is not one of the eight falsy values.
|
|
293
303
|
*
|
|
294
|
-
* @
|
|
304
|
+
* @privateRemarks
|
|
295
305
|
* The schema is registered in the `BupkisRegistry` with the name `Truthy` and
|
|
296
306
|
* indicates that it accepts anything as valid input for evaluation.
|
|
297
307
|
* @example
|
|
@@ -326,7 +336,7 @@ export const TruthySchema = z
|
|
|
326
336
|
* in JavaScript are: `false`, `0`, `-0`, `0n`, `""` (empty string), `null`,
|
|
327
337
|
* `undefined`, and `NaN`.
|
|
328
338
|
*
|
|
329
|
-
* @
|
|
339
|
+
* @privateRemarks
|
|
330
340
|
* The schema is registered in the `BupkisRegistry` with the name `Falsy` and
|
|
331
341
|
* indicates that it accepts anything as valid input for evaluation.
|
|
332
342
|
* @example
|
|
@@ -363,7 +373,7 @@ export const FalsySchema = z
|
|
|
363
373
|
* distinguishing them from objects and functions which are non-primitive
|
|
364
374
|
* reference types.
|
|
365
375
|
*
|
|
366
|
-
* @
|
|
376
|
+
* @privateRemarks
|
|
367
377
|
* The schema is registered in the `BupkisRegistry` with the name `Primitive`
|
|
368
378
|
* and indicates that it accepts primitive values as valid input.
|
|
369
379
|
* @example
|
|
@@ -443,7 +453,7 @@ export const ArrayLikeSchema = z
|
|
|
443
453
|
* It ensures the validated value is a proper regular expression object with all
|
|
444
454
|
* associated methods and properties.
|
|
445
455
|
*
|
|
446
|
-
* @
|
|
456
|
+
* @privateRemarks
|
|
447
457
|
* The schema is registered in the `BupkisRegistry` with the name `RegExp` for
|
|
448
458
|
* later reference and type checking purposes.
|
|
449
459
|
* @example
|
|
@@ -464,4 +474,79 @@ export const RegExpSchema = z
|
|
|
464
474
|
.instanceof(RegExp)
|
|
465
475
|
.describe('A RegExp instance')
|
|
466
476
|
.register(BupkisRegistry, { name: 'RegExp' });
|
|
477
|
+
/**
|
|
478
|
+
* A recursive Zod schema that validates values allowed in "to satisfy"
|
|
479
|
+
* assertion patterns.
|
|
480
|
+
*
|
|
481
|
+
* This schema defines the allowed structure for patterns used with "to satisfy"
|
|
482
|
+
* and "to be like" assertions. It supports a recursive structure that can
|
|
483
|
+
* contain:
|
|
484
|
+
*
|
|
485
|
+
* - **Primitive values**: strings, numbers, booleans, null, undefined, bigint,
|
|
486
|
+
* symbols
|
|
487
|
+
* - **Regular expressions**: for pattern matching against string values
|
|
488
|
+
* - **ExpectItExecutor functions**: nested assertions created via `expect.it()`
|
|
489
|
+
* - **Objects**: with properties that recursively follow this same pattern
|
|
490
|
+
* - **Arrays**: with elements that recursively follow this same pattern
|
|
491
|
+
*
|
|
492
|
+
* The schema handles the special semantics required for "to satisfy"
|
|
493
|
+
* assertions:
|
|
494
|
+
*
|
|
495
|
+
* - RegExp values are used for pattern testing rather than exact matching
|
|
496
|
+
* - ExpectItExecutor functions are executed as nested assertions
|
|
497
|
+
* - Objects and arrays can contain any combination of the above recursively
|
|
498
|
+
*
|
|
499
|
+
* @privateRemarks
|
|
500
|
+
* Uses `z.lazy()` to handle recursive object and array structures without
|
|
501
|
+
* causing infinite recursion during schema definition. The schema is registered
|
|
502
|
+
* in the `BupkisRegistry` for reference and type checking.
|
|
503
|
+
* @example
|
|
504
|
+
*
|
|
505
|
+
* ```typescript
|
|
506
|
+
* // Primitive values
|
|
507
|
+
* SatisfyPatternSchema.parse('hello'); // ✓ Valid
|
|
508
|
+
* SatisfyPatternSchema.parse(42); // ✓ Valid
|
|
509
|
+
* SatisfyPatternSchema.parse(true); // ✓ Valid
|
|
510
|
+
*
|
|
511
|
+
* // Regular expressions for pattern matching
|
|
512
|
+
* SatisfyPatternSchema.parse(/test/); // ✓ Valid
|
|
513
|
+
*
|
|
514
|
+
* // ExpectItExecutor functions
|
|
515
|
+
* SatisfyPatternSchema.parse(expect.it('to be a string')); // ✓ Valid
|
|
516
|
+
*
|
|
517
|
+
* // Complex nested structures
|
|
518
|
+
* SatisfyPatternSchema.parse({
|
|
519
|
+
* name: expect.it('to be a string'),
|
|
520
|
+
* email: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
|
|
521
|
+
* age: expect.it('to be greater than', 0),
|
|
522
|
+
* tags: [expect.it('to be a string')],
|
|
523
|
+
* }); // ✓ Valid
|
|
524
|
+
*
|
|
525
|
+
* // Invalid values
|
|
526
|
+
* SatisfyPatternSchema.parse(new Date()); // ✗ Invalid (not supported type)
|
|
527
|
+
* SatisfyPatternSchema.parse(() => {}); // ✗ Invalid (regular function, not ExpectItExecutor)
|
|
528
|
+
* ```
|
|
529
|
+
*
|
|
530
|
+
* @group Schema
|
|
531
|
+
*/
|
|
532
|
+
export const SatisfyPatternSchema = z
|
|
533
|
+
.lazy(() => z.union([
|
|
534
|
+
// Primitive types
|
|
535
|
+
z.string(),
|
|
536
|
+
z.number(),
|
|
537
|
+
z.boolean(),
|
|
538
|
+
z.null(),
|
|
539
|
+
z.undefined(),
|
|
540
|
+
z.bigint(),
|
|
541
|
+
z.symbol(),
|
|
542
|
+
// Special types for "to satisfy" semantics
|
|
543
|
+
z.instanceof(RegExp), // For pattern matching
|
|
544
|
+
z.custom(isExpectItExecutor, {
|
|
545
|
+
message: 'Expected an ExpectItExecutor function (created with expect.it())',
|
|
546
|
+
}), // For nested assertions
|
|
547
|
+
// Recursive structures
|
|
548
|
+
z.array(SatisfyPatternSchema), // Arrays of satisfy patterns
|
|
549
|
+
z.record(z.string(), SatisfyPatternSchema), // Objects with satisfy pattern values
|
|
550
|
+
]))
|
|
551
|
+
.register(BupkisRegistry, { name: 'SatisfyPatternSchema' });
|
|
467
552
|
//# sourceMappingURL=schema.js.map
|
package/dist/esm/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,OAAO,EACL,GAAG,EACH,eAAe,EACf,UAAU,EACV,eAAe,EACf,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,OAAO,EACL,GAAG,EACH,eAAe,EACf,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAQ/C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC;KACjC,MAAM,CAAc,eAAe,CAAC;KACpC,QAAQ,CAAC,cAAc,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAC;KACzD,QAAQ,CAAC,wBAAwB,CAAC,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC;KAC5B,MAAM,CAAqD,UAAU,CAAC;KACtE,QAAQ,CAAC,cAAc,EAAE;IACxB,IAAI,EAAE,gBAAgB;CACvB,CAAC;KACD,QAAQ,CACP,oEAAoE,CACrE,CAAC;AAEJ;;;;;;;;;;;;;;;;;;;;;;GA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAmC,CAAC;KAClE,IAAI,CAAC,GAAG,EAAE,CACT,CAAC,CAAC,KAAK,CAAC;IACN,kBAAkB;IAClB,CAAC,CAAC,MAAM,EAAE;IACV,CAAC,CAAC,MAAM,EAAE;IACV,CAAC,CAAC,OAAO,EAAE;IACX,CAAC,CAAC,IAAI,EAAE;IACR,CAAC,CAAC,SAAS,EAAE;IACb,CAAC,CAAC,MAAM,EAAE;IACV,CAAC,CAAC,MAAM,EAAE;IAEV,2CAA2C;IAC3C,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,uBAAuB;IAC7C,CAAC,CAAC,MAAM,CAAwB,kBAAkB,EAAE;QAClD,OAAO,EACL,kEAAkE;KACrE,CAAC,EAAE,wBAAwB;IAE5B,uBAAuB;IACvB,CAAC,CAAC,KAAK,CAAC,oBAAoB,CAAC,EAAE,6BAA6B;IAC5D,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,oBAAoB,CAAC,EAAE,sCAAsC;CACnF,CAAC,CACH;KACA,QAAQ,CAAC,cAAc,EAAE,EAAE,IAAI,EAAE,sBAAsB,EAAE,CAAC,CAAC"}
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import type { ArrayValues, TupleToUnion, Constructor as TypeFestConstructor, UnionToIntersection } from 'type-fest';
|
|
18
18
|
import type { z } from 'zod/v4';
|
|
19
19
|
import type { AnyAssertion, AnyAsyncAssertion, AnyAsyncAssertions, AnySyncAssertion, AnySyncAssertions, AssertionFunctionAsync, AssertionFunctionSync, AssertionImplFnAsync, AssertionImplFnSync, AssertionImplSchemaAsync, AssertionImplSchemaSync, AssertionPart, AssertionParts, AssertionSchemaAsync, AssertionSchemaSync, AssertionSlot, AssertionSlots, BuiltinAsyncAssertions, BuiltinSyncAssertions, NoNeverTuple, PhraseLiteral, PhraseLiteralChoice, PhraseLiteralChoiceSlot, PhraseLiteralSlot, RawAssertionImplSchemaSync } from './assertion/assertion-types.js';
|
|
20
|
+
import { type kExpectIt } from './constant.js';
|
|
20
21
|
/**
|
|
21
22
|
* Creates a negated version of a tuple of
|
|
22
23
|
* {@link AssertionPart | AssertionParts}.
|
|
@@ -62,7 +63,6 @@ export interface BaseExpect {
|
|
|
62
63
|
*/
|
|
63
64
|
fail: FailFn;
|
|
64
65
|
}
|
|
65
|
-
export type * from './assertion/assertion-types.js';
|
|
66
66
|
/**
|
|
67
67
|
* The main API as returned by a {@link UseFn}.
|
|
68
68
|
*
|
|
@@ -102,6 +102,7 @@ export interface Bupkis<BaseSyncAssertions extends AnySyncAssertions, BaseAsyncA
|
|
|
102
102
|
*/
|
|
103
103
|
use: UseFn<Concat<BaseSyncAssertions, ExtendedSyncAssertions>, Concat<BaseAsyncAssertions, ExtendedAsyncAssertions>>;
|
|
104
104
|
}
|
|
105
|
+
export type * from './assertion/assertion-types.js';
|
|
105
106
|
/**
|
|
106
107
|
* Helper type to concatenate two tuples
|
|
107
108
|
*/
|
|
@@ -166,14 +167,7 @@ export interface CreateAsyncAssertionFn {
|
|
|
166
167
|
* @returns New `AssertionFunctionAsync` object
|
|
167
168
|
*/
|
|
168
169
|
<const Parts extends AssertionParts, Impl extends AssertionImplFnAsync<Parts>, Slots extends AssertionSlots<Parts>>(parts: Parts, impl: Impl): AssertionFunctionAsync<Parts, Impl, Slots>;
|
|
169
|
-
}
|
|
170
|
-
* @template BaseSyncAssertions Base set of synchronous
|
|
171
|
-
* {@link Assertion | Assertions}; will be the builtin sync assertions, at
|
|
172
|
-
* minimum)
|
|
173
|
-
* @template BaseAsyncAssertions Base set of asynchronous
|
|
174
|
-
* {@link Assertion | Assertions}; will be the builtin async assertions, at
|
|
175
|
-
* minimum)
|
|
176
|
-
*/
|
|
170
|
+
}
|
|
177
171
|
/**
|
|
178
172
|
* The main synchronous assertion function.
|
|
179
173
|
*
|
|
@@ -269,6 +263,112 @@ export interface ExpectAsyncProps<AsyncAssertions extends AnyAsyncAssertions, Sy
|
|
|
269
263
|
export type ExpectFunction<SyncAssertions extends AnySyncAssertions = BuiltinSyncAssertions> = UnionToIntersection<TupleToUnion<{
|
|
270
264
|
[K in keyof SyncAssertions]: SyncAssertions[K] extends AnySyncAssertion ? (...args: MutableOrReadonly<SlotsFromParts<SyncAssertions[K]['parts']>>) => void : never;
|
|
271
265
|
}>>;
|
|
266
|
+
/**
|
|
267
|
+
* Creates embeddable assertion functions that can be used with `to satisfy`.
|
|
268
|
+
*
|
|
269
|
+
* This type generates a union of all possible `expect.it` function signatures
|
|
270
|
+
* based on the available synchronous assertions. Each assertion contributes its
|
|
271
|
+
* own function signature to create embeddable executors that can be used within
|
|
272
|
+
* object patterns for complex validation scenarios.
|
|
273
|
+
*
|
|
274
|
+
* The resulting functions are designed to be used exclusively within `'to
|
|
275
|
+
* satisfy'` assertion contexts, where they provide type-safe pattern matching
|
|
276
|
+
* for nested object structures. Direct execution of these functions outside of
|
|
277
|
+
* their intended context is not supported.
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
*
|
|
281
|
+
* ```typescript
|
|
282
|
+
* // Create embeddable assertion functions
|
|
283
|
+
* const isString = expect.it('to be a string');
|
|
284
|
+
* const isPositive = expect.it('to be greater than', 0);
|
|
285
|
+
*
|
|
286
|
+
* // Use within 'to satisfy' patterns
|
|
287
|
+
* expect(user, 'to satisfy', {
|
|
288
|
+
* name: isString,
|
|
289
|
+
* age: isPositive,
|
|
290
|
+
* email: /\S+@\S+/,
|
|
291
|
+
* });
|
|
292
|
+
* ```
|
|
293
|
+
*
|
|
294
|
+
* @template SyncAssertions - Array of synchronous assertion objects that define
|
|
295
|
+
* the available assertion logic for embeddable functions
|
|
296
|
+
* @see {@link ExpectItFunction} for individual function signature generation
|
|
297
|
+
* @see {@link ExpectItExecutor} for the executor function interface
|
|
298
|
+
*/
|
|
299
|
+
export type ExpectIt<SyncAssertions extends AnySyncAssertions = BuiltinSyncAssertions> = UnionToIntersection<TupleToUnion<{
|
|
300
|
+
[K in keyof SyncAssertions]: SyncAssertions[K] extends AnySyncAssertion ? SyncAssertions[K]['parts'] extends AssertionParts ? ExpectItFunction<SyncAssertions[K]['parts']> : never : never;
|
|
301
|
+
}>>;
|
|
302
|
+
/**
|
|
303
|
+
* Interface for executor functions created by `expect.it()`.
|
|
304
|
+
*
|
|
305
|
+
* ExpectItExecutor functions are the result of calling `expect.it()` with
|
|
306
|
+
* assertion parameters. They encapsulate the assertion logic and can be
|
|
307
|
+
* executed later within `'to satisfy'` pattern matching contexts. These
|
|
308
|
+
* functions are marked with an internal symbol to distinguish them from regular
|
|
309
|
+
* functions during pattern validation.
|
|
310
|
+
*
|
|
311
|
+
* The executor accepts a subject value and performs the embedded assertion
|
|
312
|
+
* logic against it. The subject type is constrained by the Zod schema that
|
|
313
|
+
* represents the first part of the assertion definition, ensuring type safety
|
|
314
|
+
* during pattern matching.
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
*
|
|
318
|
+
* ```typescript
|
|
319
|
+
* const isStringExecutor = expect.it('to be a string');
|
|
320
|
+
* // isStringExecutor is an ExpectItExecutor<z.ZodString>
|
|
321
|
+
*
|
|
322
|
+
* // Used within satisfy patterns
|
|
323
|
+
* expect({ name: 'Alice' }, 'to satisfy', {
|
|
324
|
+
* name: isStringExecutor, // Validates that name is a string
|
|
325
|
+
* });
|
|
326
|
+
* ```
|
|
327
|
+
*
|
|
328
|
+
* @template Subject - The Zod schema type that constrains the subject parameter
|
|
329
|
+
* @see {@link ExpectItFunction} for the factory function that creates executors
|
|
330
|
+
*/
|
|
331
|
+
export interface ExpectItExecutor<Subject extends z.ZodType> {
|
|
332
|
+
(subject: z.infer<Subject>): void;
|
|
333
|
+
[kExpectIt]: true;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Function signature for creating ExpectItExecutor instances.
|
|
337
|
+
*
|
|
338
|
+
* This type represents the factory function that creates embeddable assertion
|
|
339
|
+
* executors from assertion parts. It takes the assertion parameters (excluding
|
|
340
|
+
* the subject) and returns an executor function that can be embedded within
|
|
341
|
+
* `'to satisfy'` patterns.
|
|
342
|
+
*
|
|
343
|
+
* The function signature is derived from assertion parts by removing the first
|
|
344
|
+
* part (which becomes the subject type for the executor) and using the
|
|
345
|
+
* remaining parts as parameters. This allows for natural language assertion
|
|
346
|
+
* creation that mirrors the main `expect()` function but produces reusable
|
|
347
|
+
* executor functions.
|
|
348
|
+
*
|
|
349
|
+
* The resulting executor is constrained to only work with subjects that match
|
|
350
|
+
* the first assertion part, providing compile-time type safety for pattern
|
|
351
|
+
* matching scenarios.
|
|
352
|
+
*
|
|
353
|
+
* @example
|
|
354
|
+
*
|
|
355
|
+
* ```typescript
|
|
356
|
+
* // For assertion parts: [z.string(), 'to match', z.instanceof(RegExp)]
|
|
357
|
+
* // Results in function: (pattern: RegExp) => ExpectItExecutor<z.ZodString>
|
|
358
|
+
* const matchesPattern = expect.it('to match', /^[A-Z]/);
|
|
359
|
+
*
|
|
360
|
+
* expect({ code: 'ABC123' }, 'to satisfy', {
|
|
361
|
+
* code: matchesPattern, // Validates that code matches the pattern
|
|
362
|
+
* });
|
|
363
|
+
* ```
|
|
364
|
+
*
|
|
365
|
+
* @template Parts - Tuple of assertion parts that define the function signature
|
|
366
|
+
* and executor constraints
|
|
367
|
+
* @see {@link ExpectItExecutor} for the returned executor interface
|
|
368
|
+
* @see {@link TupleTail} for parameter extraction from assertion parts
|
|
369
|
+
* @see {@link SlotsFromParts} for type slot generation
|
|
370
|
+
*/
|
|
371
|
+
export type ExpectItFunction<Parts extends AssertionParts> = (...args: MutableOrReadonly<TupleTail<SlotsFromParts<Parts>>>) => Parts[0] extends z.ZodType ? ExpectItExecutor<Parts[0]> : never;
|
|
272
372
|
/**
|
|
273
373
|
* Properties of {@link expect}.
|
|
274
374
|
*/
|
|
@@ -279,6 +379,7 @@ export interface ExpectSyncProps<SyncAssertions extends AnySyncAssertions, Async
|
|
|
279
379
|
* @preventExpand
|
|
280
380
|
*/
|
|
281
381
|
assertions: SyncAssertions;
|
|
382
|
+
it: ExpectIt<SyncAssertions>;
|
|
282
383
|
/**
|
|
283
384
|
* Function to add more assertions to this `expect()`, returning a new
|
|
284
385
|
* `expect()` and `expectAsync()` pair with the combined assertions.
|
|
@@ -430,6 +531,9 @@ export type MutableOrReadonly<Tuple extends readonly unknown[]> = Tuple extends
|
|
|
430
531
|
* @see {@link MapExpectSlots} for how negation is incorporated into function signatures
|
|
431
532
|
*/
|
|
432
533
|
export type Negation<S extends string> = `not ${S}`;
|
|
534
|
+
export type SatisfyPatternValue = bigint | boolean | ExpectItExecutor<any> | Map<SatisfyPatternValue, SatisfyPatternValue> | null | number | RegExp | SatisfyPatternValue[] | Set<SatisfyPatternValue> | string | symbol | undefined | WeakMap<Extract<SatisfyPatternValue, object>, SatisfyPatternValue> | WeakSet<Extract<SatisfyPatternValue, object>> | {
|
|
535
|
+
[key: string]: SatisfyPatternValue;
|
|
536
|
+
};
|
|
433
537
|
/**
|
|
434
538
|
* Converts AssertionParts to complete function parameter types for expect
|
|
435
539
|
* functions.
|
|
@@ -469,6 +573,26 @@ export type Negation<S extends string> = `not ${S}`;
|
|
|
469
573
|
* @see {@link NoNeverTuple} for never-type filtering
|
|
470
574
|
*/
|
|
471
575
|
export type SlotsFromParts<Parts extends AssertionParts> = NoNeverTuple<Parts extends readonly [infer First extends AssertionPart, ...infer _] ? First extends PhraseLiteral | PhraseLiteralChoice ? [unknown, ...MapExpectSlots<Parts>] : MapExpectSlots<Parts> : never>;
|
|
576
|
+
/**
|
|
577
|
+
* Gets the tail (all elements except the first) of a tuple type.
|
|
578
|
+
*
|
|
579
|
+
* Unlike ArrayTail from type-fest, this preserves the tuple structure as a
|
|
580
|
+
* readonly tuple rather than converting to an array type.
|
|
581
|
+
*
|
|
582
|
+
* @example
|
|
583
|
+
*
|
|
584
|
+
* ```typescript
|
|
585
|
+
* type Example = TupleTail<readonly [string, number, boolean]>; // readonly [number, boolean]
|
|
586
|
+
* type Single = TupleTail<readonly [string]>; // readonly []
|
|
587
|
+
* type Empty = TupleTail<readonly []>; // readonly []
|
|
588
|
+
* ```
|
|
589
|
+
*
|
|
590
|
+
* @template T - The tuple type to get the tail of
|
|
591
|
+
*/
|
|
592
|
+
export type TupleTail<T extends readonly unknown[]> = T extends readonly [
|
|
593
|
+
unknown,
|
|
594
|
+
...infer Rest
|
|
595
|
+
] ? Rest : readonly [];
|
|
472
596
|
/**
|
|
473
597
|
* The type of a `use()` function.
|
|
474
598
|
*/
|
|
@@ -486,4 +610,42 @@ export interface UseFn<BaseSyncAssertions extends AnySyncAssertions, BaseAsyncAs
|
|
|
486
610
|
*/
|
|
487
611
|
<MixedAssertions extends readonly AnyAssertion[], ExtendedSyncAssertions extends FilterSyncAssertions<MixedAssertions>, ExtendedAsyncAssertions extends FilterAsyncAssertions<MixedAssertions>>(assertions: MixedAssertions): Bupkis<BaseSyncAssertions, BaseAsyncAssertions, ExtendedSyncAssertions, ExtendedAsyncAssertions>;
|
|
488
612
|
}
|
|
613
|
+
/**
|
|
614
|
+
* Maps Zod `def.type` strings to their corresponding ZodType classes.
|
|
615
|
+
*
|
|
616
|
+
* This allows for type-safe discrimination of ZodTypes based on their internal
|
|
617
|
+
* `def.type` property in Zod v4.
|
|
618
|
+
*/
|
|
619
|
+
export interface ZodTypeMap {
|
|
620
|
+
any: z.ZodAny;
|
|
621
|
+
array: z.ZodArray<any>;
|
|
622
|
+
bigint: z.ZodBigInt;
|
|
623
|
+
boolean: z.ZodBoolean;
|
|
624
|
+
catch: z.ZodCatch<any>;
|
|
625
|
+
date: z.ZodDate;
|
|
626
|
+
default: z.ZodDefault<any>;
|
|
627
|
+
enum: z.ZodEnum<any>;
|
|
628
|
+
function: z.ZodFunction<any, any>;
|
|
629
|
+
lazy: z.ZodLazy<any>;
|
|
630
|
+
literal: z.ZodLiteral<any>;
|
|
631
|
+
map: z.ZodMap<any, any>;
|
|
632
|
+
never: z.ZodNever;
|
|
633
|
+
null: z.ZodNull;
|
|
634
|
+
nullable: z.ZodNullable<any>;
|
|
635
|
+
number: z.ZodNumber;
|
|
636
|
+
object: z.ZodObject<any>;
|
|
637
|
+
optional: z.ZodOptional<any>;
|
|
638
|
+
pipe: z.ZodPipe<any, any>;
|
|
639
|
+
promise: z.ZodPromise<any>;
|
|
640
|
+
readonly: z.ZodReadonly<any>;
|
|
641
|
+
record: z.ZodRecord<any, any>;
|
|
642
|
+
set: z.ZodSet<any>;
|
|
643
|
+
string: z.ZodString;
|
|
644
|
+
symbol: z.ZodSymbol;
|
|
645
|
+
tuple: z.ZodTuple<any>;
|
|
646
|
+
undefined: z.ZodUndefined;
|
|
647
|
+
union: z.ZodUnion<any>;
|
|
648
|
+
unknown: z.ZodUnknown;
|
|
649
|
+
void: z.ZodVoid;
|
|
650
|
+
}
|
|
489
651
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/esm/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,WAAW,IAAI,mBAAmB,EAClC,mBAAmB,EACpB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EAGjB,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,EACxB,uBAAuB,EACvB,aAAa,EACb,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,qBAAqB,EACrB,YAAY,EACZ,aAAa,EACb,mBAAmB,E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
|
|
1
|
-
{"version":3,"file":"use.d.ts","sourceRoot":"","sources":["../../src/use.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACvB,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"use.d.ts","sourceRoot":"","sources":["../../src/use.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACvB,MAAM,gCAAgC,CAAC;AAOxC,OAAO,EAKL,KAAK,KAAK,EACX,MAAM,YAAY,CAAC;AAqBpB,wBAAgB,SAAS,CACvB,KAAK,CAAC,CAAC,SAAS,iBAAiB,EACjC,KAAK,CAAC,CAAC,SAAS,kBAAkB,EAClC,cAAc,EAAE,CAAC,EAAE,eAAe,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CA8CpD"}
|
package/dist/esm/use.js
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import { BupkisAssertionAsync } from './assertion/assertion-async.js';
|
|
2
2
|
import { BupkisAssertionSync } from './assertion/assertion-sync.js';
|
|
3
|
+
import { kExpectIt } from './constant.js';
|
|
3
4
|
import { createBaseExpect, createExpectAsyncFunction, createExpectSyncFunction, } from './expect.js';
|
|
5
|
+
const createExpectIt = (expect) => {
|
|
6
|
+
const expectIt = (...args) => {
|
|
7
|
+
const func = Object.assign((subject) => {
|
|
8
|
+
const allArgs = [subject, ...args];
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
10
|
+
expect(...allArgs);
|
|
11
|
+
}, {
|
|
12
|
+
[kExpectIt]: true,
|
|
13
|
+
});
|
|
14
|
+
return func;
|
|
15
|
+
};
|
|
16
|
+
return expectIt;
|
|
17
|
+
};
|
|
4
18
|
export function createUse(syncAssertions, asyncAssertions) {
|
|
5
19
|
const syncAssertionsIn = syncAssertions ?? [];
|
|
6
20
|
const asyncAssertionsIn = asyncAssertions ?? [];
|
|
@@ -17,7 +31,7 @@ export function createUse(syncAssertions, asyncAssertions) {
|
|
|
17
31
|
];
|
|
18
32
|
const expectFunction = createExpectSyncFunction(allSyncAssertions);
|
|
19
33
|
const expectAsyncFunction = createExpectAsyncFunction(allAsyncAssertions);
|
|
20
|
-
const expect = Object.assign(expectFunction, createBaseExpect(allSyncAssertions, allAsyncAssertions, 'sync'));
|
|
34
|
+
const expect = Object.assign(expectFunction, createBaseExpect(allSyncAssertions, allAsyncAssertions, 'sync'), { it: createExpectIt(expectFunction) });
|
|
21
35
|
const expectAsync = Object.assign(expectAsyncFunction, createBaseExpect(allSyncAssertions, allAsyncAssertions, 'async'));
|
|
22
36
|
return {
|
|
23
37
|
expect,
|
package/dist/esm/use.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use.js","sourceRoot":"","sources":["../../src/use.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAMpE,OAAO,EACL,gBAAgB,EAChB,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"use.js","sourceRoot":"","sources":["../../src/use.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAMpE,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EACL,gBAAgB,EAChB,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AASrB,MAAM,cAAc,GAAG,CACrB,MAAW,EACe,EAAE;IAC5B,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAwB,EAAE,EAAE;QAC/C,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CACxB,CAAC,OAAgB,EAAE,EAAE;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