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/commonjs/schema.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* This module provides reusable Zod schemas for validating constructors,
|
|
6
6
|
* functions, property keys, promises, and other common JavaScript types used
|
|
7
|
-
* throughout the assertion system. These tend to work around the
|
|
7
|
+
* throughout the assertion system. These tend to work around the impedance
|
|
8
8
|
* mismatch between **BUPKIS** and Zod.
|
|
9
9
|
*
|
|
10
10
|
* These are used internally, but consumers may also find them useful.
|
|
@@ -33,41 +33,41 @@
|
|
|
33
33
|
* @packageDocumentation
|
|
34
34
|
*/
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.RegExpSchema = exports.ArrayLikeSchema = exports.PrimitiveSchema = exports.FalsySchema = exports.TruthySchema = exports.AsyncFunctionSchema = exports.NullProtoObjectSchema = exports.StrongSetSchema = exports.StrongMapSchema = exports.WrappedPromiseLikeSchema = exports.PropertyKeySchema = exports.FunctionSchema = exports.
|
|
36
|
+
exports.SatisfyPatternSchema = exports.RegExpSchema = exports.ArrayLikeSchema = exports.PrimitiveSchema = exports.FalsySchema = exports.TruthySchema = exports.AsyncFunctionSchema = exports.NullProtoObjectSchema = exports.DictionarySchema = exports.StrongSetSchema = exports.StrongMapSchema = exports.WrappedPromiseLikeSchema = exports.PropertyKeySchema = exports.FunctionSchema = exports.ConstructibleSchema = void 0;
|
|
37
37
|
const v4_1 = require("zod/v4");
|
|
38
38
|
const guards_js_1 = require("./guards.js");
|
|
39
39
|
const metadata_js_1 = require("./metadata.js");
|
|
40
40
|
/**
|
|
41
|
-
* A Zod schema that validates JavaScript
|
|
41
|
+
* A Zod schema that validates JavaScript constructible functions.
|
|
42
42
|
*
|
|
43
43
|
* This schema validates values that can be used as constructors, including ES6
|
|
44
44
|
* classes, traditional constructor functions, and built-in constructors. It
|
|
45
|
-
* uses the {@link
|
|
45
|
+
* uses the {@link isConstructible} guard function to determine if a value can be
|
|
46
46
|
* invoked with the `new` operator to create object instances.
|
|
47
47
|
*
|
|
48
48
|
* @privateRemarks
|
|
49
49
|
* The schema is registered in the {@link BupkisRegistry} with the name
|
|
50
|
-
* `
|
|
50
|
+
* `ConstructibleSchema` for later reference and type checking purposes.
|
|
51
51
|
* @example
|
|
52
52
|
*
|
|
53
53
|
* ```typescript
|
|
54
54
|
* class MyClass {}
|
|
55
55
|
* function MyConstructor() {}
|
|
56
56
|
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
57
|
+
* ConstructibleSchema.parse(MyClass); // ✓ Valid
|
|
58
|
+
* ConstructibleSchema.parse(MyConstructor); // ✓ Valid
|
|
59
|
+
* ConstructibleSchema.parse(Array); // ✓ Valid
|
|
60
|
+
* ConstructibleSchema.parse(Date); // ✓ Valid
|
|
61
|
+
* ConstructibleSchema.parse(() => {}); // ✗ Throws validation error
|
|
62
|
+
* ConstructibleSchema.parse({}); // ✗ Throws validation error
|
|
63
63
|
* ```
|
|
64
64
|
*
|
|
65
65
|
* @group Schema
|
|
66
66
|
*/
|
|
67
|
-
exports.
|
|
68
|
-
.custom(guards_js_1.
|
|
69
|
-
.register(metadata_js_1.BupkisRegistry, { name: '
|
|
70
|
-
.describe('
|
|
67
|
+
exports.ConstructibleSchema = v4_1.z
|
|
68
|
+
.custom(guards_js_1.isConstructible)
|
|
69
|
+
.register(metadata_js_1.BupkisRegistry, { name: 'ConstructibleSchema' })
|
|
70
|
+
.describe('Constructible Function');
|
|
71
71
|
/**
|
|
72
72
|
* A Zod schema that validates any JavaScript function.
|
|
73
73
|
*
|
|
@@ -224,9 +224,12 @@ exports.StrongSetSchema = v4_1.z
|
|
|
224
224
|
* `Object.prototype`, making them useful as pure data containers or
|
|
225
225
|
* dictionaries.
|
|
226
226
|
*
|
|
227
|
-
* @
|
|
227
|
+
* @privateRemarks
|
|
228
228
|
* The schema is registered in the `BupkisRegistry` with the name
|
|
229
229
|
* `ObjectWithNullPrototype` for later reference and type checking purposes.
|
|
230
|
+
*
|
|
231
|
+
* Changing this to be a `ZodRecord` would be nice, but that would end up
|
|
232
|
+
* blasting away the original object's prototype.
|
|
230
233
|
* @example
|
|
231
234
|
*
|
|
232
235
|
* ```typescript
|
|
@@ -242,11 +245,18 @@ exports.StrongSetSchema = v4_1.z
|
|
|
242
245
|
* ```
|
|
243
246
|
*
|
|
244
247
|
* @group Schema
|
|
248
|
+
* @see Aliases: {@link NullProtoObjectSchema}, {@link DictionarySchema}
|
|
245
249
|
*/
|
|
246
|
-
exports.
|
|
250
|
+
exports.DictionarySchema = v4_1.z
|
|
247
251
|
.custom((value) => (0, guards_js_1.isNonNullObject)(value) && Object.getPrototypeOf(value) === null)
|
|
248
252
|
.describe('Object with null prototype')
|
|
249
253
|
.register(metadata_js_1.BupkisRegistry, { name: 'ObjectWithNullPrototype' });
|
|
254
|
+
/**
|
|
255
|
+
* {@inheritDoc DictionarySchema}
|
|
256
|
+
*
|
|
257
|
+
* @group Schema
|
|
258
|
+
*/
|
|
259
|
+
exports.NullProtoObjectSchema = exports.DictionarySchema;
|
|
250
260
|
/**
|
|
251
261
|
* A Zod schema that validates functions declared with the `async` keyword.
|
|
252
262
|
*
|
|
@@ -255,7 +265,7 @@ exports.NullProtoObjectSchema = v4_1.z
|
|
|
255
265
|
* function's internal `[[ToString]]` representation to distinguish async
|
|
256
266
|
* functions from regular functions that might return Promises.
|
|
257
267
|
*
|
|
258
|
-
* @
|
|
268
|
+
* @privateRemarks
|
|
259
269
|
* The schema is registered in the `BupkisRegistry` with the name
|
|
260
270
|
* `AsyncFunctionSchema` for later reference and type checking purposes. This
|
|
261
271
|
* schema cannot reliably detect functions that return Promises but are not
|
|
@@ -294,7 +304,7 @@ exports.AsyncFunctionSchema = exports.FunctionSchema.refine((value) => Object.pr
|
|
|
294
304
|
* if it converts to `true` when evaluated in a boolean context - essentially
|
|
295
305
|
* any value that is not one of the eight falsy values.
|
|
296
306
|
*
|
|
297
|
-
* @
|
|
307
|
+
* @privateRemarks
|
|
298
308
|
* The schema is registered in the `BupkisRegistry` with the name `Truthy` and
|
|
299
309
|
* indicates that it accepts anything as valid input for evaluation.
|
|
300
310
|
* @example
|
|
@@ -329,7 +339,7 @@ exports.TruthySchema = v4_1.z
|
|
|
329
339
|
* in JavaScript are: `false`, `0`, `-0`, `0n`, `""` (empty string), `null`,
|
|
330
340
|
* `undefined`, and `NaN`.
|
|
331
341
|
*
|
|
332
|
-
* @
|
|
342
|
+
* @privateRemarks
|
|
333
343
|
* The schema is registered in the `BupkisRegistry` with the name `Falsy` and
|
|
334
344
|
* indicates that it accepts anything as valid input for evaluation.
|
|
335
345
|
* @example
|
|
@@ -366,7 +376,7 @@ exports.FalsySchema = v4_1.z
|
|
|
366
376
|
* distinguishing them from objects and functions which are non-primitive
|
|
367
377
|
* reference types.
|
|
368
378
|
*
|
|
369
|
-
* @
|
|
379
|
+
* @privateRemarks
|
|
370
380
|
* The schema is registered in the `BupkisRegistry` with the name `Primitive`
|
|
371
381
|
* and indicates that it accepts primitive values as valid input.
|
|
372
382
|
* @example
|
|
@@ -446,7 +456,7 @@ exports.ArrayLikeSchema = v4_1.z
|
|
|
446
456
|
* It ensures the validated value is a proper regular expression object with all
|
|
447
457
|
* associated methods and properties.
|
|
448
458
|
*
|
|
449
|
-
* @
|
|
459
|
+
* @privateRemarks
|
|
450
460
|
* The schema is registered in the `BupkisRegistry` with the name `RegExp` for
|
|
451
461
|
* later reference and type checking purposes.
|
|
452
462
|
* @example
|
|
@@ -467,4 +477,79 @@ exports.RegExpSchema = v4_1.z
|
|
|
467
477
|
.instanceof(RegExp)
|
|
468
478
|
.describe('A RegExp instance')
|
|
469
479
|
.register(metadata_js_1.BupkisRegistry, { name: 'RegExp' });
|
|
480
|
+
/**
|
|
481
|
+
* A recursive Zod schema that validates values allowed in "to satisfy"
|
|
482
|
+
* assertion patterns.
|
|
483
|
+
*
|
|
484
|
+
* This schema defines the allowed structure for patterns used with "to satisfy"
|
|
485
|
+
* and "to be like" assertions. It supports a recursive structure that can
|
|
486
|
+
* contain:
|
|
487
|
+
*
|
|
488
|
+
* - **Primitive values**: strings, numbers, booleans, null, undefined, bigint,
|
|
489
|
+
* symbols
|
|
490
|
+
* - **Regular expressions**: for pattern matching against string values
|
|
491
|
+
* - **ExpectItExecutor functions**: nested assertions created via `expect.it()`
|
|
492
|
+
* - **Objects**: with properties that recursively follow this same pattern
|
|
493
|
+
* - **Arrays**: with elements that recursively follow this same pattern
|
|
494
|
+
*
|
|
495
|
+
* The schema handles the special semantics required for "to satisfy"
|
|
496
|
+
* assertions:
|
|
497
|
+
*
|
|
498
|
+
* - RegExp values are used for pattern testing rather than exact matching
|
|
499
|
+
* - ExpectItExecutor functions are executed as nested assertions
|
|
500
|
+
* - Objects and arrays can contain any combination of the above recursively
|
|
501
|
+
*
|
|
502
|
+
* @privateRemarks
|
|
503
|
+
* Uses `z.lazy()` to handle recursive object and array structures without
|
|
504
|
+
* causing infinite recursion during schema definition. The schema is registered
|
|
505
|
+
* in the `BupkisRegistry` for reference and type checking.
|
|
506
|
+
* @example
|
|
507
|
+
*
|
|
508
|
+
* ```typescript
|
|
509
|
+
* // Primitive values
|
|
510
|
+
* SatisfyPatternSchema.parse('hello'); // ✓ Valid
|
|
511
|
+
* SatisfyPatternSchema.parse(42); // ✓ Valid
|
|
512
|
+
* SatisfyPatternSchema.parse(true); // ✓ Valid
|
|
513
|
+
*
|
|
514
|
+
* // Regular expressions for pattern matching
|
|
515
|
+
* SatisfyPatternSchema.parse(/test/); // ✓ Valid
|
|
516
|
+
*
|
|
517
|
+
* // ExpectItExecutor functions
|
|
518
|
+
* SatisfyPatternSchema.parse(expect.it('to be a string')); // ✓ Valid
|
|
519
|
+
*
|
|
520
|
+
* // Complex nested structures
|
|
521
|
+
* SatisfyPatternSchema.parse({
|
|
522
|
+
* name: expect.it('to be a string'),
|
|
523
|
+
* email: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
|
|
524
|
+
* age: expect.it('to be greater than', 0),
|
|
525
|
+
* tags: [expect.it('to be a string')],
|
|
526
|
+
* }); // ✓ Valid
|
|
527
|
+
*
|
|
528
|
+
* // Invalid values
|
|
529
|
+
* SatisfyPatternSchema.parse(new Date()); // ✗ Invalid (not supported type)
|
|
530
|
+
* SatisfyPatternSchema.parse(() => {}); // ✗ Invalid (regular function, not ExpectItExecutor)
|
|
531
|
+
* ```
|
|
532
|
+
*
|
|
533
|
+
* @group Schema
|
|
534
|
+
*/
|
|
535
|
+
exports.SatisfyPatternSchema = v4_1.z
|
|
536
|
+
.lazy(() => v4_1.z.union([
|
|
537
|
+
// Primitive types
|
|
538
|
+
v4_1.z.string(),
|
|
539
|
+
v4_1.z.number(),
|
|
540
|
+
v4_1.z.boolean(),
|
|
541
|
+
v4_1.z.null(),
|
|
542
|
+
v4_1.z.undefined(),
|
|
543
|
+
v4_1.z.bigint(),
|
|
544
|
+
v4_1.z.symbol(),
|
|
545
|
+
// Special types for "to satisfy" semantics
|
|
546
|
+
v4_1.z.instanceof(RegExp), // For pattern matching
|
|
547
|
+
v4_1.z.custom(guards_js_1.isExpectItExecutor, {
|
|
548
|
+
message: 'Expected an ExpectItExecutor function (created with expect.it())',
|
|
549
|
+
}), // For nested assertions
|
|
550
|
+
// Recursive structures
|
|
551
|
+
v4_1.z.array(exports.SatisfyPatternSchema), // Arrays of satisfy patterns
|
|
552
|
+
v4_1.z.record(v4_1.z.string(), exports.SatisfyPatternSchema), // Objects with satisfy pattern values
|
|
553
|
+
]))
|
|
554
|
+
.register(metadata_js_1.BupkisRegistry, { name: 'SatisfyPatternSchema' });
|
|
470
555
|
//# sourceMappingURL=schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/schema.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;;;AAEH,+BAA2B;AAE3B,
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/schema.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;;;AAEH,+BAA2B;AAE3B,2CAOqB;AACrB,+CAA+C;AAQ/C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEU,QAAA,mBAAmB,GAAG,MAAC;KACjC,MAAM,CAAc,2BAAe,CAAC;KACpC,QAAQ,CAAC,4BAAc,E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AAEL;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACU,QAAA,YAAY,GAAG,MAAC;KAC1B,UAAU,CAAC,MAAM,CAAC;KAClB,QAAQ,CAAC,mBAAmB,CAAC;KAC7B,QAAQ,CAAC,4BAAc,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACU,QAAA,oBAAoB,GAAmC,MAAC;KAClE,IAAI,CAAC,GAAG,EAAE,CACT,MAAC,CAAC,KAAK,CAAC;IACN,kBAAkB;IAClB,MAAC,CAAC,MAAM,EAAE;IACV,MAAC,CAAC,MAAM,EAAE;IACV,MAAC,CAAC,OAAO,EAAE;IACX,MAAC,CAAC,IAAI,EAAE;IACR,MAAC,CAAC,SAAS,EAAE;IACb,MAAC,CAAC,MAAM,EAAE;IACV,MAAC,CAAC,MAAM,EAAE;IAEV,2CAA2C;IAC3C,MAAC,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,uBAAuB;IAC7C,MAAC,CAAC,MAAM,CAAwB,8BAAkB,EAAE;QAClD,OAAO,EACL,kEAAkE;KACrE,CAAC,EAAE,wBAAwB;IAE5B,uBAAuB;IACvB,MAAC,CAAC,KAAK,CAAC,4BAAoB,CAAC,EAAE,6BAA6B;IAC5D,MAAC,CAAC,MAAM,CAAC,MAAC,CAAC,MAAM,EAAE,EAAE,4BAAoB,CAAC,EAAE,sCAAsC;CACnF,CAAC,CACH;KACA,QAAQ,CAAC,4BAAc,EAAE,EAAE,IAAI,EAAE,sBAAsB,EAAE,CAAC,CAAC"}
|
package/dist/commonjs/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
|
|
@@ -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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K,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACvB,OAAO,EAAE,CAAC,CAAC,UAAU,CAAC;IACtB,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC;CACjB"}
|
|
@@ -1 +1 @@
|
|
|
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/commonjs/use.js
CHANGED
|
@@ -3,7 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createUse = createUse;
|
|
4
4
|
const assertion_async_js_1 = require("./assertion/assertion-async.js");
|
|
5
5
|
const assertion_sync_js_1 = require("./assertion/assertion-sync.js");
|
|
6
|
+
const constant_js_1 = require("./constant.js");
|
|
6
7
|
const expect_js_1 = require("./expect.js");
|
|
8
|
+
const createExpectIt = (expect) => {
|
|
9
|
+
const expectIt = (...args) => {
|
|
10
|
+
const func = Object.assign((subject) => {
|
|
11
|
+
const allArgs = [subject, ...args];
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
13
|
+
expect(...allArgs);
|
|
14
|
+
}, {
|
|
15
|
+
[constant_js_1.kExpectIt]: true,
|
|
16
|
+
});
|
|
17
|
+
return func;
|
|
18
|
+
};
|
|
19
|
+
return expectIt;
|
|
20
|
+
};
|
|
7
21
|
function createUse(syncAssertions, asyncAssertions) {
|
|
8
22
|
const syncAssertionsIn = syncAssertions ?? [];
|
|
9
23
|
const asyncAssertionsIn = asyncAssertions ?? [];
|
|
@@ -20,7 +34,7 @@ function createUse(syncAssertions, asyncAssertions) {
|
|
|
20
34
|
];
|
|
21
35
|
const expectFunction = (0, expect_js_1.createExpectSyncFunction)(allSyncAssertions);
|
|
22
36
|
const expectAsyncFunction = (0, expect_js_1.createExpectAsyncFunction)(allAsyncAssertions);
|
|
23
|
-
const expect = Object.assign(expectFunction, (0, expect_js_1.createBaseExpect)(allSyncAssertions, allAsyncAssertions, 'sync'));
|
|
37
|
+
const expect = Object.assign(expectFunction, (0, expect_js_1.createBaseExpect)(allSyncAssertions, allAsyncAssertions, 'sync'), { it: createExpectIt(expectFunction) });
|
|
24
38
|
const expectAsync = Object.assign(expectAsyncFunction, (0, expect_js_1.createBaseExpect)(allSyncAssertions, allAsyncAssertions, 'async'));
|
|
25
39
|
return {
|
|
26
40
|
expect,
|
package/dist/commonjs/use.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use.js","sourceRoot":"","sources":["../../src/use.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"use.js","sourceRoot":"","sources":["../../src/use.ts"],"names":[],"mappings":";;AAwCA,8BAiDC;AAzFD,uEAAsE;AACtE,qEAAoE;AAMpE,+CAA0C;AAC1C,2CAIqB;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;YACnB,MAAM,OAAO,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;YACnC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