hein 2.0.0-alpha.1 → 2.0.0-alpha.3
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/_virtual/rolldown_runtime.cjs +34 -0
- package/dist/assert/deep-equal.cjs +40 -0
- package/dist/assert/deep-equal.cjs.map +1 -0
- package/dist/assert/deep-equal.d.cts +5 -0
- package/dist/assert/deep-equal.d.cts.map +1 -0
- package/dist/assert/deep-equal.d.ts +5 -0
- package/dist/assert/deep-equal.d.ts.map +1 -0
- package/dist/assert/deep-equal.js +36 -0
- package/dist/assert/deep-equal.js.map +1 -0
- package/dist/assert/deep-has-property.cjs +68 -0
- package/dist/assert/deep-has-property.cjs.map +1 -0
- package/dist/assert/deep-has-property.d.cts +22 -0
- package/dist/assert/deep-has-property.d.cts.map +1 -0
- package/dist/assert/deep-has-property.d.ts +22 -0
- package/dist/assert/deep-has-property.d.ts.map +1 -0
- package/dist/assert/deep-has-property.js +63 -0
- package/dist/assert/deep-has-property.js.map +1 -0
- package/dist/assert/ends-with.cjs +30 -0
- package/dist/assert/ends-with.cjs.map +1 -0
- package/dist/assert/ends-with.d.cts +13 -0
- package/dist/assert/ends-with.d.cts.map +1 -0
- package/dist/assert/ends-with.d.ts +13 -0
- package/dist/assert/ends-with.d.ts.map +1 -0
- package/dist/assert/ends-with.js +27 -0
- package/dist/assert/ends-with.js.map +1 -0
- package/dist/assert/equal.cjs +37 -0
- package/dist/assert/equal.cjs.map +1 -0
- package/dist/assert/equal.d.cts +11 -0
- package/dist/assert/equal.d.cts.map +1 -0
- package/dist/assert/equal.d.ts +11 -0
- package/dist/assert/equal.d.ts.map +1 -0
- package/dist/assert/equal.js +34 -0
- package/dist/assert/equal.js.map +1 -0
- package/dist/assert/greater-than-equal.cjs +32 -0
- package/dist/assert/greater-than-equal.cjs.map +1 -0
- package/dist/assert/greater-than-equal.d.cts +11 -0
- package/dist/assert/greater-than-equal.d.cts.map +1 -0
- package/dist/assert/greater-than-equal.d.ts +11 -0
- package/dist/assert/greater-than-equal.d.ts.map +1 -0
- package/dist/assert/greater-than-equal.js +29 -0
- package/dist/assert/greater-than-equal.js.map +1 -0
- package/dist/assert/greater-than.cjs +33 -0
- package/dist/assert/greater-than.cjs.map +1 -0
- package/dist/assert/greater-than.d.cts +11 -0
- package/dist/assert/greater-than.d.cts.map +1 -0
- package/dist/assert/greater-than.d.ts +11 -0
- package/dist/assert/greater-than.d.ts.map +1 -0
- package/dist/assert/greater-than.js +30 -0
- package/dist/assert/greater-than.js.map +1 -0
- package/dist/assert/has-keys.cjs +58 -0
- package/dist/assert/has-keys.cjs.map +1 -0
- package/dist/assert/has-keys.d.cts +16 -0
- package/dist/assert/has-keys.d.cts.map +1 -0
- package/dist/assert/has-keys.d.ts +16 -0
- package/dist/assert/has-keys.d.ts.map +1 -0
- package/dist/assert/has-keys.js +54 -0
- package/dist/assert/has-keys.js.map +1 -0
- package/dist/assert/has-members.cjs +67 -0
- package/dist/assert/has-members.cjs.map +1 -0
- package/dist/assert/has-members.d.cts +48 -0
- package/dist/assert/has-members.d.cts.map +1 -0
- package/dist/assert/has-members.d.ts +48 -0
- package/dist/assert/has-members.d.ts.map +1 -0
- package/dist/assert/has-members.js +64 -0
- package/dist/assert/has-members.js.map +1 -0
- package/dist/assert/has-property.cjs +61 -0
- package/dist/assert/has-property.cjs.map +1 -0
- package/dist/assert/has-property.d.cts +22 -0
- package/dist/assert/has-property.d.cts.map +1 -0
- package/dist/assert/has-property.d.ts +22 -0
- package/dist/assert/has-property.d.ts.map +1 -0
- package/dist/assert/has-property.js +58 -0
- package/dist/assert/has-property.js.map +1 -0
- package/dist/assert/has-size.cjs +122 -0
- package/dist/assert/has-size.cjs.map +1 -0
- package/dist/assert/has-size.d.cts +42 -0
- package/dist/assert/has-size.d.cts.map +1 -0
- package/dist/assert/has-size.d.ts +42 -0
- package/dist/assert/has-size.d.ts.map +1 -0
- package/dist/assert/has-size.js +118 -0
- package/dist/assert/has-size.js.map +1 -0
- package/dist/assert/in-ballpark.cjs +44 -0
- package/dist/assert/in-ballpark.cjs.map +1 -0
- package/dist/assert/in-ballpark.d.cts +16 -0
- package/dist/assert/in-ballpark.d.cts.map +1 -0
- package/dist/assert/in-ballpark.d.ts +16 -0
- package/dist/assert/in-ballpark.d.ts.map +1 -0
- package/dist/assert/in-ballpark.js +41 -0
- package/dist/assert/in-ballpark.js.map +1 -0
- package/dist/assert/includes.cjs +30 -0
- package/dist/assert/includes.cjs.map +1 -0
- package/dist/assert/includes.d.cts +24 -0
- package/dist/assert/includes.d.cts.map +1 -0
- package/dist/assert/includes.d.ts +24 -0
- package/dist/assert/includes.d.ts.map +1 -0
- package/dist/assert/includes.js +27 -0
- package/dist/assert/includes.js.map +1 -0
- package/dist/assert/instance-of.cjs +36 -0
- package/dist/assert/instance-of.cjs.map +1 -0
- package/dist/assert/instance-of.d.cts +16 -0
- package/dist/assert/instance-of.d.cts.map +1 -0
- package/dist/assert/instance-of.d.ts +16 -0
- package/dist/assert/instance-of.d.ts.map +1 -0
- package/dist/assert/instance-of.js +32 -0
- package/dist/assert/instance-of.js.map +1 -0
- package/dist/assert/is-after.cjs +29 -0
- package/dist/assert/is-after.cjs.map +1 -0
- package/dist/assert/is-after.d.cts +11 -0
- package/dist/assert/is-after.d.cts.map +1 -0
- package/dist/assert/is-after.d.ts +11 -0
- package/dist/assert/is-after.d.ts.map +1 -0
- package/dist/assert/is-after.js +26 -0
- package/dist/assert/is-after.js.map +1 -0
- package/dist/assert/is-before.cjs +29 -0
- package/dist/assert/is-before.cjs.map +1 -0
- package/dist/assert/is-before.d.cts +11 -0
- package/dist/assert/is-before.d.cts.map +1 -0
- package/dist/assert/is-before.d.ts +11 -0
- package/dist/assert/is-before.d.ts.map +1 -0
- package/dist/assert/is-before.js +26 -0
- package/dist/assert/is-before.js.map +1 -0
- package/dist/assert/is-between.cjs +47 -0
- package/dist/assert/is-between.cjs.map +1 -0
- package/dist/assert/is-between.d.cts +15 -0
- package/dist/assert/is-between.d.cts.map +1 -0
- package/dist/assert/is-between.d.ts +15 -0
- package/dist/assert/is-between.d.ts.map +1 -0
- package/dist/assert/is-between.js +44 -0
- package/dist/assert/is-between.js.map +1 -0
- package/dist/assert/is-empty.cjs +98 -0
- package/dist/assert/is-empty.cjs.map +1 -0
- package/dist/assert/is-empty.d.cts +31 -0
- package/dist/assert/is-empty.d.cts.map +1 -0
- package/dist/assert/is-empty.d.ts +31 -0
- package/dist/assert/is-empty.d.ts.map +1 -0
- package/dist/assert/is-empty.js +94 -0
- package/dist/assert/is-empty.js.map +1 -0
- package/dist/assert/is-type.cjs +34 -0
- package/dist/assert/is-type.cjs.map +1 -0
- package/dist/assert/is-type.d.cts +97 -0
- package/dist/assert/is-type.d.cts.map +1 -0
- package/dist/assert/is-type.d.ts +97 -0
- package/dist/assert/is-type.d.ts.map +1 -0
- package/dist/assert/is-type.js +31 -0
- package/dist/assert/is-type.js.map +1 -0
- package/dist/assert/less-than-equal.cjs +36 -0
- package/dist/assert/less-than-equal.cjs.map +1 -0
- package/dist/assert/less-than-equal.d.cts +11 -0
- package/dist/assert/less-than-equal.d.cts.map +1 -0
- package/dist/assert/less-than-equal.d.ts +11 -0
- package/dist/assert/less-than-equal.d.ts.map +1 -0
- package/dist/assert/less-than-equal.js +33 -0
- package/dist/assert/less-than-equal.js.map +1 -0
- package/dist/assert/less-than.cjs +34 -0
- package/dist/assert/less-than.cjs.map +1 -0
- package/dist/assert/less-than.d.cts +11 -0
- package/dist/assert/less-than.d.cts.map +1 -0
- package/dist/assert/less-than.d.ts +11 -0
- package/dist/assert/less-than.d.ts.map +1 -0
- package/dist/assert/less-than.js +31 -0
- package/dist/assert/less-than.js.map +1 -0
- package/dist/assert/match.cjs +31 -0
- package/dist/assert/match.cjs.map +1 -0
- package/dist/assert/match.d.cts +15 -0
- package/dist/assert/match.d.cts.map +1 -0
- package/dist/assert/match.d.ts +15 -0
- package/dist/assert/match.d.ts.map +1 -0
- package/dist/assert/match.js +28 -0
- package/dist/assert/match.js.map +1 -0
- package/dist/assert/rejects.cjs +49 -0
- package/dist/assert/rejects.cjs.map +1 -0
- package/dist/assert/rejects.d.cts +36 -0
- package/dist/assert/rejects.d.cts.map +1 -0
- package/dist/assert/rejects.d.ts +36 -0
- package/dist/assert/rejects.d.ts.map +1 -0
- package/dist/assert/rejects.js +46 -0
- package/dist/assert/rejects.js.map +1 -0
- package/dist/assert/round-to.cjs +54 -0
- package/dist/assert/round-to.cjs.map +1 -0
- package/dist/assert/round-to.d.cts +15 -0
- package/dist/assert/round-to.d.cts.map +1 -0
- package/dist/assert/round-to.d.ts +15 -0
- package/dist/assert/round-to.d.ts.map +1 -0
- package/dist/assert/round-to.js +51 -0
- package/dist/assert/round-to.js.map +1 -0
- package/dist/assert/starts-with.cjs +30 -0
- package/dist/assert/starts-with.cjs.map +1 -0
- package/dist/assert/starts-with.d.cts +14 -0
- package/dist/assert/starts-with.d.cts.map +1 -0
- package/dist/assert/starts-with.d.ts +14 -0
- package/dist/assert/starts-with.d.ts.map +1 -0
- package/dist/assert/starts-with.js +27 -0
- package/dist/assert/starts-with.js.map +1 -0
- package/dist/assert/throws.cjs +41 -0
- package/dist/assert/throws.cjs.map +1 -0
- package/dist/{throws-CYLYG7gu.d.cts → assert/throws.d.cts} +4 -11
- package/dist/assert/throws.d.cts.map +1 -0
- package/dist/{throws-BlzO4xvg.d.ts → assert/throws.d.ts} +3 -12
- package/dist/assert/throws.d.ts.map +1 -0
- package/dist/assert/throws.js +38 -0
- package/dist/assert/throws.js.map +1 -0
- package/dist/assert.cjs +143 -52
- package/dist/assert.cjs.map +1 -0
- package/dist/assert.d.cts +34 -3
- package/dist/assert.d.cts.map +1 -0
- package/dist/assert.d.ts +34 -3
- package/dist/assert.d.ts.map +1 -0
- package/dist/assert.js +87 -2
- package/dist/assert.js.map +1 -0
- package/dist/expect/after.cjs +15 -0
- package/dist/expect/after.cjs.map +1 -0
- package/dist/expect/after.js +16 -0
- package/dist/expect/after.js.map +1 -0
- package/dist/expect/ballpark.cjs +15 -0
- package/dist/expect/ballpark.cjs.map +1 -0
- package/dist/expect/ballpark.js +16 -0
- package/dist/expect/ballpark.js.map +1 -0
- package/dist/expect/before.cjs +15 -0
- package/dist/expect/before.cjs.map +1 -0
- package/dist/expect/before.js +16 -0
- package/dist/expect/before.js.map +1 -0
- package/dist/expect/between.cjs +15 -0
- package/dist/expect/between.cjs.map +1 -0
- package/dist/expect/between.js +16 -0
- package/dist/expect/between.js.map +1 -0
- package/dist/expect/empty.cjs +15 -0
- package/dist/expect/empty.cjs.map +1 -0
- package/dist/expect/empty.js +16 -0
- package/dist/expect/empty.js.map +1 -0
- package/dist/expect/end-with.cjs +15 -0
- package/dist/expect/end-with.cjs.map +1 -0
- package/dist/expect/end-with.js +16 -0
- package/dist/expect/end-with.js.map +1 -0
- package/dist/expect/eql.cjs +21 -0
- package/dist/expect/eql.cjs.map +1 -0
- package/dist/expect/eql.js +22 -0
- package/dist/expect/eql.js.map +1 -0
- package/dist/expect/equal-shorthand.cjs +34 -0
- package/dist/expect/equal-shorthand.cjs.map +1 -0
- package/dist/expect/equal-shorthand.js +33 -0
- package/dist/expect/equal-shorthand.js.map +1 -0
- package/dist/expect/equal.cjs +27 -0
- package/dist/expect/equal.cjs.map +1 -0
- package/dist/expect/equal.js +28 -0
- package/dist/expect/equal.js.map +1 -0
- package/dist/expect/excluding.cjs +19 -0
- package/dist/expect/excluding.cjs.map +1 -0
- package/dist/expect/excluding.js +18 -0
- package/dist/expect/excluding.js.map +1 -0
- package/dist/expect/greater-than-equal.cjs +25 -0
- package/dist/expect/greater-than-equal.cjs.map +1 -0
- package/dist/expect/greater-than-equal.js +26 -0
- package/dist/expect/greater-than-equal.js.map +1 -0
- package/dist/expect/greater-than.cjs +25 -0
- package/dist/expect/greater-than.cjs.map +1 -0
- package/dist/expect/greater-than.js +26 -0
- package/dist/expect/greater-than.js.map +1 -0
- package/dist/expect/has-property.cjs +20 -0
- package/dist/expect/has-property.cjs.map +1 -0
- package/dist/expect/has-property.js +21 -0
- package/dist/expect/has-property.js.map +1 -0
- package/dist/expect/include.cjs +21 -0
- package/dist/expect/include.cjs.map +1 -0
- package/dist/expect/include.js +22 -0
- package/dist/expect/include.js.map +1 -0
- package/dist/expect/instance-of-shorthand.cjs +24 -0
- package/dist/expect/instance-of-shorthand.cjs.map +1 -0
- package/dist/expect/instance-of-shorthand.js +25 -0
- package/dist/expect/instance-of-shorthand.js.map +1 -0
- package/dist/expect/instance-of.cjs +15 -0
- package/dist/expect/instance-of.cjs.map +1 -0
- package/dist/expect/instance-of.js +16 -0
- package/dist/expect/instance-of.js.map +1 -0
- package/dist/expect/keys.cjs +15 -0
- package/dist/expect/keys.cjs.map +1 -0
- package/dist/expect/keys.js +16 -0
- package/dist/expect/keys.js.map +1 -0
- package/dist/expect/length.cjs +21 -0
- package/dist/expect/length.cjs.map +1 -0
- package/dist/expect/length.js +22 -0
- package/dist/expect/length.js.map +1 -0
- package/dist/expect/less-than-equal.cjs +25 -0
- package/dist/expect/less-than-equal.cjs.map +1 -0
- package/dist/expect/less-than-equal.js +26 -0
- package/dist/expect/less-than-equal.js.map +1 -0
- package/dist/expect/less-than.cjs +25 -0
- package/dist/expect/less-than.cjs.map +1 -0
- package/dist/expect/less-than.js +26 -0
- package/dist/expect/less-than.js.map +1 -0
- package/dist/expect/match.cjs +15 -0
- package/dist/expect/match.cjs.map +1 -0
- package/dist/expect/match.js +16 -0
- package/dist/expect/match.js.map +1 -0
- package/dist/expect/members.cjs +41 -0
- package/dist/expect/members.cjs.map +1 -0
- package/dist/expect/members.js +42 -0
- package/dist/expect/members.js.map +1 -0
- package/dist/expect/reject.cjs +14 -0
- package/dist/expect/reject.cjs.map +1 -0
- package/dist/expect/reject.js +15 -0
- package/dist/expect/reject.js.map +1 -0
- package/dist/expect/round-to.cjs +15 -0
- package/dist/expect/round-to.cjs.map +1 -0
- package/dist/expect/round-to.js +16 -0
- package/dist/expect/round-to.js.map +1 -0
- package/dist/expect/start-with.cjs +15 -0
- package/dist/expect/start-with.cjs.map +1 -0
- package/dist/expect/start-with.js +16 -0
- package/dist/expect/start-with.js.map +1 -0
- package/dist/expect/throw.cjs +14 -0
- package/dist/expect/throw.cjs.map +1 -0
- package/dist/expect/throw.js +15 -0
- package/dist/expect/throw.js.map +1 -0
- package/dist/expect/type-shorthand.cjs +29 -0
- package/dist/expect/type-shorthand.cjs.map +1 -0
- package/dist/expect/type-shorthand.js +30 -0
- package/dist/expect/type-shorthand.js.map +1 -0
- package/dist/expect/type.cjs +15 -0
- package/dist/expect/type.cjs.map +1 -0
- package/dist/expect/type.js +16 -0
- package/dist/expect/type.js.map +1 -0
- package/dist/expect.cjs +144 -0
- package/dist/expect.cjs.map +1 -0
- package/dist/expect.d.cts +10 -0
- package/dist/expect.d.cts.map +1 -0
- package/dist/expect.d.ts +10 -0
- package/dist/expect.d.ts.map +1 -0
- package/dist/expect.js +141 -0
- package/dist/expect.js.map +1 -0
- package/dist/expect.types.d.cts +67 -3
- package/dist/expect.types.d.cts.map +1 -0
- package/dist/expect.types.d.ts +67 -3
- package/dist/expect.types.d.ts.map +1 -0
- package/dist/index.cjs +13 -582
- package/dist/index.d.cts +8 -15
- package/dist/index.d.ts +8 -15
- package/dist/index.js +8 -575
- package/dist/mixins.cjs +11 -0
- package/dist/mixins.cjs.map +1 -0
- package/dist/mixins.d.cts +28 -0
- package/dist/mixins.d.cts.map +1 -0
- package/dist/mixins.d.ts +28 -0
- package/dist/mixins.d.ts.map +1 -0
- package/dist/mixins.js +9 -0
- package/dist/mixins.js.map +1 -0
- package/dist/utils/chain.cjs +20 -0
- package/dist/utils/chain.cjs.map +1 -0
- package/dist/utils/chain.js +18 -0
- package/dist/utils/chain.js.map +1 -0
- package/dist/utils/fail.cjs +16 -0
- package/dist/utils/fail.cjs.map +1 -0
- package/dist/utils/fail.d.cts +9 -0
- package/dist/utils/fail.d.cts.map +1 -0
- package/dist/utils/fail.d.ts +9 -0
- package/dist/utils/fail.d.ts.map +1 -0
- package/dist/utils/fail.js +14 -0
- package/dist/utils/fail.js.map +1 -0
- package/dist/utils/get-size.cjs +17 -0
- package/dist/utils/get-size.cjs.map +1 -0
- package/dist/utils/get-size.js +15 -0
- package/dist/utils/get-size.js.map +1 -0
- package/dist/utils/get-type.cjs +12 -0
- package/dist/utils/get-type.cjs.map +1 -0
- package/dist/utils/get-type.d.cts +5 -0
- package/dist/utils/get-type.d.cts.map +1 -0
- package/dist/utils/get-type.d.ts +5 -0
- package/dist/utils/get-type.d.ts.map +1 -0
- package/dist/utils/get-type.js +11 -0
- package/dist/utils/get-type.js.map +1 -0
- package/dist/utils/match.cjs +118 -0
- package/dist/utils/match.cjs.map +1 -0
- package/dist/utils/match.d.cts +7 -0
- package/dist/utils/match.d.cts.map +1 -0
- package/dist/utils/match.d.ts +7 -0
- package/dist/utils/match.d.ts.map +1 -0
- package/dist/utils/match.js +114 -0
- package/dist/utils/match.js.map +1 -0
- package/dist/utils/process-error.cjs +86 -0
- package/dist/utils/process-error.cjs.map +1 -0
- package/dist/utils/process-error.d.cts +8 -0
- package/dist/utils/process-error.d.cts.map +1 -0
- package/dist/utils/process-error.d.ts +10 -0
- package/dist/utils/process-error.d.ts.map +1 -0
- package/dist/utils/process-error.js +85 -0
- package/dist/utils/process-error.js.map +1 -0
- package/dist/utils/validate-numeric-and-dates.cjs +20 -0
- package/dist/utils/validate-numeric-and-dates.cjs.map +1 -0
- package/dist/utils/validate-numeric-and-dates.js +18 -0
- package/dist/utils/validate-numeric-and-dates.js.map +1 -0
- package/dist/utils/xor.cjs +9 -0
- package/dist/utils/xor.cjs.map +1 -0
- package/dist/utils/xor.js +8 -0
- package/dist/utils/xor.js.map +1 -0
- package/package.json +1 -1
- package/dist/assert-ChQPKP5C.d.cts +0 -480
- package/dist/assert-ChQPKP5C.d.cts.map +0 -1
- package/dist/assert-CsN7srt-.d.ts +0 -478
- package/dist/assert-CsN7srt-.d.ts.map +0 -1
- package/dist/assert-DZjgWjOw.cjs +0 -1626
- package/dist/assert-DZjgWjOw.cjs.map +0 -1
- package/dist/assert-kFXp7i_B.js +0 -1260
- package/dist/assert-kFXp7i_B.js.map +0 -1
- package/dist/expect.types-CHYPdbCW.d.cts +0 -454
- package/dist/expect.types-CHYPdbCW.d.cts.map +0 -1
- package/dist/expect.types-nBq4Rg8e.d.ts +0 -454
- package/dist/expect.types-nBq4Rg8e.d.ts.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/throws-BlzO4xvg.d.ts.map +0 -1
- package/dist/throws-CYLYG7gu.d.cts.map +0 -1
- /package/dist/{chunk-CTAAG5j7.js → _virtual/rolldown_runtime.js} +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/utils/chain.ts
|
|
2
|
+
const registerProperty = (object, name, value) => {
|
|
3
|
+
Object.defineProperty(object, name, {
|
|
4
|
+
enumerable: true,
|
|
5
|
+
get() {
|
|
6
|
+
return value();
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
return object;
|
|
10
|
+
};
|
|
11
|
+
const registerMethod = (object, name, value) => {
|
|
12
|
+
Object.defineProperty(object, name, { value });
|
|
13
|
+
return object;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { registerMethod, registerProperty };
|
|
18
|
+
//# sourceMappingURL=chain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain.js","names":[],"sources":["../../src/utils/chain.ts"],"sourcesContent":["export const registerProperty = <T, U extends string, V extends () => any>(object: T, name: U, value: V) => {\n Object.defineProperty(object, name, {\n enumerable: true,\n get() {\n return value();\n }\n });\n return object as T & Record<U, V>;\n};\n\nexport const registerMethod = <T, U extends string, V>(object: T, name: U, value: V) => {\n Object.defineProperty(object, name, {\n value\n });\n return object as T & Record<U, V>;\n};\n"],"mappings":";AAAA,MAAa,oBAA8D,QAAW,MAAS,UAAa;AACxG,QAAO,eAAe,QAAQ,MAAM;EAChC,YAAY;EACZ,MAAM;AACF,UAAO,OAAO;;EAErB,CAAC;AACF,QAAO;;AAGX,MAAa,kBAA0C,QAAW,MAAS,UAAa;AACpF,QAAO,eAAe,QAAQ,MAAM,EAChC,OACH,CAAC;AACF,QAAO"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let hein_assertion_utils = require("hein-assertion-utils");
|
|
3
|
+
hein_assertion_utils = require_rolldown_runtime.__toESM(hein_assertion_utils);
|
|
4
|
+
|
|
5
|
+
//#region src/utils/fail.ts
|
|
6
|
+
/**
|
|
7
|
+
* Throw an AssertionError
|
|
8
|
+
* @param {string} message - The message to pass to the AssertionError
|
|
9
|
+
*/
|
|
10
|
+
const fail = (message = "Fail") => {
|
|
11
|
+
throw new hein_assertion_utils.AssertionError(void 0, void 0, message);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
exports.fail = fail;
|
|
16
|
+
//# sourceMappingURL=fail.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fail.cjs","names":["AssertionError"],"sources":["../../src/utils/fail.ts"],"sourcesContent":["import { AssertionError } from 'hein-assertion-utils';\n\n/**\n * Throw an AssertionError\n * @param {string} message - The message to pass to the AssertionError\n */\nexport const fail = (message: string = 'Fail') => {\n throw new AssertionError(undefined, undefined, message);\n};\n"],"mappings":";;;;;;;;;AAMA,MAAa,QAAQ,UAAkB,WAAW;AAC9C,OAAM,IAAIA,oCAAe,QAAW,QAAW,QAAQ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fail.d.cts","names":[],"sources":["../../src/utils/fail.ts"],"sourcesContent":[],"mappings":";;AAMA;;;cAAa"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fail.d.ts","names":[],"sources":["../../src/utils/fail.ts"],"sourcesContent":[],"mappings":";;AAMA;;;cAAa"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AssertionError } from "hein-assertion-utils";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/fail.ts
|
|
4
|
+
/**
|
|
5
|
+
* Throw an AssertionError
|
|
6
|
+
* @param {string} message - The message to pass to the AssertionError
|
|
7
|
+
*/
|
|
8
|
+
const fail = (message = "Fail") => {
|
|
9
|
+
throw new AssertionError(void 0, void 0, message);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { fail };
|
|
14
|
+
//# sourceMappingURL=fail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fail.js","names":[],"sources":["../../src/utils/fail.ts"],"sourcesContent":["import { AssertionError } from 'hein-assertion-utils';\n\n/**\n * Throw an AssertionError\n * @param {string} message - The message to pass to the AssertionError\n */\nexport const fail = (message: string = 'Fail') => {\n throw new AssertionError(undefined, undefined, message);\n};\n"],"mappings":";;;;;;;AAMA,MAAa,QAAQ,UAAkB,WAAW;AAC9C,OAAM,IAAI,eAAe,QAAW,QAAW,QAAQ"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let lodash_isPlainObject_js = require("lodash/isPlainObject.js");
|
|
3
|
+
lodash_isPlainObject_js = require_rolldown_runtime.__toESM(lodash_isPlainObject_js);
|
|
4
|
+
|
|
5
|
+
//#region src/utils/get-size.ts
|
|
6
|
+
const getSize = (value) => {
|
|
7
|
+
if (Array.isArray(value)) return value.length;
|
|
8
|
+
if ((0, lodash_isPlainObject_js.default)(value)) return Object.keys(value).length;
|
|
9
|
+
if (value instanceof Map) return value.size;
|
|
10
|
+
if (value instanceof Set) return value.size;
|
|
11
|
+
if (typeof value === "string") return value.length;
|
|
12
|
+
return 0;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
exports.getSize = getSize;
|
|
17
|
+
//# sourceMappingURL=get-size.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-size.cjs","names":[],"sources":["../../src/utils/get-size.ts"],"sourcesContent":["import isPlainObject from 'lodash/isPlainObject.js';\n\nexport const getSize = (value: any) => {\n if (Array.isArray(value)) {\n return value.length;\n }\n if (isPlainObject(value)) {\n return Object.keys(value).length;\n }\n if (value instanceof Map) {\n return value.size;\n }\n if (value instanceof Set) {\n return value.size;\n }\n if (typeof value === 'string') {\n return value.length;\n }\n return 0;\n};\n"],"mappings":";;;;;AAEA,MAAa,WAAW,UAAe;AACnC,KAAI,MAAM,QAAQ,MAAM,CACpB,QAAO,MAAM;AAEjB,0CAAkB,MAAM,CACpB,QAAO,OAAO,KAAK,MAAM,CAAC;AAE9B,KAAI,iBAAiB,IACjB,QAAO,MAAM;AAEjB,KAAI,iBAAiB,IACjB,QAAO,MAAM;AAEjB,KAAI,OAAO,UAAU,SACjB,QAAO,MAAM;AAEjB,QAAO"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import isPlainObject from "lodash/isPlainObject.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/get-size.ts
|
|
4
|
+
const getSize = (value) => {
|
|
5
|
+
if (Array.isArray(value)) return value.length;
|
|
6
|
+
if (isPlainObject(value)) return Object.keys(value).length;
|
|
7
|
+
if (value instanceof Map) return value.size;
|
|
8
|
+
if (value instanceof Set) return value.size;
|
|
9
|
+
if (typeof value === "string") return value.length;
|
|
10
|
+
return 0;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { getSize };
|
|
15
|
+
//# sourceMappingURL=get-size.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-size.js","names":[],"sources":["../../src/utils/get-size.ts"],"sourcesContent":["import isPlainObject from 'lodash/isPlainObject.js';\n\nexport const getSize = (value: any) => {\n if (Array.isArray(value)) {\n return value.length;\n }\n if (isPlainObject(value)) {\n return Object.keys(value).length;\n }\n if (value instanceof Map) {\n return value.size;\n }\n if (value instanceof Set) {\n return value.size;\n }\n if (typeof value === 'string') {\n return value.length;\n }\n return 0;\n};\n"],"mappings":";;;AAEA,MAAa,WAAW,UAAe;AACnC,KAAI,MAAM,QAAQ,MAAM,CACpB,QAAO,MAAM;AAEjB,KAAI,cAAc,MAAM,CACpB,QAAO,OAAO,KAAK,MAAM,CAAC;AAE9B,KAAI,iBAAiB,IACjB,QAAO,MAAM;AAEjB,KAAI,iBAAiB,IACjB,QAAO,MAAM;AAEjB,KAAI,OAAO,UAAU,SACjB,QAAO,MAAM;AAEjB,QAAO"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/utils/get-type.ts
|
|
3
|
+
const getType = (value) => {
|
|
4
|
+
if (value !== value) return "NaN";
|
|
5
|
+
if (Array.isArray(value)) return "array";
|
|
6
|
+
if (value === null) return "null";
|
|
7
|
+
return typeof value;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
exports.getType = getType;
|
|
12
|
+
//# sourceMappingURL=get-type.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-type.cjs","names":[],"sources":["../../src/utils/get-type.ts"],"sourcesContent":["export type ValueType =\n | 'string'\n | 'number'\n | 'bigint'\n | 'boolean'\n | 'symbol'\n | 'undefined'\n | 'object'\n | 'function'\n | 'null'\n | 'NaN'\n | 'array';\n\nexport const getType = (value: any): ValueType => {\n if (value !== value) {\n return 'NaN';\n }\n if (Array.isArray(value)) {\n return 'array';\n }\n if (value === null) {\n return 'null';\n }\n return typeof value;\n};\n"],"mappings":";;AAaA,MAAa,WAAW,UAA0B;AAC9C,KAAI,UAAU,MACV,QAAO;AAEX,KAAI,MAAM,QAAQ,MAAM,CACpB,QAAO;AAEX,KAAI,UAAU,KACV,QAAO;AAEX,QAAO,OAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-type.d.cts","names":[],"sources":["../../src/utils/get-type.ts"],"sourcesContent":[],"mappings":";KAAY,SAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-type.d.ts","names":[],"sources":["../../src/utils/get-type.ts"],"sourcesContent":[],"mappings":";KAAY,SAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/utils/get-type.ts
|
|
2
|
+
const getType = (value) => {
|
|
3
|
+
if (value !== value) return "NaN";
|
|
4
|
+
if (Array.isArray(value)) return "array";
|
|
5
|
+
if (value === null) return "null";
|
|
6
|
+
return typeof value;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { getType };
|
|
11
|
+
//# sourceMappingURL=get-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-type.js","names":[],"sources":["../../src/utils/get-type.ts"],"sourcesContent":["export type ValueType =\n | 'string'\n | 'number'\n | 'bigint'\n | 'boolean'\n | 'symbol'\n | 'undefined'\n | 'object'\n | 'function'\n | 'null'\n | 'NaN'\n | 'array';\n\nexport const getType = (value: any): ValueType => {\n if (value !== value) {\n return 'NaN';\n }\n if (Array.isArray(value)) {\n return 'array';\n }\n if (value === null) {\n return 'null';\n }\n return typeof value;\n};\n"],"mappings":";AAaA,MAAa,WAAW,UAA0B;AAC9C,KAAI,UAAU,MACV,QAAO;AAEX,KAAI,MAAM,QAAQ,MAAM,CACpB,QAAO;AAEX,KAAI,UAAU,KACV,QAAO;AAEX,QAAO,OAAO"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_xor = require('./xor.cjs');
|
|
3
|
+
let lodash_isObjectLike_js = require("lodash/isObjectLike.js");
|
|
4
|
+
lodash_isObjectLike_js = require_rolldown_runtime.__toESM(lodash_isObjectLike_js);
|
|
5
|
+
|
|
6
|
+
//#region src/utils/match.ts
|
|
7
|
+
const evaluationSymbol = Symbol();
|
|
8
|
+
const createEvaluation = (callback) => {
|
|
9
|
+
const evaluation = (value) => {
|
|
10
|
+
return callback(value);
|
|
11
|
+
};
|
|
12
|
+
evaluation[evaluationSymbol] = true;
|
|
13
|
+
return evaluation;
|
|
14
|
+
};
|
|
15
|
+
const any = createEvaluation(() => true);
|
|
16
|
+
const isEvaluation = (value) => value && value[evaluationSymbol];
|
|
17
|
+
const match = (actual, expected, { mutate = false, partial = false } = {}) => {
|
|
18
|
+
if (actual === expected) return true;
|
|
19
|
+
if (isEvaluation(expected)) return expected(actual);
|
|
20
|
+
if (actual == null || expected == null || !(0, lodash_isObjectLike_js.default)(actual) && !(0, lodash_isObjectLike_js.default)(expected)) return actual !== actual && expected !== expected;
|
|
21
|
+
let result = true;
|
|
22
|
+
if (actual instanceof Map || expected instanceof Map) {
|
|
23
|
+
if (!(actual instanceof Map && expected instanceof Map)) return false;
|
|
24
|
+
if (actual.size !== expected.size && !partial) result = false;
|
|
25
|
+
for (const [key, value] of expected.entries()) {
|
|
26
|
+
if (!actual.has(key)) {
|
|
27
|
+
result = false;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const actualValue = actual.get(key);
|
|
31
|
+
if (mutate && isEvaluation(value)) {
|
|
32
|
+
expected.set(key, actualValue);
|
|
33
|
+
result && (result = value(actualValue));
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
result = match(actualValue, value, {
|
|
37
|
+
mutate,
|
|
38
|
+
partial
|
|
39
|
+
}) && result;
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
if (actual instanceof WeakMap || expected instanceof WeakMap) return false;
|
|
45
|
+
if (actual instanceof Set || expected instanceof Set) {
|
|
46
|
+
if (!(actual instanceof Set && expected instanceof Set)) return false;
|
|
47
|
+
if (actual.size !== expected.size && !partial) return false;
|
|
48
|
+
return [...expected.values()].every((value) => {
|
|
49
|
+
return actual.has(value);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
if (actual instanceof WeakSet || expected instanceof WeakSet) return false;
|
|
53
|
+
if (actual instanceof Date || expected instanceof Date) {
|
|
54
|
+
if (!(actual instanceof Date && expected instanceof Date)) {
|
|
55
|
+
const date1 = new Date(actual);
|
|
56
|
+
const date2 = new Date(expected);
|
|
57
|
+
return date1.getTime() === date2.getTime();
|
|
58
|
+
}
|
|
59
|
+
if (actual.getTime() !== expected.getTime()) return false;
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
if (require_xor.xor((0, lodash_isObjectLike_js.default)(actual), (0, lodash_isObjectLike_js.default)(expected))) return false;
|
|
63
|
+
if (Array.isArray(actual) || Array.isArray(expected)) {
|
|
64
|
+
if (!(Array.isArray(actual) && Array.isArray(expected))) return false;
|
|
65
|
+
if (actual.length !== expected.length && !partial) result = false;
|
|
66
|
+
if (partial && actual.length < expected.length) result = false;
|
|
67
|
+
for (const [index, value] of actual.entries()) {
|
|
68
|
+
if (index >= expected.length) continue;
|
|
69
|
+
const expectedValue = expected[index];
|
|
70
|
+
if (mutate && isEvaluation(expectedValue)) {
|
|
71
|
+
const matchesEvaluation = expectedValue(value);
|
|
72
|
+
if (matchesEvaluation) expected[index] = value;
|
|
73
|
+
result && (result = matchesEvaluation);
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
result && (result = match(value, expectedValue, {
|
|
77
|
+
mutate,
|
|
78
|
+
partial
|
|
79
|
+
}));
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
if (Object.keys(actual).length !== Object.keys(expected).length && !partial) result = false;
|
|
85
|
+
if (globalThis.Buffer && actual instanceof globalThis.Buffer && expected instanceof globalThis.Buffer) return Buffer.compare(actual, expected) === 0;
|
|
86
|
+
for (const key in expected) if (!(key in actual)) {
|
|
87
|
+
result && (result = false);
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
for (const index in actual) {
|
|
91
|
+
const expectedValue = expected[index];
|
|
92
|
+
const actualValue = actual[index];
|
|
93
|
+
if (!(index in expected)) {
|
|
94
|
+
if (partial) continue;
|
|
95
|
+
result && (result = false);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (isEvaluation(expectedValue)) {
|
|
99
|
+
if (!expectedValue(actualValue)) {
|
|
100
|
+
result && (result = false);
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (mutate) expected[index] = actualValue;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (!match(actual[index], expectedValue, {
|
|
107
|
+
mutate,
|
|
108
|
+
partial
|
|
109
|
+
})) result = false;
|
|
110
|
+
}
|
|
111
|
+
return result;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
//#endregion
|
|
115
|
+
exports.any = any;
|
|
116
|
+
exports.createEvaluation = createEvaluation;
|
|
117
|
+
exports.match = match;
|
|
118
|
+
//# sourceMappingURL=match.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match.cjs","names":["evaluationSymbol: unique symbol","xor"],"sources":["../../src/utils/match.ts"],"sourcesContent":["import isObjectLike from 'lodash/isObjectLike.js';\nimport { xor } from './xor.js';\n\nconst evaluationSymbol: unique symbol = Symbol();\n\ninterface Evaluation {\n [evaluationSymbol]: true;\n (value: any): boolean;\n}\n\nexport const createEvaluation = (callback: (value: any) => boolean): any => {\n const evaluation = (value: any): boolean => {\n return callback(value);\n };\n evaluation[evaluationSymbol] = true;\n return evaluation as Evaluation;\n};\n\nexport const any = createEvaluation(() => true);\n\nexport const isEvaluation = (value: any): value is Evaluation => value && value[evaluationSymbol];\n\ninterface MatchOptions {\n mutate?: boolean;\n partial?: boolean;\n}\n\nexport const match = <T>(actual: T, expected: T, { mutate = false, partial = false }: MatchOptions = {}): boolean => {\n if (actual === expected) {\n return true;\n }\n if (isEvaluation(expected)) {\n return expected(actual);\n }\n\n if (actual == null || expected == null || (!isObjectLike(actual) && !isObjectLike(expected))) {\n return actual !== actual && expected !== expected;\n }\n let result = true;\n if (actual instanceof Map || expected instanceof Map) {\n if (!(actual instanceof Map && expected instanceof Map)) {\n return false;\n }\n if (actual.size !== expected.size && !partial) {\n result = false;\n }\n for (const [key, value] of expected.entries()) {\n if (!actual.has(key)) {\n result = false;\n continue;\n }\n const actualValue = actual.get(key);\n if (mutate && isEvaluation(value)) {\n expected.set(key, actualValue);\n result &&= value(actualValue);\n continue;\n }\n result = match(actualValue, value, { mutate, partial }) && result;\n continue;\n }\n return result;\n }\n if (actual instanceof WeakMap || expected instanceof WeakMap) {\n return false;\n }\n if (actual instanceof Set || expected instanceof Set) {\n if (!(actual instanceof Set && expected instanceof Set)) {\n return false;\n }\n if (actual.size !== expected.size && !partial) {\n return false;\n }\n return [...expected.values()].every((value) => {\n return actual.has(value);\n });\n }\n if (actual instanceof WeakSet || expected instanceof WeakSet) {\n return false;\n }\n if (actual instanceof Date || expected instanceof Date) {\n if (!(actual instanceof Date && expected instanceof Date)) {\n const date1 = new Date(actual as any);\n const date2 = new Date(expected as any);\n return date1.getTime() === date2.getTime();\n }\n if (actual.getTime() !== expected.getTime()) {\n return false;\n }\n return true;\n }\n if (xor(isObjectLike(actual), isObjectLike(expected))) {\n return false;\n }\n if (Array.isArray(actual) || Array.isArray(expected)) {\n if (!(Array.isArray(actual) && Array.isArray(expected))) {\n return false;\n }\n if (actual.length !== expected.length && !partial) {\n result = false;\n }\n if (partial && actual.length < expected.length) {\n result = false;\n }\n for (const [index, value] of actual.entries()) {\n if (index >= expected.length) {\n continue;\n }\n const expectedValue = expected[index];\n if (mutate && isEvaluation(expectedValue)) {\n const matchesEvaluation = expectedValue(value);\n if (matchesEvaluation) {\n expected[index] = value;\n }\n result &&= matchesEvaluation;\n continue;\n }\n result &&= match(value, expectedValue, { mutate, partial });\n continue;\n }\n return result;\n }\n if (Object.keys(actual).length !== Object.keys(expected).length && !partial) {\n result = false;\n }\n if (globalThis.Buffer && actual instanceof globalThis.Buffer && expected instanceof globalThis.Buffer) {\n return Buffer.compare(actual, expected) === 0;\n }\n for (const key in expected) {\n if (!(key in (actual as object))) {\n result &&= false;\n continue;\n }\n }\n for (const index in actual) {\n const expectedValue = expected[index];\n const actualValue = actual[index];\n if (!(index in (expected as object))) {\n if (partial) {\n continue;\n }\n result &&= false;\n continue;\n }\n if (isEvaluation(expectedValue)) {\n if (!expectedValue(actualValue)) {\n result &&= false;\n continue;\n }\n if (mutate) {\n expected[index] = actualValue;\n }\n continue;\n }\n if (!match(actual[index], expectedValue, { mutate, partial })) {\n result = false;\n }\n }\n return result;\n};\n"],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match.d.cts","names":[],"sources":["../../src/utils/match.ts"],"sourcesContent":[],"mappings":";;cAUa;cAQA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match.d.ts","names":[],"sources":["../../src/utils/match.ts"],"sourcesContent":[],"mappings":";;cAUa;cAQA"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { xor } from "./xor.js";
|
|
2
|
+
import isObjectLike from "lodash/isObjectLike.js";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/match.ts
|
|
5
|
+
const evaluationSymbol = Symbol();
|
|
6
|
+
const createEvaluation = (callback) => {
|
|
7
|
+
const evaluation = (value) => {
|
|
8
|
+
return callback(value);
|
|
9
|
+
};
|
|
10
|
+
evaluation[evaluationSymbol] = true;
|
|
11
|
+
return evaluation;
|
|
12
|
+
};
|
|
13
|
+
const any = createEvaluation(() => true);
|
|
14
|
+
const isEvaluation = (value) => value && value[evaluationSymbol];
|
|
15
|
+
const match = (actual, expected, { mutate = false, partial = false } = {}) => {
|
|
16
|
+
if (actual === expected) return true;
|
|
17
|
+
if (isEvaluation(expected)) return expected(actual);
|
|
18
|
+
if (actual == null || expected == null || !isObjectLike(actual) && !isObjectLike(expected)) return actual !== actual && expected !== expected;
|
|
19
|
+
let result = true;
|
|
20
|
+
if (actual instanceof Map || expected instanceof Map) {
|
|
21
|
+
if (!(actual instanceof Map && expected instanceof Map)) return false;
|
|
22
|
+
if (actual.size !== expected.size && !partial) result = false;
|
|
23
|
+
for (const [key, value] of expected.entries()) {
|
|
24
|
+
if (!actual.has(key)) {
|
|
25
|
+
result = false;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
const actualValue = actual.get(key);
|
|
29
|
+
if (mutate && isEvaluation(value)) {
|
|
30
|
+
expected.set(key, actualValue);
|
|
31
|
+
result && (result = value(actualValue));
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
result = match(actualValue, value, {
|
|
35
|
+
mutate,
|
|
36
|
+
partial
|
|
37
|
+
}) && result;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
if (actual instanceof WeakMap || expected instanceof WeakMap) return false;
|
|
43
|
+
if (actual instanceof Set || expected instanceof Set) {
|
|
44
|
+
if (!(actual instanceof Set && expected instanceof Set)) return false;
|
|
45
|
+
if (actual.size !== expected.size && !partial) return false;
|
|
46
|
+
return [...expected.values()].every((value) => {
|
|
47
|
+
return actual.has(value);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
if (actual instanceof WeakSet || expected instanceof WeakSet) return false;
|
|
51
|
+
if (actual instanceof Date || expected instanceof Date) {
|
|
52
|
+
if (!(actual instanceof Date && expected instanceof Date)) {
|
|
53
|
+
const date1 = new Date(actual);
|
|
54
|
+
const date2 = new Date(expected);
|
|
55
|
+
return date1.getTime() === date2.getTime();
|
|
56
|
+
}
|
|
57
|
+
if (actual.getTime() !== expected.getTime()) return false;
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
if (xor(isObjectLike(actual), isObjectLike(expected))) return false;
|
|
61
|
+
if (Array.isArray(actual) || Array.isArray(expected)) {
|
|
62
|
+
if (!(Array.isArray(actual) && Array.isArray(expected))) return false;
|
|
63
|
+
if (actual.length !== expected.length && !partial) result = false;
|
|
64
|
+
if (partial && actual.length < expected.length) result = false;
|
|
65
|
+
for (const [index, value] of actual.entries()) {
|
|
66
|
+
if (index >= expected.length) continue;
|
|
67
|
+
const expectedValue = expected[index];
|
|
68
|
+
if (mutate && isEvaluation(expectedValue)) {
|
|
69
|
+
const matchesEvaluation = expectedValue(value);
|
|
70
|
+
if (matchesEvaluation) expected[index] = value;
|
|
71
|
+
result && (result = matchesEvaluation);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
result && (result = match(value, expectedValue, {
|
|
75
|
+
mutate,
|
|
76
|
+
partial
|
|
77
|
+
}));
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
if (Object.keys(actual).length !== Object.keys(expected).length && !partial) result = false;
|
|
83
|
+
if (globalThis.Buffer && actual instanceof globalThis.Buffer && expected instanceof globalThis.Buffer) return Buffer.compare(actual, expected) === 0;
|
|
84
|
+
for (const key in expected) if (!(key in actual)) {
|
|
85
|
+
result && (result = false);
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
for (const index in actual) {
|
|
89
|
+
const expectedValue = expected[index];
|
|
90
|
+
const actualValue = actual[index];
|
|
91
|
+
if (!(index in expected)) {
|
|
92
|
+
if (partial) continue;
|
|
93
|
+
result && (result = false);
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (isEvaluation(expectedValue)) {
|
|
97
|
+
if (!expectedValue(actualValue)) {
|
|
98
|
+
result && (result = false);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (mutate) expected[index] = actualValue;
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
if (!match(actual[index], expectedValue, {
|
|
105
|
+
mutate,
|
|
106
|
+
partial
|
|
107
|
+
})) result = false;
|
|
108
|
+
}
|
|
109
|
+
return result;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
//#endregion
|
|
113
|
+
export { any, createEvaluation, match };
|
|
114
|
+
//# sourceMappingURL=match.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match.js","names":["evaluationSymbol: unique symbol"],"sources":["../../src/utils/match.ts"],"sourcesContent":["import isObjectLike from 'lodash/isObjectLike.js';\nimport { xor } from './xor.js';\n\nconst evaluationSymbol: unique symbol = Symbol();\n\ninterface Evaluation {\n [evaluationSymbol]: true;\n (value: any): boolean;\n}\n\nexport const createEvaluation = (callback: (value: any) => boolean): any => {\n const evaluation = (value: any): boolean => {\n return callback(value);\n };\n evaluation[evaluationSymbol] = true;\n return evaluation as Evaluation;\n};\n\nexport const any = createEvaluation(() => true);\n\nexport const isEvaluation = (value: any): value is Evaluation => value && value[evaluationSymbol];\n\ninterface MatchOptions {\n mutate?: boolean;\n partial?: boolean;\n}\n\nexport const match = <T>(actual: T, expected: T, { mutate = false, partial = false }: MatchOptions = {}): boolean => {\n if (actual === expected) {\n return true;\n }\n if (isEvaluation(expected)) {\n return expected(actual);\n }\n\n if (actual == null || expected == null || (!isObjectLike(actual) && !isObjectLike(expected))) {\n return actual !== actual && expected !== expected;\n }\n let result = true;\n if (actual instanceof Map || expected instanceof Map) {\n if (!(actual instanceof Map && expected instanceof Map)) {\n return false;\n }\n if (actual.size !== expected.size && !partial) {\n result = false;\n }\n for (const [key, value] of expected.entries()) {\n if (!actual.has(key)) {\n result = false;\n continue;\n }\n const actualValue = actual.get(key);\n if (mutate && isEvaluation(value)) {\n expected.set(key, actualValue);\n result &&= value(actualValue);\n continue;\n }\n result = match(actualValue, value, { mutate, partial }) && result;\n continue;\n }\n return result;\n }\n if (actual instanceof WeakMap || expected instanceof WeakMap) {\n return false;\n }\n if (actual instanceof Set || expected instanceof Set) {\n if (!(actual instanceof Set && expected instanceof Set)) {\n return false;\n }\n if (actual.size !== expected.size && !partial) {\n return false;\n }\n return [...expected.values()].every((value) => {\n return actual.has(value);\n });\n }\n if (actual instanceof WeakSet || expected instanceof WeakSet) {\n return false;\n }\n if (actual instanceof Date || expected instanceof Date) {\n if (!(actual instanceof Date && expected instanceof Date)) {\n const date1 = new Date(actual as any);\n const date2 = new Date(expected as any);\n return date1.getTime() === date2.getTime();\n }\n if (actual.getTime() !== expected.getTime()) {\n return false;\n }\n return true;\n }\n if (xor(isObjectLike(actual), isObjectLike(expected))) {\n return false;\n }\n if (Array.isArray(actual) || Array.isArray(expected)) {\n if (!(Array.isArray(actual) && Array.isArray(expected))) {\n return false;\n }\n if (actual.length !== expected.length && !partial) {\n result = false;\n }\n if (partial && actual.length < expected.length) {\n result = false;\n }\n for (const [index, value] of actual.entries()) {\n if (index >= expected.length) {\n continue;\n }\n const expectedValue = expected[index];\n if (mutate && isEvaluation(expectedValue)) {\n const matchesEvaluation = expectedValue(value);\n if (matchesEvaluation) {\n expected[index] = value;\n }\n result &&= matchesEvaluation;\n continue;\n }\n result &&= match(value, expectedValue, { mutate, partial });\n continue;\n }\n return result;\n }\n if (Object.keys(actual).length !== Object.keys(expected).length && !partial) {\n result = false;\n }\n if (globalThis.Buffer && actual instanceof globalThis.Buffer && expected instanceof globalThis.Buffer) {\n return Buffer.compare(actual, expected) === 0;\n }\n for (const key in expected) {\n if (!(key in (actual as object))) {\n result &&= false;\n continue;\n }\n }\n for (const index in actual) {\n const expectedValue = expected[index];\n const actualValue = actual[index];\n if (!(index in (expected as object))) {\n if (partial) {\n continue;\n }\n result &&= false;\n continue;\n }\n if (isEvaluation(expectedValue)) {\n if (!expectedValue(actualValue)) {\n result &&= false;\n continue;\n }\n if (mutate) {\n expected[index] = actualValue;\n }\n continue;\n }\n if (!match(actual[index], expectedValue, { mutate, partial })) {\n result = false;\n }\n }\n return result;\n};\n"],"mappings":"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"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/utils/process-error.ts
|
|
3
|
+
const isConstructor = (value) => {
|
|
4
|
+
return typeof value === "function" && value.prototype && value.prototype.isPrototypeOf;
|
|
5
|
+
};
|
|
6
|
+
const processError = (report, error, narrowerOrMessage, message) => {
|
|
7
|
+
message = (typeof narrowerOrMessage === "string" ? narrowerOrMessage : message) ?? null;
|
|
8
|
+
if (!(error instanceof Error)) return report({
|
|
9
|
+
noStringify: true,
|
|
10
|
+
status: "notok",
|
|
11
|
+
messageId: "nonError",
|
|
12
|
+
actual: typeof error,
|
|
13
|
+
expected: "Error"
|
|
14
|
+
});
|
|
15
|
+
if (narrowerOrMessage) {
|
|
16
|
+
if (isConstructor(narrowerOrMessage)) {
|
|
17
|
+
if (!(error instanceof narrowerOrMessage)) return report({
|
|
18
|
+
noStringify: true,
|
|
19
|
+
status: "notok",
|
|
20
|
+
messageId: "invalidConstructor",
|
|
21
|
+
actual: error.name,
|
|
22
|
+
expected: narrowerOrMessage.name,
|
|
23
|
+
message
|
|
24
|
+
});
|
|
25
|
+
return report({
|
|
26
|
+
noStringify: true,
|
|
27
|
+
status: "ok",
|
|
28
|
+
messageId: "notConstructor",
|
|
29
|
+
actual: error.name,
|
|
30
|
+
expected: narrowerOrMessage.name,
|
|
31
|
+
message
|
|
32
|
+
});
|
|
33
|
+
} else if (typeof narrowerOrMessage === "function") {
|
|
34
|
+
if (!narrowerOrMessage(error)) return report({
|
|
35
|
+
noStringify: true,
|
|
36
|
+
status: "notok",
|
|
37
|
+
messageId: "predicate",
|
|
38
|
+
actual: error,
|
|
39
|
+
expected: null,
|
|
40
|
+
message
|
|
41
|
+
});
|
|
42
|
+
return report({
|
|
43
|
+
noStringify: true,
|
|
44
|
+
status: "ok",
|
|
45
|
+
messageId: "notPredicate",
|
|
46
|
+
actual: error,
|
|
47
|
+
expected: null,
|
|
48
|
+
message
|
|
49
|
+
});
|
|
50
|
+
} else if (typeof narrowerOrMessage === "string") return report({
|
|
51
|
+
noStringify: true,
|
|
52
|
+
status: "ok",
|
|
53
|
+
messageId: "throws",
|
|
54
|
+
actual: error,
|
|
55
|
+
message: narrowerOrMessage
|
|
56
|
+
});
|
|
57
|
+
else if (narrowerOrMessage instanceof RegExp) {
|
|
58
|
+
if (!narrowerOrMessage.test(error.message)) return report({
|
|
59
|
+
noStringify: true,
|
|
60
|
+
status: "notok",
|
|
61
|
+
messageId: "regex",
|
|
62
|
+
actual: error.message,
|
|
63
|
+
expected: narrowerOrMessage.toString(),
|
|
64
|
+
message
|
|
65
|
+
});
|
|
66
|
+
return report({
|
|
67
|
+
noStringify: true,
|
|
68
|
+
status: "ok",
|
|
69
|
+
messageId: "notRegex",
|
|
70
|
+
actual: error.message,
|
|
71
|
+
expected: narrowerOrMessage.toString(),
|
|
72
|
+
message
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return report({
|
|
77
|
+
noStringify: true,
|
|
78
|
+
status: "ok",
|
|
79
|
+
actual: error,
|
|
80
|
+
message
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
//#endregion
|
|
85
|
+
exports.processError = processError;
|
|
86
|
+
//# sourceMappingURL=process-error.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-error.cjs","names":[],"sources":["../../src/utils/process-error.ts"],"sourcesContent":["import { type Report } from 'hein-assertion-utils';\n\nexport interface Constructor<T = any> {\n new (...args: any[]): T;\n}\n\nexport type ErrorPredicate = (error: Error) => boolean;\n\nexport const isConstructor = (value: any): value is Constructor => {\n return typeof value === 'function' && value.prototype && value.prototype.isPrototypeOf;\n};\n\nexport const isErrorConstructor = (value: any): value is Constructor<Error> => {\n return isConstructor(value) && value.prototype instanceof Error;\n};\n\ntype ThrowsMessages =\n | 'invalidArgument'\n | 'nonError'\n | 'throws'\n | 'invalidConstructor'\n | 'predicate'\n | 'regex'\n | 'not'\n | 'notConstructor'\n | 'notPredicate'\n | 'notRegex';\n\nexport const processError = (report: Report<ThrowsMessages>, error: Error, narrowerOrMessage, message) => {\n message = (typeof narrowerOrMessage === 'string' ? narrowerOrMessage : message) ?? null;\n\n if (!(error instanceof Error)) {\n return report({\n noStringify: true,\n status: 'notok',\n messageId: 'nonError',\n actual: typeof error,\n expected: 'Error'\n });\n }\n if (narrowerOrMessage) {\n if (isConstructor(narrowerOrMessage)) {\n if (!(error instanceof narrowerOrMessage)) {\n return report({\n noStringify: true,\n status: 'notok',\n messageId: 'invalidConstructor',\n actual: error.name,\n expected: narrowerOrMessage.name,\n message\n });\n }\n return report({\n noStringify: true,\n status: 'ok',\n messageId: 'notConstructor',\n actual: error.name,\n expected: narrowerOrMessage.name,\n message\n });\n } else if (typeof narrowerOrMessage === 'function') {\n if (!(narrowerOrMessage as ErrorPredicate)(error)) {\n return report({\n noStringify: true,\n status: 'notok',\n messageId: 'predicate',\n actual: error,\n expected: null,\n message\n });\n }\n return report({\n noStringify: true,\n status: 'ok',\n messageId: 'notPredicate',\n actual: error,\n expected: null,\n message\n });\n } else if (typeof narrowerOrMessage === 'string') {\n return report({\n noStringify: true,\n status: 'ok',\n messageId: 'throws',\n actual: error,\n message: narrowerOrMessage\n });\n } else if (narrowerOrMessage instanceof RegExp) {\n if (!narrowerOrMessage.test(error.message)) {\n return report({\n noStringify: true,\n status: 'notok',\n messageId: 'regex',\n actual: error.message,\n expected: narrowerOrMessage.toString(),\n message\n });\n }\n return report({\n noStringify: true,\n status: 'ok',\n messageId: 'notRegex',\n actual: error.message,\n expected: narrowerOrMessage.toString(),\n message\n });\n }\n }\n return report({ noStringify: true, status: 'ok', actual: error, message });\n};\n"],"mappings":";;AAQA,MAAa,iBAAiB,UAAqC;AAC/D,QAAO,OAAO,UAAU,cAAc,MAAM,aAAa,MAAM,UAAU;;AAmB7E,MAAa,gBAAgB,QAAgC,OAAc,mBAAmB,YAAY;AACtG,YAAW,OAAO,sBAAsB,WAAW,oBAAoB,YAAY;AAEnF,KAAI,EAAE,iBAAiB,OACnB,QAAO,OAAO;EACV,aAAa;EACb,QAAQ;EACR,WAAW;EACX,QAAQ,OAAO;EACf,UAAU;EACb,CAAC;AAEN,KAAI,mBACA;MAAI,cAAc,kBAAkB,EAAE;AAClC,OAAI,EAAE,iBAAiB,mBACnB,QAAO,OAAO;IACV,aAAa;IACb,QAAQ;IACR,WAAW;IACX,QAAQ,MAAM;IACd,UAAU,kBAAkB;IAC5B;IACH,CAAC;AAEN,UAAO,OAAO;IACV,aAAa;IACb,QAAQ;IACR,WAAW;IACX,QAAQ,MAAM;IACd,UAAU,kBAAkB;IAC5B;IACH,CAAC;aACK,OAAO,sBAAsB,YAAY;AAChD,OAAI,CAAE,kBAAqC,MAAM,CAC7C,QAAO,OAAO;IACV,aAAa;IACb,QAAQ;IACR,WAAW;IACX,QAAQ;IACR,UAAU;IACV;IACH,CAAC;AAEN,UAAO,OAAO;IACV,aAAa;IACb,QAAQ;IACR,WAAW;IACX,QAAQ;IACR,UAAU;IACV;IACH,CAAC;aACK,OAAO,sBAAsB,SACpC,QAAO,OAAO;GACV,aAAa;GACb,QAAQ;GACR,WAAW;GACX,QAAQ;GACR,SAAS;GACZ,CAAC;WACK,6BAA6B,QAAQ;AAC5C,OAAI,CAAC,kBAAkB,KAAK,MAAM,QAAQ,CACtC,QAAO,OAAO;IACV,aAAa;IACb,QAAQ;IACR,WAAW;IACX,QAAQ,MAAM;IACd,UAAU,kBAAkB,UAAU;IACtC;IACH,CAAC;AAEN,UAAO,OAAO;IACV,aAAa;IACb,QAAQ;IACR,WAAW;IACX,QAAQ,MAAM;IACd,UAAU,kBAAkB,UAAU;IACtC;IACH,CAAC;;;AAGV,QAAO,OAAO;EAAE,aAAa;EAAM,QAAQ;EAAM,QAAQ;EAAO;EAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-error.d.cts","names":[],"sources":["../../src/utils/process-error.ts"],"sourcesContent":[],"mappings":";AAEiB,UAAA,WAAW,CACF,IAAC,GAAA,CAAA,CAAA;EAGf,KAAA,GAAA,IAAA,EAAA,GAAc,EAAA,CAAA,EAHA,CAGA;;KAAd,cAAA,WAAyB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "hein-assertion-utils";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/process-error.d.ts
|
|
4
|
+
interface Constructor<T = any> {
|
|
5
|
+
new (...args: any[]): T;
|
|
6
|
+
}
|
|
7
|
+
type ErrorPredicate = (error: Error) => boolean;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { Constructor, ErrorPredicate };
|
|
10
|
+
//# sourceMappingURL=process-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-error.d.ts","names":[],"sources":["../../src/utils/process-error.ts"],"sourcesContent":[],"mappings":";;;UAEiB;wBACS;AAD1B;AAIY,KAAA,cAAA,GAAc,CAAA,KAAW,EAAA,KAAK,EAAA,GAAA,OAAA"}
|