@kensio/smartass 1.16.0 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assert/array-includes/array-includes.assert.d.ts +3 -8
- package/dist/assert/array-includes/array-includes.assert.d.ts.map +1 -1
- package/dist/assert/array-includes/array-includes.assert.js.map +1 -1
- package/dist/assert/array-includes/array-includes.match.d.ts +1 -6
- package/dist/assert/array-includes/array-includes.match.d.ts.map +1 -1
- package/dist/assert/array-includes/array-includes.match.js +7 -1
- package/dist/assert/array-includes/array-includes.match.js.map +1 -1
- package/dist/assert/array-includes/array-includes.type.d.ts +44 -0
- package/dist/assert/array-includes/array-includes.type.d.ts.map +1 -0
- package/dist/assert/array-includes/array-includes.type.js +8 -0
- package/dist/assert/array-includes/array-includes.type.js.map +1 -0
- package/dist/assert/array-includes-all/array-includes-all.assert.d.ts +3 -7
- package/dist/assert/array-includes-all/array-includes-all.assert.d.ts.map +1 -1
- package/dist/assert/array-includes-all/array-includes-all.assert.js +27 -5
- package/dist/assert/array-includes-all/array-includes-all.assert.js.map +1 -1
- package/dist/assert/array-includes-all/array-includes-all.match.d.ts +3 -8
- package/dist/assert/array-includes-all/array-includes-all.match.d.ts.map +1 -1
- package/dist/assert/array-includes-all/array-includes-all.match.js +16 -3
- package/dist/assert/array-includes-all/array-includes-all.match.js.map +1 -1
- package/dist/assert/array-includes-all/array-includes-all.type.d.ts +51 -0
- package/dist/assert/array-includes-all/array-includes-all.type.d.ts.map +1 -0
- package/dist/assert/array-includes-all/array-includes-all.type.js +2 -0
- package/dist/assert/array-includes-all/array-includes-all.type.js.map +1 -0
- package/dist/assert/array-length/array-length.assert.d.ts +4 -9
- package/dist/assert/array-length/array-length.assert.d.ts.map +1 -1
- package/dist/assert/array-length/array-length.assert.js +7 -4
- package/dist/assert/array-length/array-length.assert.js.map +1 -1
- package/dist/assert/array-length/array-length.match.d.ts +1 -9
- package/dist/assert/array-length/array-length.match.d.ts.map +1 -1
- package/dist/assert/array-length/array-length.match.js +8 -2
- package/dist/assert/array-length/array-length.match.js.map +1 -1
- package/dist/assert/array-length/array-length.type.d.ts +37 -0
- package/dist/assert/array-length/array-length.type.d.ts.map +1 -0
- package/dist/assert/array-length/array-length.type.js +8 -0
- package/dist/assert/array-length/array-length.type.js.map +1 -0
- package/dist/assert/array-min-length/array-min-length.assert.d.ts +3 -9
- package/dist/assert/array-min-length/array-min-length.assert.d.ts.map +1 -1
- package/dist/assert/array-min-length/array-min-length.assert.js +10 -6
- package/dist/assert/array-min-length/array-min-length.assert.js.map +1 -1
- package/dist/assert/array-min-length/array-min-length.match.d.ts +1 -3
- package/dist/assert/array-min-length/array-min-length.match.d.ts.map +1 -1
- package/dist/assert/array-min-length/array-min-length.match.js +7 -1
- package/dist/assert/array-min-length/array-min-length.match.js.map +1 -1
- package/dist/assert/array-min-length/array-min-length.type.d.ts +35 -0
- package/dist/assert/array-min-length/array-min-length.type.d.ts.map +1 -0
- package/dist/assert/array-min-length/array-min-length.type.js +8 -0
- package/dist/assert/array-min-length/array-min-length.type.js.map +1 -0
- package/dist/assert/array-not-empty/array-not-empty.assert.d.ts +3 -5
- package/dist/assert/array-not-empty/array-not-empty.assert.d.ts.map +1 -1
- package/dist/assert/array-not-empty/array-not-empty.assert.js +8 -3
- package/dist/assert/array-not-empty/array-not-empty.assert.js.map +1 -1
- package/dist/assert/array-not-empty/array-not-empty.match.d.ts +1 -3
- package/dist/assert/array-not-empty/array-not-empty.match.d.ts.map +1 -1
- package/dist/assert/array-not-empty/array-not-empty.match.js +7 -1
- package/dist/assert/array-not-empty/array-not-empty.match.js.map +1 -1
- package/dist/assert/array-not-empty/array-not-empty.type.d.ts +35 -0
- package/dist/assert/array-not-empty/array-not-empty.type.d.ts.map +1 -0
- package/dist/assert/array-not-empty/array-not-empty.type.js +8 -0
- package/dist/assert/array-not-empty/array-not-empty.type.js.map +1 -0
- package/dist/assert/buffer-equal/buffer-equal.assert.d.ts +1 -1
- package/dist/assert/buffer-equal/buffer-equal.assert.d.ts.map +1 -1
- package/dist/assert/buffer-equal/buffer-equal.assert.js.map +1 -1
- package/dist/assert/buffer-equal/buffer-equal.match.d.ts +3 -3
- package/dist/assert/buffer-equal/buffer-equal.match.d.ts.map +1 -1
- package/dist/assert/buffer-equal/buffer-equal.match.js +20 -11
- package/dist/assert/buffer-equal/buffer-equal.match.js.map +1 -1
- package/dist/assert/buffer-equal/buffer-equal.type.d.ts +32 -0
- package/dist/assert/buffer-equal/buffer-equal.type.d.ts.map +1 -0
- package/dist/assert/buffer-equal/buffer-equal.type.js +8 -0
- package/dist/assert/buffer-equal/buffer-equal.type.js.map +1 -0
- package/dist/assert/identical/identical.assert.d.ts +1 -1
- package/dist/assert/identical/identical.assert.d.ts.map +1 -1
- package/dist/assert/instance-of/instance-of.assert.d.ts +3 -5
- package/dist/assert/instance-of/instance-of.assert.d.ts.map +1 -1
- package/dist/assert/instance-of/instance-of.assert.js.map +1 -1
- package/dist/assert/instance-of/instance-of.match.d.ts +2 -3
- package/dist/assert/instance-of/instance-of.match.d.ts.map +1 -1
- package/dist/assert/instance-of/instance-of.match.js +7 -1
- package/dist/assert/instance-of/instance-of.match.js.map +1 -1
- package/dist/assert/instance-of/instance-of.type.d.ts +42 -0
- package/dist/assert/instance-of/instance-of.type.d.ts.map +1 -0
- package/dist/assert/instance-of/instance-of.type.js +8 -0
- package/dist/assert/instance-of/instance-of.type.js.map +1 -0
- package/dist/assert/map-size/map-size.assert.d.ts +4 -0
- package/dist/assert/map-size/map-size.assert.d.ts.map +1 -0
- package/dist/assert/map-size/map-size.assert.js +19 -0
- package/dist/assert/map-size/map-size.assert.js.map +1 -0
- package/dist/assert/map-size/map-size.match.d.ts +6 -0
- package/dist/assert/map-size/map-size.match.d.ts.map +1 -0
- package/dist/assert/map-size/map-size.match.js +15 -0
- package/dist/assert/map-size/map-size.match.js.map +1 -0
- package/dist/assert/map-size/map-size.type.d.ts +33 -0
- package/dist/assert/map-size/map-size.type.d.ts.map +1 -0
- package/dist/assert/map-size/map-size.type.js +8 -0
- package/dist/assert/map-size/map-size.type.js.map +1 -0
- package/dist/assert/non-nullable/non-nullable.match.d.ts +2 -2
- package/dist/assert/non-nullable/non-nullable.match.d.ts.map +1 -1
- package/dist/assert/non-nullable/non-nullable.match.js.map +1 -1
- package/dist/assert/non-nullable/non-nullable.type.d.ts +5 -0
- package/dist/assert/non-nullable/non-nullable.type.d.ts.map +1 -0
- package/dist/assert/non-nullable/non-nullable.type.js +2 -0
- package/dist/assert/non-nullable/non-nullable.type.js.map +1 -0
- package/dist/assert/number-to-nearest/number-to-nearest.assert.d.ts +1 -1
- package/dist/assert/number-to-nearest/number-to-nearest.assert.d.ts.map +1 -1
- package/dist/assert/number-to-nearest/number-to-nearest.assert.js +2 -2
- package/dist/assert/number-to-nearest/number-to-nearest.assert.js.map +1 -1
- package/dist/assert/number-to-nearest/number-to-nearest.match.d.ts +1 -1
- package/dist/assert/number-to-nearest/number-to-nearest.match.d.ts.map +1 -1
- package/dist/assert/number-to-nearest/number-to-nearest.match.js +1 -1
- package/dist/assert/number-to-nearest/number-to-nearest.match.js.map +1 -1
- package/dist/assert/object-has-property/object-has-property.assert.d.ts +3 -6
- package/dist/assert/object-has-property/object-has-property.assert.d.ts.map +1 -1
- package/dist/assert/object-has-property/object-has-property.assert.js +1 -1
- package/dist/assert/object-has-property/object-has-property.assert.js.map +1 -1
- package/dist/assert/object-has-property/object-has-property.match.d.ts +1 -7
- package/dist/assert/object-has-property/object-has-property.match.d.ts.map +1 -1
- package/dist/assert/object-has-property/object-has-property.match.js +1 -1
- package/dist/assert/object-has-property/object-has-property.match.js.map +1 -1
- package/dist/assert/object-has-property/object-has-property.type.d.ts +8 -0
- package/dist/assert/object-has-property/object-has-property.type.d.ts.map +1 -0
- package/dist/assert/object-has-property/object-has-property.type.js +2 -0
- package/dist/assert/object-has-property/object-has-property.type.js.map +1 -0
- package/dist/assert/object-matches/object-matches.assert.d.ts +1 -28
- package/dist/assert/object-matches/object-matches.assert.d.ts.map +1 -1
- package/dist/assert/object-matches/object-matches.assert.js.map +1 -1
- package/dist/assert/object-matches/object-matches.type.d.ts +155 -0
- package/dist/assert/object-matches/object-matches.type.d.ts.map +1 -0
- package/dist/assert/object-matches/object-matches.type.js +2 -0
- package/dist/assert/object-matches/object-matches.type.js.map +1 -0
- package/dist/assert/one-of/one-of.assert.d.ts +5 -3
- package/dist/assert/one-of/one-of.assert.d.ts.map +1 -1
- package/dist/assert/one-of/one-of.assert.js.map +1 -1
- package/dist/assert/one-of/one-of.match.d.ts +2 -2
- package/dist/assert/one-of/one-of.match.d.ts.map +1 -1
- package/dist/assert/one-of/one-of.match.js +7 -1
- package/dist/assert/one-of/one-of.match.js.map +1 -1
- package/dist/assert/one-of/one-of.type.d.ts +33 -0
- package/dist/assert/one-of/one-of.type.d.ts.map +1 -0
- package/dist/assert/one-of/one-of.type.js +8 -0
- package/dist/assert/one-of/one-of.type.js.map +1 -0
- package/dist/assert/string-ends-with/string-ends-with.assert.d.ts +3 -4
- package/dist/assert/string-ends-with/string-ends-with.assert.d.ts.map +1 -1
- package/dist/assert/string-ends-with/string-ends-with.assert.js.map +1 -1
- package/dist/assert/string-ends-with/string-ends-with.match.d.ts +2 -2
- package/dist/assert/string-ends-with/string-ends-with.match.d.ts.map +1 -1
- package/dist/assert/string-ends-with/string-ends-with.match.js +7 -1
- package/dist/assert/string-ends-with/string-ends-with.match.js.map +1 -1
- package/dist/assert/string-ends-with/string-ends-with.type.d.ts +39 -0
- package/dist/assert/string-ends-with/string-ends-with.type.d.ts.map +1 -0
- package/dist/assert/string-ends-with/string-ends-with.type.js +8 -0
- package/dist/assert/string-ends-with/string-ends-with.type.js.map +1 -0
- package/dist/assert/string-includes/string-includes.assert.d.ts +3 -4
- package/dist/assert/string-includes/string-includes.assert.d.ts.map +1 -1
- package/dist/assert/string-includes/string-includes.assert.js.map +1 -1
- package/dist/assert/string-includes/string-includes.match.d.ts +2 -2
- package/dist/assert/string-includes/string-includes.match.d.ts.map +1 -1
- package/dist/assert/string-includes/string-includes.match.js +7 -1
- package/dist/assert/string-includes/string-includes.match.js.map +1 -1
- package/dist/assert/string-includes/string-includes.type.d.ts +39 -0
- package/dist/assert/string-includes/string-includes.type.d.ts.map +1 -0
- package/dist/assert/string-includes/string-includes.type.js +8 -0
- package/dist/assert/string-includes/string-includes.type.js.map +1 -0
- package/dist/assert/string-length/string-length.assert.d.ts +3 -14
- package/dist/assert/string-length/string-length.assert.d.ts.map +1 -1
- package/dist/assert/string-length/string-length.assert.js +7 -2
- package/dist/assert/string-length/string-length.assert.js.map +1 -1
- package/dist/assert/string-length/string-length.match.d.ts +1 -93
- package/dist/assert/string-length/string-length.match.d.ts.map +1 -1
- package/dist/assert/string-length/string-length.match.js +8 -2
- package/dist/assert/string-length/string-length.match.js.map +1 -1
- package/dist/assert/string-length/string-length.type.d.ts +132 -0
- package/dist/assert/string-length/string-length.type.d.ts.map +1 -0
- package/dist/assert/string-length/string-length.type.js +8 -0
- package/dist/assert/string-length/string-length.type.js.map +1 -0
- package/dist/assert/string-not-includes/string-not-includes.assert.d.ts +4 -4
- package/dist/assert/string-not-includes/string-not-includes.assert.d.ts.map +1 -1
- package/dist/assert/string-not-includes/string-not-includes.assert.js +7 -2
- package/dist/assert/string-not-includes/string-not-includes.assert.js.map +1 -1
- package/dist/assert/string-not-includes/string-not-includes.match.d.ts +2 -2
- package/dist/assert/string-not-includes/string-not-includes.match.d.ts.map +1 -1
- package/dist/assert/string-not-includes/string-not-includes.match.js +8 -2
- package/dist/assert/string-not-includes/string-not-includes.match.js.map +1 -1
- package/dist/assert/string-not-includes/string-not-includes.type.d.ts +30 -0
- package/dist/assert/string-not-includes/string-not-includes.type.d.ts.map +1 -0
- package/dist/assert/string-not-includes/string-not-includes.type.js +8 -0
- package/dist/assert/string-not-includes/string-not-includes.type.js.map +1 -0
- package/dist/assert/string-starts-with/string-starts-with.assert.d.ts +4 -4
- package/dist/assert/string-starts-with/string-starts-with.assert.d.ts.map +1 -1
- package/dist/assert/string-starts-with/string-starts-with.assert.js +7 -2
- package/dist/assert/string-starts-with/string-starts-with.assert.js.map +1 -1
- package/dist/assert/string-starts-with/string-starts-with.match.d.ts +2 -2
- package/dist/assert/string-starts-with/string-starts-with.match.d.ts.map +1 -1
- package/dist/assert/string-starts-with/string-starts-with.match.js +7 -1
- package/dist/assert/string-starts-with/string-starts-with.match.js.map +1 -1
- package/dist/assert/string-starts-with/string-starts-with.type.d.ts +39 -0
- package/dist/assert/string-starts-with/string-starts-with.type.d.ts.map +1 -0
- package/dist/assert/string-starts-with/string-starts-with.type.js +8 -0
- package/dist/assert/string-starts-with/string-starts-with.type.js.map +1 -0
- package/dist/assert/throws-error-like/throws-error-like.assert.d.ts +1 -5
- package/dist/assert/throws-error-like/throws-error-like.assert.d.ts.map +1 -1
- package/dist/assert/throws-error-like/throws-error-like.assert.js.map +1 -1
- package/dist/assert/throws-error-like/throws-error-like.type.d.ts +6 -0
- package/dist/assert/throws-error-like/throws-error-like.type.d.ts.map +1 -0
- package/dist/assert/throws-error-like/throws-error-like.type.js +2 -0
- package/dist/assert/throws-error-like/throws-error-like.type.js.map +1 -0
- package/dist/assert/type-bigint/type-bigint.match.d.ts +2 -2
- package/dist/assert/type-bigint/type-bigint.match.d.ts.map +1 -1
- package/dist/assert/type-bigint/type-bigint.match.js.map +1 -1
- package/dist/assert/type-bigint/type-bigint.type.d.ts +21 -0
- package/dist/assert/type-bigint/type-bigint.type.d.ts.map +1 -0
- package/dist/assert/type-bigint/type-bigint.type.js +2 -0
- package/dist/assert/type-bigint/type-bigint.type.js.map +1 -0
- package/dist/assert/type-boolean/type-boolean.match.d.ts +2 -2
- package/dist/assert/type-boolean/type-boolean.match.d.ts.map +1 -1
- package/dist/assert/type-boolean/type-boolean.match.js +7 -1
- package/dist/assert/type-boolean/type-boolean.match.js.map +1 -1
- package/dist/assert/type-boolean/type-boolean.type.d.ts +30 -0
- package/dist/assert/type-boolean/type-boolean.type.d.ts.map +1 -0
- package/dist/assert/type-boolean/type-boolean.type.js +9 -0
- package/dist/assert/type-boolean/type-boolean.type.js.map +1 -0
- package/dist/assert/type-function/type-function.assert.d.ts.map +1 -1
- package/dist/assert/type-function/type-function.assert.js.map +1 -1
- package/dist/assert/type-function/type-function.match.d.ts +2 -2
- package/dist/assert/type-function/type-function.match.d.ts.map +1 -1
- package/dist/assert/type-function/type-function.match.js +7 -4
- package/dist/assert/type-function/type-function.match.js.map +1 -1
- package/dist/assert/type-function/type-function.type.d.ts +29 -0
- package/dist/assert/type-function/type-function.type.d.ts.map +1 -0
- package/dist/assert/type-function/type-function.type.js +8 -0
- package/dist/assert/type-function/type-function.type.js.map +1 -0
- package/dist/assert/type-number/type-number.match.d.ts +2 -2
- package/dist/assert/type-number/type-number.match.d.ts.map +1 -1
- package/dist/assert/type-number/type-number.match.js +7 -1
- package/dist/assert/type-number/type-number.match.js.map +1 -1
- package/dist/assert/type-number/type-number.type.d.ts +30 -0
- package/dist/assert/type-number/type-number.type.d.ts.map +1 -0
- package/dist/assert/type-number/type-number.type.js +9 -0
- package/dist/assert/type-number/type-number.type.js.map +1 -0
- package/dist/assert/type-numeric/type-numeric.match.d.ts +2 -2
- package/dist/assert/type-numeric/type-numeric.match.d.ts.map +1 -1
- package/dist/assert/type-numeric/type-numeric.match.js +7 -1
- package/dist/assert/type-numeric/type-numeric.match.js.map +1 -1
- package/dist/assert/type-numeric/type-numeric.type.d.ts +33 -0
- package/dist/assert/type-numeric/type-numeric.type.d.ts.map +1 -0
- package/dist/assert/type-numeric/type-numeric.type.js +9 -0
- package/dist/assert/type-numeric/type-numeric.type.js.map +1 -0
- package/dist/assert/type-object/type-object.match.d.ts +2 -2
- package/dist/assert/type-object/type-object.match.d.ts.map +1 -1
- package/dist/assert/type-object/type-object.match.js +7 -1
- package/dist/assert/type-object/type-object.match.js.map +1 -1
- package/dist/assert/type-object/type-object.type.d.ts +33 -0
- package/dist/assert/type-object/type-object.type.d.ts.map +1 -0
- package/dist/assert/type-object/type-object.type.js +8 -0
- package/dist/assert/type-object/type-object.type.js.map +1 -0
- package/dist/assert/type-string/type-string.match.d.ts +2 -2
- package/dist/assert/type-string/type-string.match.d.ts.map +1 -1
- package/dist/assert/type-string/type-string.match.js +7 -1
- package/dist/assert/type-string/type-string.match.js.map +1 -1
- package/dist/assert/type-string/type-string.type.d.ts +30 -0
- package/dist/assert/type-string/type-string.type.d.ts.map +1 -0
- package/dist/assert/type-string/type-string.type.js +9 -0
- package/dist/assert/type-string/type-string.type.js.map +1 -0
- package/dist/assert/type-symbol/type-symbol.assert.d.ts +5 -0
- package/dist/assert/type-symbol/type-symbol.assert.d.ts.map +1 -0
- package/dist/assert/type-symbol/type-symbol.assert.js +13 -0
- package/dist/assert/type-symbol/type-symbol.assert.js.map +1 -0
- package/dist/assert/type-symbol/type-symbol.match.d.ts +6 -0
- package/dist/assert/type-symbol/type-symbol.match.d.ts.map +1 -0
- package/dist/assert/type-symbol/type-symbol.match.js +14 -0
- package/dist/assert/type-symbol/type-symbol.match.js.map +1 -0
- package/dist/assert/type-symbol/type-symbol.type.d.ts +30 -0
- package/dist/assert/type-symbol/type-symbol.type.d.ts.map +1 -0
- package/dist/assert/type-symbol/type-symbol.type.js +9 -0
- package/dist/assert/type-symbol/type-symbol.type.js.map +1 -0
- package/dist/assert/type-typed-array/type-typed-array.assert.d.ts +1 -1
- package/dist/assert/type-typed-array/type-typed-array.assert.d.ts.map +1 -1
- package/dist/assert/type-typed-array/type-typed-array.assert.js.map +1 -1
- package/dist/assert/type-typed-array/type-typed-array.match.d.ts +2 -6
- package/dist/assert/type-typed-array/type-typed-array.match.d.ts.map +1 -1
- package/dist/assert/type-typed-array/type-typed-array.match.js +7 -1
- package/dist/assert/type-typed-array/type-typed-array.match.js.map +1 -1
- package/dist/assert/type-typed-array/type-typed-array.type.d.ts +33 -0
- package/dist/assert/type-typed-array/type-typed-array.type.d.ts.map +1 -0
- package/dist/assert/type-typed-array/type-typed-array.type.js +8 -0
- package/dist/assert/type-typed-array/type-typed-array.type.js.map +1 -0
- package/dist/assert/uuid/uuid-v4.assert.d.ts +2 -4
- package/dist/assert/uuid/uuid-v4.assert.d.ts.map +1 -1
- package/dist/assert/uuid/uuid-v4.assert.js +2 -2
- package/dist/assert/uuid/uuid-v4.assert.js.map +1 -1
- package/dist/assert/uuid/uuid-v4.match.d.ts +2 -4
- package/dist/assert/uuid/uuid-v4.match.d.ts.map +1 -1
- package/dist/assert/uuid/uuid-v4.match.js +7 -1
- package/dist/assert/uuid/uuid-v4.match.js.map +1 -1
- package/dist/assert/uuid/uuid-v4.type.d.ts +34 -0
- package/dist/assert/uuid/uuid-v4.type.d.ts.map +1 -0
- package/dist/assert/uuid/uuid-v4.type.js +8 -0
- package/dist/assert/uuid/uuid-v4.type.js.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/match/match.d.ts +37 -1
- package/dist/match/match.d.ts.map +1 -1
- package/dist/match/match.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { AssertionMatcher, refinement } from "../../match/match.js";
|
|
2
|
+
/**
|
|
3
|
+
* Unique symbol to reliably identify the MapOfSizeMatcher type.
|
|
4
|
+
*
|
|
5
|
+
* TypeScript is structurally typed, so matcher types with similar predicates
|
|
6
|
+
* can otherwise accidentally satisfy each other's conditional branches.
|
|
7
|
+
*/
|
|
8
|
+
export declare const mapOfSizeMatcher: unique symbol;
|
|
9
|
+
export type MapOfSize<TKey, TValue, N extends number> = Map<TKey, TValue> & {
|
|
10
|
+
readonly size: N;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Type produced when an actual value is matched by mapOfSize().
|
|
14
|
+
*
|
|
15
|
+
* When the calling scope already knows the actual value is a Map, preserve that
|
|
16
|
+
* exact Map type and only refine its size property. Otherwise, fall back to a
|
|
17
|
+
* generic Map with unknown keys and values.
|
|
18
|
+
*/
|
|
19
|
+
export type MapOfSizeMatch<TActual, N extends number> = NonNullable<TActual> extends Map<unknown, unknown> ? NonNullable<TActual> & {
|
|
20
|
+
readonly size: N;
|
|
21
|
+
} : MapOfSize<unknown, unknown, N>;
|
|
22
|
+
export type MapOfSizeMatcher<N extends number> = AssertionMatcher<MapOfSize<unknown, unknown, N>> & {
|
|
23
|
+
readonly [mapOfSizeMatcher]: N;
|
|
24
|
+
/**
|
|
25
|
+
* Optional type-level hook used by compositional assertions such as
|
|
26
|
+
* assertObjectMatches().
|
|
27
|
+
*
|
|
28
|
+
* This lets the matcher describe how it refines an existing actual type,
|
|
29
|
+
* rather than only exposing the standalone matches() predicate type.
|
|
30
|
+
*/
|
|
31
|
+
readonly [refinement]?: <TActual>(actual: TActual) => MapOfSizeMatch<TActual, N>;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=map-size.type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-size.type.d.ts","sourceRoot":"","sources":["../../../src/assert/map-size/map-size.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEzE;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,eAAsC,CAAC;AAEpE,MAAM,MAAM,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,SAAS,MAAM,IAAI,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG;IAC1E,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;CAClB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,CAAC,OAAO,EAAE,CAAC,SAAS,MAAM,IAClD,WAAW,CAAC,OAAO,CAAC,SAAS,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,GAC9C,WAAW,CAAC,OAAO,CAAC,GAAG;IACrB,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;CAClB,GACD,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;AAErC,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,MAAM,IAAI,gBAAgB,CAC/D,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,CAC/B,GAAG;IACF,QAAQ,CAAC,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;IAE/B;;;;;;OAMG;IACH,QAAQ,CAAC,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,OAAO,EAC9B,MAAM,EAAE,OAAO,KACZ,cAAc,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;CACjC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unique symbol to reliably identify the MapOfSizeMatcher type.
|
|
3
|
+
*
|
|
4
|
+
* TypeScript is structurally typed, so matcher types with similar predicates
|
|
5
|
+
* can otherwise accidentally satisfy each other's conditional branches.
|
|
6
|
+
*/
|
|
7
|
+
export const mapOfSizeMatcher = Symbol("smartass.mapOfSizeMatcher");
|
|
8
|
+
//# sourceMappingURL=map-size.type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-size.type.js","sourceRoot":"","sources":["../../../src/assert/map-size/map-size.type.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,2BAA2B,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { NonNullableMatcher } from "./non-nullable.type.js";
|
|
2
2
|
/**
|
|
3
3
|
* Matcher for a non-nullable value.
|
|
4
4
|
*/
|
|
5
|
-
export declare function nonNullable
|
|
5
|
+
export declare function nonNullable(): NonNullableMatcher;
|
|
6
6
|
//# sourceMappingURL=non-nullable.match.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"non-nullable.match.d.ts","sourceRoot":"","sources":["../../../src/assert/non-nullable/non-nullable.match.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"non-nullable.match.d.ts","sourceRoot":"","sources":["../../../src/assert/non-nullable/non-nullable.match.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE;;GAEG;AACH,wBAAgB,WAAW,IAAI,kBAAkB,CAOhD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"non-nullable.match.js","sourceRoot":"","sources":["../../../src/assert/non-nullable/non-nullable.match.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"non-nullable.match.js","sourceRoot":"","sources":["../../../src/assert/non-nullable/non-nullable.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD;;GAEG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,aAAa,CAClB,CAAC,KAAK,EAAiC,EAAE,CACvC,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EACvC,GAAG,EAAE,CAAC,wBAAwB,EAC9B,GAAG,EAAE,CAAC,aAAa,CACpB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AssertionMatcher, refinement } from "../../match/match.js";
|
|
2
|
+
export type NonNullableMatcher = AssertionMatcher<NonNullable<unknown>> & {
|
|
3
|
+
readonly [refinement]?: <TActual>(actual: TActual) => NonNullable<TActual>;
|
|
4
|
+
};
|
|
5
|
+
//# sourceMappingURL=non-nullable.type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"non-nullable.type.d.ts","sourceRoot":"","sources":["../../../src/assert/non-nullable/non-nullable.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEzE,MAAM,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,GAAG;IACxE,QAAQ,CAAC,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,KAAK,WAAW,CAAC,OAAO,CAAC,CAAC;CAC5E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"non-nullable.type.js","sourceRoot":"","sources":["../../../src/assert/non-nullable/non-nullable.type.ts"],"names":[],"mappings":""}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Assert that a numeric value, when rounded to the nearest given increment,
|
|
3
3
|
* equals the expected value.
|
|
4
4
|
*/
|
|
5
|
-
export declare function assertNumberToNearest(value: unknown,
|
|
5
|
+
export declare function assertNumberToNearest(value: unknown, expected: number, toNearest?: number, message?: string): asserts value is number;
|
|
6
6
|
//# sourceMappingURL=number-to-nearest.assert.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-to-nearest.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/number-to-nearest/number-to-nearest.assert.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,OAAO,EACd,
|
|
1
|
+
{"version":3,"file":"number-to-nearest.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/number-to-nearest/number-to-nearest.assert.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,MAAM,EAChB,SAAS,SAAI,EACb,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,KAAK,IAAI,MAAM,CAYzB"}
|
|
@@ -6,9 +6,9 @@ import { numberToNearest } from "./number-to-nearest.match.js";
|
|
|
6
6
|
* Assert that a numeric value, when rounded to the nearest given increment,
|
|
7
7
|
* equals the expected value.
|
|
8
8
|
*/
|
|
9
|
-
export function assertNumberToNearest(value,
|
|
9
|
+
export function assertNumberToNearest(value, expected, toNearest = 1, message) {
|
|
10
10
|
assertTypeNumber(value);
|
|
11
|
-
const matcher = numberToNearest(
|
|
11
|
+
const matcher = numberToNearest(expected, toNearest);
|
|
12
12
|
if (!matcher.matches(value)) {
|
|
13
13
|
throw new AssertionError(message ?? `Expected ${repr(value)} to ${matcher.describe()}.`, value, matcher.represent());
|
|
14
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-to-nearest.assert.js","sourceRoot":"","sources":["../../../src/assert/number-to-nearest/number-to-nearest.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CACnC,KAAc,EACd,
|
|
1
|
+
{"version":3,"file":"number-to-nearest.assert.js","sourceRoot":"","sources":["../../../src/assert/number-to-nearest/number-to-nearest.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CACnC,KAAc,EACd,QAAgB,EAChB,SAAS,GAAG,CAAC,EACb,OAAgB;IAEhB,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAExB,MAAM,OAAO,GAAG,eAAe,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAErD,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,cAAc,CACtB,OAAO,IAAI,YAAY,IAAI,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,QAAQ,EAAE,GAAG,EAC9D,KAAK,EACL,OAAO,CAAC,SAAS,EAAE,CACpB,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -3,5 +3,5 @@ import { type AssertionMatcher } from "../../match/match.js";
|
|
|
3
3
|
* Matcher for a number that, when rounded to the nearest given increment,
|
|
4
4
|
* equals the expected value.
|
|
5
5
|
*/
|
|
6
|
-
export declare function numberToNearest(
|
|
6
|
+
export declare function numberToNearest(expected: number, toNearest?: number): AssertionMatcher<number>;
|
|
7
7
|
//# sourceMappingURL=number-to-nearest.match.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-to-nearest.match.d.ts","sourceRoot":"","sources":["../../../src/assert/number-to-nearest/number-to-nearest.match.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,gBAAgB,EAAiB,MAAM,sBAAsB,CAAC;AAE5E;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,
|
|
1
|
+
{"version":3,"file":"number-to-nearest.match.d.ts","sourceRoot":"","sources":["../../../src/assert/number-to-nearest/number-to-nearest.match.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,gBAAgB,EAAiB,MAAM,sBAAsB,CAAC;AAE5E;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,SAAS,SAAI,GACZ,gBAAgB,CAAC,MAAM,CAAC,CAQ1B"}
|
|
@@ -4,7 +4,7 @@ import { createMatcher } from "../../match/match.js";
|
|
|
4
4
|
* Matcher for a number that, when rounded to the nearest given increment,
|
|
5
5
|
* equals the expected value.
|
|
6
6
|
*/
|
|
7
|
-
export function numberToNearest(
|
|
7
|
+
export function numberToNearest(expected, toNearest = 1) {
|
|
8
8
|
return createMatcher((value) => typeof value === "number" &&
|
|
9
9
|
roundToNearest(value, toNearest) === expected, () => `equal ${repr(expected)} to nearest ${repr(toNearest)}`, () => `≈₍${repr(toNearest)}₎${repr(expected)}`);
|
|
10
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-to-nearest.match.js","sourceRoot":"","sources":["../../../src/assert/number-to-nearest/number-to-nearest.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAyB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE5E;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,
|
|
1
|
+
{"version":3,"file":"number-to-nearest.match.js","sourceRoot":"","sources":["../../../src/assert/number-to-nearest/number-to-nearest.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAyB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE5E;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,QAAgB,EAChB,SAAS,GAAG,CAAC;IAEb,OAAO,aAAa,CAClB,CAAC,KAAK,EAAmB,EAAE,CACzB,OAAO,KAAK,KAAK,QAAQ;QACzB,cAAc,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,QAAQ,EAC/C,GAAG,EAAE,CAAC,SAAS,IAAI,CAAC,QAAQ,CAAC,eAAe,IAAI,CAAC,SAAS,CAAC,EAAE,EAC7D,GAAG,EAAE,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE,CAC/C,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,KAAa,EAAE,SAAiB;IACtD,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;IAE7D,uEAAuE;IACvE,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9C,MAAM,aAAa,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC;IAE5C,OAAO,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* The property only has to exist on the object, but could be undefined.
|
|
5
|
-
*/
|
|
6
|
-
export declare function assertObjectHasProperty<T extends object, K extends PropertyKey>(value: T, key: K, message?: string): asserts value is T & ObjectWithProperty<K, T>;
|
|
1
|
+
import type { ObjectWithProperty } from "./object-has-property.type.js";
|
|
2
|
+
export declare function assertObjectHasProperty<T extends object, K extends PropertyKey>(value: T, key: K, message?: string): asserts value is T & ObjectWithProperty<K>;
|
|
3
|
+
export declare function assertObjectHasProperty<K extends PropertyKey>(value: unknown, key: K, message?: string): asserts value is ObjectWithProperty<K>;
|
|
7
4
|
//# sourceMappingURL=object-has-property.assert.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-has-property.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/object-has-property/object-has-property.assert.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"object-has-property.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/object-has-property/object-has-property.assert.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAExE,wBAAgB,uBAAuB,CACrC,CAAC,SAAS,MAAM,EAChB,CAAC,SAAS,WAAW,EAErB,KAAK,EAAE,CAAC,EACR,GAAG,EAAE,CAAC,EACN,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,KAAK,IAAI,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC;AAE9C,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,WAAW,EAC3D,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,CAAC,EACN,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,KAAK,IAAI,kBAAkB,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AssertionError } from "../../assertion-error.js";
|
|
2
2
|
import { desc } from "../../describe/describe.js";
|
|
3
|
-
import { objectWithProperty
|
|
3
|
+
import { objectWithProperty } from "./object-has-property.match.js";
|
|
4
4
|
/**
|
|
5
5
|
* Assert that an object has a certain named property.
|
|
6
6
|
* The property only has to exist on the object, but could be undefined.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-has-property.assert.js","sourceRoot":"","sources":["../../../src/assert/object-has-property/object-has-property.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,
|
|
1
|
+
{"version":3,"file":"object-has-property.assert.js","sourceRoot":"","sources":["../../../src/assert/object-has-property/object-has-property.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAkBpE;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CACrC,KAAc,EACd,GAAgB,EAChB,OAAgB;IAEhB,MAAM,OAAO,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;IAExC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,cAAc,CACtB,OAAO,IAAI,YAAY,IAAI,CAAC,KAAK,CAAC,UAAU,OAAO,CAAC,QAAQ,EAAE,GAAG,EACjE,KAAK,EACL,OAAO,CAAC,SAAS,EAAE,CACpB,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
export type ObjectWithProperty<K extends PropertyKey, TActual = unknown> = K extends keyof NonNullable<TActual> ? Omit<NonNullable<TActual>, K> & {
|
|
3
|
-
[P in K]-?: Exclude<NonNullable<TActual>[P], undefined>;
|
|
4
|
-
} : object & Record<K, unknown>;
|
|
5
|
-
export type ObjectWithPropertyMatcher<K extends PropertyKey> = AssertionMatcher<ObjectWithProperty<K>> & {
|
|
6
|
-
readonly [refinement]?: <TActual>(actual: TActual) => ObjectWithProperty<K, TActual>;
|
|
7
|
-
};
|
|
1
|
+
import type { ObjectWithPropertyMatcher } from "./object-has-property.type.js";
|
|
8
2
|
/**
|
|
9
3
|
* Matcher for an object with a certain named property.
|
|
10
4
|
* The property only has to exist on the object, but could be undefined.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-has-property.match.d.ts","sourceRoot":"","sources":["../../../src/assert/object-has-property/object-has-property.match.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"object-has-property.match.d.ts","sourceRoot":"","sources":["../../../src/assert/object-has-property/object-has-property.match.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,yBAAyB,EAC1B,MAAM,+BAA+B,CAAC;AAEvC;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,WAAW,EACtD,GAAG,EAAE,CAAC,GACL,yBAAyB,CAAC,CAAC,CAAC,CAO9B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { desc, repr } from "../../describe/describe.js";
|
|
2
|
-
import { createMatcher
|
|
2
|
+
import { createMatcher } from "../../match/match.js";
|
|
3
3
|
/**
|
|
4
4
|
* Matcher for an object with a certain named property.
|
|
5
5
|
* The property only has to exist on the object, but could be undefined.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-has-property.match.js","sourceRoot":"","sources":["../../../src/assert/object-has-property/object-has-property.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,
|
|
1
|
+
{"version":3,"file":"object-has-property.match.js","sourceRoot":"","sources":["../../../src/assert/object-has-property/object-has-property.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAMrD;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAChC,GAAM;IAEN,OAAO,aAAa,CAClB,CAAC,KAAK,EAAkC,EAAE,CACxC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,EAC7D,GAAG,EAAE,CAAC,wBAAwB,IAAI,CAAC,GAAG,CAAC,EAAE,EACzC,GAAG,EAAE,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CACS,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AssertionMatcher } from "../../match/match.js";
|
|
2
|
+
declare const objectWithPropertyMatcher: unique symbol;
|
|
3
|
+
export type ObjectWithProperty<K extends PropertyKey> = object & Record<K, unknown>;
|
|
4
|
+
export type ObjectWithPropertyMatcher<K extends PropertyKey> = AssertionMatcher<ObjectWithProperty<K>> & {
|
|
5
|
+
readonly [objectWithPropertyMatcher]: K;
|
|
6
|
+
};
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=object-has-property.type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object-has-property.type.d.ts","sourceRoot":"","sources":["../../../src/assert/object-has-property/object-has-property.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,OAAO,CAAC,MAAM,yBAAyB,EAAE,OAAO,MAAM,CAAC;AAEvD,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,WAAW,IAAI,MAAM,GAC5D,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AAErB,MAAM,MAAM,yBAAyB,CAAC,CAAC,SAAS,WAAW,IAAI,gBAAgB,CAC7E,kBAAkB,CAAC,CAAC,CAAC,CACtB,GAAG;IACF,QAAQ,CAAC,CAAC,yBAAyB,CAAC,EAAE,CAAC,CAAC;CACzC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object-has-property.type.js","sourceRoot":"","sources":["../../../src/assert/object-has-property/object-has-property.type.ts"],"names":[],"mappings":""}
|
|
@@ -1,30 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ArrayIncluding, ArrayIncludingMatcher } from "../array-includes/array-includes.match.js";
|
|
3
|
-
import type { ArrayIncludingAll, ArrayIncludingAllMatcher } from "../array-includes-all/array-includes-all.match.js";
|
|
4
|
-
import type { ArrayOfLength, ArrayOfLengthMatcher } from "../array-length/array-length.match.js";
|
|
5
|
-
import type { ArrayOfMinLength, ArrayOfMinLengthMatcher } from "../array-min-length/array-min-length.match.js";
|
|
6
|
-
import type { NonEmptyArray, NonEmptyArrayMatcher } from "../array-not-empty/array-not-empty.match.js";
|
|
7
|
-
import type { ObjectWithProperty, ObjectWithPropertyMatcher } from "../object-has-property/object-has-property.match.js";
|
|
8
|
-
import type { StringOfLength, StringOfLengthMatcher } from "../string-length/string-length.match.js";
|
|
9
|
-
type FunctionLike = (...arguments_: never[]) => unknown;
|
|
10
|
-
type ObjectMatchLeaf = FunctionLike | Date | RegExp | Map<unknown, unknown> | Set<unknown> | WeakMap<object, unknown> | WeakSet<object> | Promise<unknown>;
|
|
11
|
-
type ActualProperty<TActual, TKey extends PropertyKey> = TKey extends keyof NonNullable<TActual> ? NonNullable<TActual>[TKey] : unknown;
|
|
12
|
-
type ArrayElement<T> = T extends readonly (infer TElement)[] ? TElement : unknown;
|
|
13
|
-
type ActualArrayElement<TActual> = NonNullable<TActual> extends readonly unknown[] ? ArrayElement<NonNullable<TActual>> : unknown;
|
|
14
|
-
type ArrayOfLengthRefine<TActual, N extends number> = TActual & ArrayOfLength<ActualArrayElement<TActual>, N>;
|
|
15
|
-
type ArrayOfMinLengthRefine<TActual, N extends number> = TActual & ArrayOfMinLength<ActualArrayElement<TActual>, N>;
|
|
16
|
-
type ArrayIncludingRefine<TActual, E> = Omit<NonNullable<TActual>, "includes"> & ArrayIncluding<ActualArrayElement<TActual> | E, E>;
|
|
17
|
-
type ArrayIncludingAllRefine<TActual, E extends readonly unknown[]> = Omit<NonNullable<TActual>, "includes"> & ArrayIncludingAll<ActualArrayElement<TActual> | E[number], E>;
|
|
18
|
-
type NonEmptyArrayRefine<TActual> = TActual & NonEmptyArray<ActualArrayElement<TActual>>;
|
|
19
|
-
type ObjectWithPropertyRefine<TActual, K extends PropertyKey> = ObjectWithProperty<K, TActual>;
|
|
20
|
-
type StringOfLengthRefine<TActual, N extends number> = TActual & StringOfLength<N>;
|
|
21
|
-
type MatcherRefine<TActual, TExpected> = TExpected extends ArrayOfLengthMatcher<infer N> ? ArrayOfLengthRefine<TActual, N> : TExpected extends ArrayOfMinLengthMatcher<infer N> ? ArrayOfMinLengthRefine<TActual, N> : TExpected extends NonEmptyArrayMatcher ? NonEmptyArrayRefine<TActual> : TExpected extends ArrayIncludingMatcher<infer E> ? ArrayIncludingRefine<TActual, E> : TExpected extends ArrayIncludingAllMatcher<infer E> ? ArrayIncludingAllRefine<TActual, E> : TExpected extends ObjectWithPropertyMatcher<infer K> ? ObjectWithPropertyRefine<TActual, K> : TExpected extends StringOfLengthMatcher<infer N> ? StringOfLengthRefine<TActual, N> : TExpected extends AssertionMatcher<unknown> ? RefinedMatch<TExpected, TActual> : never;
|
|
22
|
-
type AssertedRefine<TActual, TRefined> = TRefined extends TActual ? TRefined : TActual & TRefined;
|
|
23
|
-
type DeepObjectRefine<TActual, TExpected> = TExpected extends AssertionMatcher<unknown> ? MatcherRefine<TActual, TExpected> : TExpected extends ObjectMatchLeaf ? TActual & TExpected : TExpected extends readonly unknown[] ? TActual & {
|
|
24
|
-
readonly [K in keyof TExpected]: DeepObjectRefine<ActualProperty<TActual, K>, TExpected[K]>;
|
|
25
|
-
} : TExpected extends object ? Omit<NonNullable<TActual>, keyof TExpected> & {
|
|
26
|
-
[K in keyof TExpected]: DeepObjectRefine<ActualProperty<TActual, K>, TExpected[K]>;
|
|
27
|
-
} : TActual & TExpected;
|
|
1
|
+
import type { AssertedRefine, DeepObjectRefine } from "./object-matches.type.js";
|
|
28
2
|
/**
|
|
29
3
|
* Assert that an object matches a partial deep object structure, with
|
|
30
4
|
* type-narrowing.
|
|
@@ -36,5 +10,4 @@ type DeepObjectRefine<TActual, TExpected> = TExpected extends AssertionMatcher<u
|
|
|
36
10
|
* Primitive values and non-plain objects are compared using Object.is.
|
|
37
11
|
*/
|
|
38
12
|
export declare function assertObjectMatches<TActual, const TExpected extends Record<PropertyKey, unknown>>(actual: TActual, expected: TExpected, message?: string): asserts actual is AssertedRefine<TActual, DeepObjectRefine<TActual, TExpected>>;
|
|
39
|
-
export {};
|
|
40
13
|
//# sourceMappingURL=object-matches.assert.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-matches.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/object-matches/object-matches.assert.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"object-matches.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/object-matches/object-matches.assert.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EACjB,MAAM,0BAA0B,CAAC;AAElC;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EACP,KAAK,CAAC,SAAS,SAAS,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,EAEpD,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,SAAS,EACnB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,IAAI,cAAc,CACjC,OAAO,EACP,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,CACrC,CAcA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-matches.assert.js","sourceRoot":"","sources":["../../../src/assert/object-matches/object-matches.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"object-matches.assert.js","sourceRoot":"","sources":["../../../src/assert/object-matches/object-matches.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAMlF;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CAIjC,MAAe,EACf,QAAmB,EACnB,OAAgB;IAKhB,MAAM,QAAQ,GAAG,4BAA4B,CAAC,MAAM,EAAE,QAAQ,EAAE;QAC9D,eAAe,EAAE,KAAK;QACtB,sBAAsB,EAAE,KAAK;KAC9B,CAAC,CAAC;IAEH,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,cAAc,CACtB,OAAO;YACL,YAAY,IAAI,CAAC,MAAM,CAAC,aAAa,IAAI,CAAC,QAAQ,CAAC,iBAAiB,QAAQ,CAAC,IAAI,cAAc,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,EACzJ,MAAM,EACN,QAAQ,CACT,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import type { ArrayOfLengthMatch, ArrayOfLengthMatcher } from "../array-length/array-length.type.js";
|
|
2
|
+
import type { ObjectWithProperty, ObjectWithPropertyMatcher } from "../object-has-property/object-has-property.type.js";
|
|
3
|
+
import type { AssertionMatcher, RefinedMatch, refinement } from "../../match/match.js";
|
|
4
|
+
import type { ArrayOfMinLengthMatch, ArrayOfMinLengthMatcher } from "../array-min-length/array-min-length.type.js";
|
|
5
|
+
import type { ArrayIncludingAllMatch, ArrayIncludingAllMatcher } from "../array-includes-all/array-includes-all.type.js";
|
|
6
|
+
import type { InstanceOfMatch, InstanceOfMatcher } from "../instance-of/instance-of.type.js";
|
|
7
|
+
import type { ArrayIncludingMatch, ArrayIncludingMatcher } from "../array-includes/array-includes.type.js";
|
|
8
|
+
import type { NonEmptyArrayMatch, NonEmptyArrayMatcher } from "../array-not-empty/array-not-empty.type.js";
|
|
9
|
+
import type { OneOfMatch, OneOfMatcher } from "../one-of/one-of.type.js";
|
|
10
|
+
import type { StringEndingWithMatch, StringEndingWithMatcher } from "../string-ends-with/string-ends-with.type.js";
|
|
11
|
+
import type { StringIncludingMatch, StringIncludingMatcher } from "../string-includes/string-includes.type.js";
|
|
12
|
+
import type { StringOfLengthMatch, StringOfLengthMatcher } from "../string-length/string-length.type.js";
|
|
13
|
+
import type { StringNotIncludingMatch, StringNotIncludingMatcher } from "../string-not-includes/string-not-includes.type.js";
|
|
14
|
+
import type { StringStartingWithMatch, StringStartingWithMatcher } from "../string-starts-with/string-starts-with.type.js";
|
|
15
|
+
import type { TypeBigIntMatch, TypeBigIntMatcher } from "../type-bigint/type-bigint.type.js";
|
|
16
|
+
import type { TypeBooleanMatch, TypeBooleanMatcher } from "../type-boolean/type-boolean.type.js";
|
|
17
|
+
import type { TypeFunctionMatch, TypeFunctionMatcher } from "../type-function/type-function.type.js";
|
|
18
|
+
import type { TypeNumberMatch, TypeNumberMatcher } from "../type-number/type-number.type.js";
|
|
19
|
+
import type { TypeNumericMatch, TypeNumericMatcher } from "../type-numeric/type-numeric.type.js";
|
|
20
|
+
import type { TypeObjectMatch, TypeObjectMatcher } from "../type-object/type-object.type.js";
|
|
21
|
+
import type { TypeStringMatch, TypeStringMatcher } from "../type-string/type-string.type.js";
|
|
22
|
+
import type { TypeSymbolMatch, TypeSymbolMatcher } from "../type-symbol/type-symbol.type.js";
|
|
23
|
+
import type { TypeTypedArrayMatch, TypeTypedArrayMatcher } from "../type-typed-array/type-typed-array.type.js";
|
|
24
|
+
import type { UuidV4Match, UuidV4Matcher } from "../uuid/uuid-v4.type.js";
|
|
25
|
+
import type { MapOfSizeMatch, MapOfSizeMatcher } from "../map-size/map-size.type.js";
|
|
26
|
+
type FunctionLike = (...arguments_: never[]) => unknown;
|
|
27
|
+
/**
|
|
28
|
+
* Values that should be treated as terminal leaves during deep object matching.
|
|
29
|
+
*
|
|
30
|
+
* These are object-like values at runtime, but assertObjectMatches() should
|
|
31
|
+
* compare/refine them as whole values rather than recursively walking their
|
|
32
|
+
* properties.
|
|
33
|
+
*/
|
|
34
|
+
type ObjectMatchLeaf = FunctionLike | Date | RegExp | Map<unknown, unknown> | Set<unknown> | WeakMap<object, unknown> | WeakSet<object> | Promise<unknown>;
|
|
35
|
+
/**
|
|
36
|
+
* Read a property from the current actual type while matching an expected
|
|
37
|
+
* shape.
|
|
38
|
+
*
|
|
39
|
+
* Missing properties and nullable parents are treated as unknown, so nested
|
|
40
|
+
* matchers can still describe the type they establish.
|
|
41
|
+
*/
|
|
42
|
+
type ActualProperty<TActual, TKey extends PropertyKey> = TKey extends keyof NonNullable<TActual> ? NonNullable<TActual>[TKey] : unknown;
|
|
43
|
+
/**
|
|
44
|
+
* Extract the element type from an array or tuple-like type.
|
|
45
|
+
*/
|
|
46
|
+
type ArrayElement<T> = T extends readonly (infer TElement)[] ? TElement : unknown;
|
|
47
|
+
/**
|
|
48
|
+
* Extract the element type from the current actual value if it is array-like.
|
|
49
|
+
*
|
|
50
|
+
* Used by generic array matcher fallbacks so known element types, such as
|
|
51
|
+
* string[], can be preserved during object matcher refinement.
|
|
52
|
+
*/
|
|
53
|
+
type ActualArrayElement<TActual> = NonNullable<TActual> extends readonly unknown[] ? ArrayElement<NonNullable<TActual>> : unknown;
|
|
54
|
+
/**
|
|
55
|
+
* Refine an object to require a specific property.
|
|
56
|
+
*
|
|
57
|
+
* Existing properties keep their original type, while properties that were not
|
|
58
|
+
* present on the actual type are introduced as unknown.
|
|
59
|
+
*/
|
|
60
|
+
type ObjectWithPropertyRefine<TActual, K extends PropertyKey> = NonNullable<TActual> extends object ? Omit<NonNullable<TActual>, K> & Required<Pick<NonNullable<TActual>, K & keyof NonNullable<TActual>>> & Record<Exclude<K, keyof NonNullable<TActual>>, unknown> : ObjectWithProperty<K>;
|
|
61
|
+
/**
|
|
62
|
+
* Choose a candidate refinement when it matches, otherwise continue to a
|
|
63
|
+
* fallback.
|
|
64
|
+
*
|
|
65
|
+
* The tuple wrapper prevents distributive conditional behavior over unions.
|
|
66
|
+
*/
|
|
67
|
+
type FirstMatch<TCandidate, TFallback> = [TCandidate] extends [never] ? TFallback : TCandidate;
|
|
68
|
+
/**
|
|
69
|
+
* Explicit refinement branches for array-specific matchers.
|
|
70
|
+
*
|
|
71
|
+
* These delegate to each matcher module's semantic Match type so the resulting
|
|
72
|
+
* user-facing types stay readable.
|
|
73
|
+
*/
|
|
74
|
+
type ArrayMatcherRefine<TActual, TExpected extends AssertionMatcher<unknown>> = TExpected extends ArrayIncludingMatcher<infer TElement> ? ArrayIncludingMatch<TActual, TElement> : TExpected extends ArrayIncludingAllMatcher<infer TElement, infer N> ? ArrayIncludingAllMatch<TActual, TElement, N> : TExpected extends ArrayOfLengthMatcher<infer N> ? ArrayOfLengthMatch<TActual, N> : TExpected extends ArrayOfMinLengthMatcher<infer N> ? ArrayOfMinLengthMatch<TActual, N> : TExpected extends NonEmptyArrayMatcher ? NonEmptyArrayMatch<TActual> : never;
|
|
75
|
+
/**
|
|
76
|
+
* Explicit refinement branches for string-specific matchers.
|
|
77
|
+
*
|
|
78
|
+
* These preserve useful literal-union overlap where possible, while falling
|
|
79
|
+
* back to readable template-literal or branded string types.
|
|
80
|
+
*/
|
|
81
|
+
type StringMatcherRefine<TActual, TExpected extends AssertionMatcher<unknown>> = TExpected extends StringEndingWithMatcher<infer TSuffix> ? StringEndingWithMatch<TActual, TSuffix> : TExpected extends StringIncludingMatcher<infer TSubstring> ? StringIncludingMatch<TActual, TSubstring> : TExpected extends StringNotIncludingMatcher<infer TSubstring> ? StringNotIncludingMatch<TActual, TSubstring> : TExpected extends StringStartingWithMatcher<infer TPrefix> ? StringStartingWithMatch<TActual, TPrefix> : TExpected extends StringOfLengthMatcher<infer N> ? StringOfLengthMatch<TActual, N> : never;
|
|
82
|
+
/**
|
|
83
|
+
* Explicit refinement branches for primitive type matchers.
|
|
84
|
+
*
|
|
85
|
+
* Keeping these branches here avoids exposing broad internal intersections when
|
|
86
|
+
* assertObjectMatches() narrows existing object properties.
|
|
87
|
+
*/
|
|
88
|
+
type TypeMatcherRefine<TActual, TExpected extends AssertionMatcher<unknown>> = TExpected extends TypeBigIntMatcher ? TypeBigIntMatch<TActual> : TExpected extends TypeBooleanMatcher ? TypeBooleanMatch<TActual> : TExpected extends TypeFunctionMatcher ? TypeFunctionMatch<TActual> : TExpected extends TypeNumberMatcher ? TypeNumberMatch<TActual> : TExpected extends TypeNumericMatcher ? TypeNumericMatch<TActual> : TExpected extends TypeObjectMatcher ? TypeObjectMatch<TActual> : TExpected extends TypeStringMatcher ? TypeStringMatch<TActual> : TExpected extends TypeSymbolMatcher ? TypeSymbolMatch<TActual> : TExpected extends TypeTypedArrayMatcher ? TypeTypedArrayMatch<TActual> : never;
|
|
89
|
+
/**
|
|
90
|
+
* Explicit refinement branches for matchers that do not fit a larger family.
|
|
91
|
+
*/
|
|
92
|
+
type MiscMatcherRefine<TActual, TExpected extends AssertionMatcher<unknown>> = TExpected extends InstanceOfMatcher<infer TInstance> ? InstanceOfMatch<TActual, TInstance> : TExpected extends MapOfSizeMatcher<infer N> ? MapOfSizeMatch<TActual, N> : TExpected extends OneOfMatcher<infer TAllowed> ? OneOfMatch<TActual, TAllowed> : TExpected extends UuidV4Matcher ? UuidV4Match<TActual> : never;
|
|
93
|
+
/**
|
|
94
|
+
* Run all explicit matcher refinements before trying generic fallbacks.
|
|
95
|
+
*
|
|
96
|
+
* Precedence matters: explicit semantic Match types produce cleaner public
|
|
97
|
+
* types than the generic refinement hook in cases where TypeScript inference
|
|
98
|
+
* struggles.
|
|
99
|
+
*/
|
|
100
|
+
type BuiltInMatcherRefine<TActual, TExpected extends AssertionMatcher<unknown>> = FirstMatch<ArrayMatcherRefine<TActual, TExpected>, FirstMatch<StringMatcherRefine<TActual, TExpected>, FirstMatch<TypeMatcherRefine<TActual, TExpected>, MiscMatcherRefine<TActual, TExpected>>>>;
|
|
101
|
+
/**
|
|
102
|
+
* Generic matcher refinements used when no explicit branch applies.
|
|
103
|
+
*
|
|
104
|
+
* This handles custom refinement hooks, property-presence matchers, broad array
|
|
105
|
+
* matchers, and finally falls back to the generic RefinedMatch behavior.
|
|
106
|
+
*/
|
|
107
|
+
type FallbackMatcherRefine<TActual, TExpected extends AssertionMatcher<unknown>> = TExpected extends {
|
|
108
|
+
readonly [refinement]?: unknown;
|
|
109
|
+
} ? RefinedMatch<TExpected, TActual> : TExpected extends ObjectWithPropertyMatcher<infer K> ? ObjectWithPropertyRefine<TActual, K> : TExpected extends AssertionMatcher<readonly [unknown, ...unknown[]]> ? [ActualArrayElement<TActual>, ...ActualArrayElement<TActual>[]] : TExpected extends AssertionMatcher<readonly unknown[]> ? ActualArrayElement<TActual>[] : RefinedMatch<TExpected, TActual>;
|
|
110
|
+
/**
|
|
111
|
+
* Apply a matcher to an actual type within assertObjectMatches().
|
|
112
|
+
*
|
|
113
|
+
* The main design goal here is user-facing readability: narrowed types should
|
|
114
|
+
* appear in IDE tooltips and compiler errors as straightforward TypeScript
|
|
115
|
+
* types, e.g. ["beta", ...string[]] or [string, string], rather than as opaque
|
|
116
|
+
* internal helper/intersection types.
|
|
117
|
+
*
|
|
118
|
+
* In principle, matchers expose a [refinement] hook describing how they refine
|
|
119
|
+
* an existing actual type. In practice, TypeScript cannot always apply generic
|
|
120
|
+
* refinement hooks precisely enough through conditional inference, so some
|
|
121
|
+
* matchers have explicit branches here. Those branches should delegate to the
|
|
122
|
+
* matcher module's exported semantic *Match type instead of duplicating the
|
|
123
|
+
* refinement logic.
|
|
124
|
+
*/
|
|
125
|
+
type RefineMatcherResult<TActual, TExpected extends AssertionMatcher<unknown>> = FirstMatch<BuiltInMatcherRefine<TActual, TExpected>, FallbackMatcherRefine<TActual, TExpected>>;
|
|
126
|
+
/**
|
|
127
|
+
* Refine an actual value with an expected matcher.
|
|
128
|
+
*
|
|
129
|
+
* Non-matcher expected values are rejected here; DeepObjectRefine handles those
|
|
130
|
+
* separately as objects, arrays, leaves, or primitive values.
|
|
131
|
+
*/
|
|
132
|
+
type MatcherRefine<TActual, TExpected> = TExpected extends AssertionMatcher<unknown> ? RefineMatcherResult<TActual, TExpected> : never;
|
|
133
|
+
/**
|
|
134
|
+
* Convert an internally refined type into a valid assertion target type.
|
|
135
|
+
*
|
|
136
|
+
* Assertion functions may only assert types assignable to the original
|
|
137
|
+
* parameter, so unrelated refinements are kept as intersections with the actual
|
|
138
|
+
* type.
|
|
139
|
+
*/
|
|
140
|
+
export type AssertedRefine<TActual, TRefined> = TRefined extends TActual ? TRefined : TActual & TRefined;
|
|
141
|
+
/**
|
|
142
|
+
* Recursively refine an actual object type using an expected object-matcher
|
|
143
|
+
* shape.
|
|
144
|
+
*
|
|
145
|
+
* Matchers are applied directly, leaves are treated as whole values,
|
|
146
|
+
* arrays/tuples refine by index, objects refine by key, and primitive expected
|
|
147
|
+
* values narrow via intersection.
|
|
148
|
+
*/
|
|
149
|
+
export type DeepObjectRefine<TActual, TExpected> = TExpected extends AssertionMatcher<unknown> ? MatcherRefine<TActual, TExpected> : TExpected extends ObjectMatchLeaf ? TActual & TExpected : TExpected extends readonly unknown[] ? TActual & {
|
|
150
|
+
-readonly [K in keyof TExpected]: DeepObjectRefine<ActualProperty<TActual, K>, TExpected[K]>;
|
|
151
|
+
} : TExpected extends object ? Omit<NonNullable<TActual>, keyof TExpected> & {
|
|
152
|
+
-readonly [K in keyof TExpected]: DeepObjectRefine<ActualProperty<TActual, K>, TExpected[K]>;
|
|
153
|
+
} : TActual & TExpected;
|
|
154
|
+
export {};
|
|
155
|
+
//# sourceMappingURL=object-matches.type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object-matches.type.d.ts","sourceRoot":"","sources":["../../../src/assert/object-matches/object-matches.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EACV,kBAAkB,EAClB,yBAAyB,EAC1B,MAAM,oDAAoD,CAAC;AAC5D,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,8CAA8C,CAAC;AACtD,OAAO,KAAK,EACV,sBAAsB,EACtB,wBAAwB,EACzB,MAAM,kDAAkD,CAAC;AAC1D,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EAClB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EACV,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,4CAA4C,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,KAAK,EACV,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,8CAA8C,CAAC;AACtD,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACvB,MAA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MAAM,MAAM,gBAAgB,CAAC,OAAO,EAAE,SAAS,IAC7C,SAAS,SAAS,gBAAgB,CAAC,OAAO,CAAC,GACvC,aAAa,CAAC,OAAO,EAAE,SAAS,CAAC,GACjC,SAAS,SAAS,eAAe,GAC/B,OAAO,GAAG,SAAS,GACnB,SAAS,SAAS,SAAS,OAAO,EAAE,GAClC,OAAO,GAAG;IACR,CAAC,UAAU,CAAC,IAAI,MAAM,SAAS,GAAG,gBAAgB,CAChD,cAAc,CAAC,OAAO,EAAE,CAAC,CAAC,EAC1B,SAAS,CAAC,CAAC,CAAC,CACb;CACF,GACD,SAAS,SAAS,MAAM,GACtB,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,MAAM,SAAS,CAAC,GAAG;IAC5C,CAAC,UAAU,CAAC,IAAI,MAAM,SAAS,GAAG,gBAAgB,CAChD,cAAc,CAAC,OAAO,EAAE,CAAC,CAAC,EAC1B,SAAS,CAAC,CAAC,CAAC,CACb;CACF,GACD,OAAO,GAAG,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object-matches.type.js","sourceRoot":"","sources":["../../../src/assert/object-matches/object-matches.type.ts"],"names":[],"mappings":""}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
type OneOfAssertion<TActual, TAllowed extends readonly unknown[]> = [
|
|
2
|
+
Extract<TActual, TAllowed[number]>
|
|
3
|
+
] extends [never] ? TActual & TAllowed[number] : Extract<TActual, TAllowed[number]>;
|
|
4
|
+
export declare function assertOneOf<TActual, const TAllowed extends readonly unknown[]>(value: TActual, allowed: TAllowed, message?: string): asserts value is OneOfAssertion<TActual, TAllowed>;
|
|
4
5
|
export declare function assertOneOf<const TAllowed extends readonly unknown[]>(value: unknown, allowed: TAllowed, message?: string): asserts value is TAllowed[number];
|
|
6
|
+
export {};
|
|
5
7
|
//# sourceMappingURL=one-of.assert.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"one-of.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/one-of/one-of.assert.ts"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"one-of.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/one-of/one-of.assert.ts"],"names":[],"mappings":"AAIA,KAAK,cAAc,CAAC,OAAO,EAAE,QAAQ,SAAS,SAAS,OAAO,EAAE,IAAI;IAClE,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;CACnC,SAAS,CAAC,KAAK,CAAC,GACb,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,GAC1B,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;AAEvC,wBAAgB,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,QAAQ,SAAS,SAAS,OAAO,EAAE,EAC5E,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,QAAQ,EACjB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,KAAK,IAAI,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAEtD,wBAAgB,WAAW,CAAC,KAAK,CAAC,QAAQ,SAAS,SAAS,OAAO,EAAE,EACnE,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,QAAQ,EACjB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,KAAK,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"one-of.assert.js","sourceRoot":"","sources":["../../../src/assert/one-of/one-of.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"one-of.assert.js","sourceRoot":"","sources":["../../../src/assert/one-of/one-of.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAoB1C;;GAEG;AACH,MAAM,UAAU,WAAW,CACzB,KAAc,EACd,OAAiB,EACjB,OAAgB;IAEhB,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,cAAc,CACtB,OAAO,IAAI,YAAY,IAAI,CAAC,KAAK,CAAC,UAAU,OAAO,CAAC,QAAQ,EAAE,GAAG,EACjE,KAAK,EACL,OAAO,CAAC,SAAS,EAAE,CACpB,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type OneOfMatcher } from "./one-of.type.js";
|
|
2
2
|
/**
|
|
3
3
|
* Matcher for a value that is one of a set of expected values.
|
|
4
4
|
*/
|
|
5
|
-
export declare function oneOf<const TAllowed extends readonly unknown[]>(allowed: TAllowed):
|
|
5
|
+
export declare function oneOf<const TAllowed extends readonly unknown[]>(allowed: TAllowed): OneOfMatcher<TAllowed>;
|
|
6
6
|
//# sourceMappingURL=one-of.match.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"one-of.match.d.ts","sourceRoot":"","sources":["../../../src/assert/one-of/one-of.match.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"one-of.match.d.ts","sourceRoot":"","sources":["../../../src/assert/one-of/one-of.match.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEnE;;GAEG;AACH,wBAAgB,KAAK,CAAC,KAAK,CAAC,QAAQ,SAAS,SAAS,OAAO,EAAE,EAC7D,OAAO,EAAE,QAAQ,GAChB,YAAY,CAAC,QAAQ,CAAC,CAWxB"}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { repr } from "../../describe/describe.js";
|
|
2
2
|
import { createMatcher } from "../../match/match.js";
|
|
3
|
+
import { oneOfMatcher } from "./one-of.type.js";
|
|
3
4
|
/**
|
|
4
5
|
* Matcher for a value that is one of a set of expected values.
|
|
5
6
|
*/
|
|
6
7
|
export function oneOf(allowed) {
|
|
7
|
-
return
|
|
8
|
+
return {
|
|
9
|
+
...createMatcher((value) => allowed.includes(value), () => `one of ${repr(allowed)}`, () => allowed.map((i) => repr(i)).join("|")),
|
|
10
|
+
// Runtime marker used only to make the matcher type nominal for type-level
|
|
11
|
+
// refinement dispatch. It is not part of the user-facing matcher behaviour.
|
|
12
|
+
[oneOfMatcher]: allowed,
|
|
13
|
+
};
|
|
8
14
|
}
|
|
9
15
|
//# sourceMappingURL=one-of.match.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"one-of.match.js","sourceRoot":"","sources":["../../../src/assert/one-of/one-of.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,
|
|
1
|
+
{"version":3,"file":"one-of.match.js","sourceRoot":"","sources":["../../../src/assert/one-of/one-of.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAqB,MAAM,kBAAkB,CAAC;AAEnE;;GAEG;AACH,MAAM,UAAU,KAAK,CACnB,OAAiB;IAEjB,OAAO;QACL,GAAG,aAAa,CACd,CAAC,KAAK,EAA6B,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAc,CAAC,EACtE,GAAG,EAAE,CAAC,UAAU,IAAI,CAAC,OAAO,CAAC,EAAE,EAC/B,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAC5C;QACD,2EAA2E;QAC3E,4EAA4E;QAC5E,CAAC,YAAY,CAAC,EAAE,OAAO;KACxB,CAAC;AACJ,CAAC"}
|