@effectionx/worker 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/message-channel.d.ts.map +1 -0
- package/dist/mod.d.ts +4 -0
- package/dist/mod.d.ts.map +1 -0
- package/dist/test-simple-worker.d.ts +2 -0
- package/dist/test-simple-worker.d.ts.map +1 -0
- package/dist/test-simple-worker.js +11 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types.d.ts.map +1 -0
- package/{esm → dist}/worker-main.d.ts +1 -1
- package/dist/worker-main.d.ts.map +1 -0
- package/{esm → dist}/worker-main.js +34 -16
- package/dist/worker.d.ts.map +1 -0
- package/{esm → dist}/worker.js +3 -4
- package/message-channel.ts +13 -0
- package/mod.ts +3 -0
- package/package.json +22 -16
- package/test-assets/boom-result-worker.ts +5 -0
- package/test-assets/boom-worker.ts +7 -0
- package/test-assets/counter-worker.ts +15 -0
- package/test-assets/crash-worker.ts +1 -0
- package/test-assets/echo-worker.ts +7 -0
- package/test-assets/result-worker.ts +5 -0
- package/test-assets/shutdown-worker.ts +24 -0
- package/test-assets/suspend-worker.ts +4 -0
- package/test-simple-worker.ts +12 -0
- package/tsconfig.json +20 -0
- package/types.ts +38 -0
- package/worker-main.ts +248 -0
- package/worker.test.ts +179 -0
- package/worker.ts +159 -0
- package/esm/_dnt.shims.d.ts +0 -2
- package/esm/_dnt.shims.d.ts.map +0 -1
- package/esm/_dnt.shims.js +0 -57
- package/esm/deps/jsr.io/@std/assert/1.0.16/almost_equals.d.ts +0 -29
- package/esm/deps/jsr.io/@std/assert/1.0.16/almost_equals.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/almost_equals.js +0 -46
- package/esm/deps/jsr.io/@std/assert/1.0.16/array_includes.d.ts +0 -24
- package/esm/deps/jsr.io/@std/assert/1.0.16/array_includes.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/array_includes.js +0 -46
- package/esm/deps/jsr.io/@std/assert/1.0.16/assert.d.ts +0 -16
- package/esm/deps/jsr.io/@std/assert/1.0.16/assert.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/assert.js +0 -22
- package/esm/deps/jsr.io/@std/assert/1.0.16/assertion_error.d.ts +0 -26
- package/esm/deps/jsr.io/@std/assert/1.0.16/assertion_error.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/assertion_error.js +0 -30
- package/esm/deps/jsr.io/@std/assert/1.0.16/equal.d.ts +0 -17
- package/esm/deps/jsr.io/@std/assert/1.0.16/equal.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/equal.js +0 -186
- package/esm/deps/jsr.io/@std/assert/1.0.16/equals.d.ts +0 -35
- package/esm/deps/jsr.io/@std/assert/1.0.16/equals.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/equals.js +0 -59
- package/esm/deps/jsr.io/@std/assert/1.0.16/exists.d.ts +0 -18
- package/esm/deps/jsr.io/@std/assert/1.0.16/exists.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/exists.js +0 -27
- package/esm/deps/jsr.io/@std/assert/1.0.16/fail.d.ts +0 -15
- package/esm/deps/jsr.io/@std/assert/1.0.16/fail.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/fail.js +0 -20
- package/esm/deps/jsr.io/@std/assert/1.0.16/false.d.ts +0 -18
- package/esm/deps/jsr.io/@std/assert/1.0.16/false.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/false.js +0 -22
- package/esm/deps/jsr.io/@std/assert/1.0.16/greater.d.ts +0 -20
- package/esm/deps/jsr.io/@std/assert/1.0.16/greater.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/greater.js +0 -29
- package/esm/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.d.ts +0 -20
- package/esm/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.js +0 -29
- package/esm/deps/jsr.io/@std/assert/1.0.16/instance_of.d.ts +0 -23
- package/esm/deps/jsr.io/@std/assert/1.0.16/instance_of.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/instance_of.js +0 -52
- package/esm/deps/jsr.io/@std/assert/1.0.16/is_error.d.ts +0 -25
- package/esm/deps/jsr.io/@std/assert/1.0.16/is_error.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/is_error.js +0 -53
- package/esm/deps/jsr.io/@std/assert/1.0.16/less.d.ts +0 -19
- package/esm/deps/jsr.io/@std/assert/1.0.16/less.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/less.js +0 -28
- package/esm/deps/jsr.io/@std/assert/1.0.16/less_or_equal.d.ts +0 -20
- package/esm/deps/jsr.io/@std/assert/1.0.16/less_or_equal.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/less_or_equal.js +0 -29
- package/esm/deps/jsr.io/@std/assert/1.0.16/match.d.ts +0 -18
- package/esm/deps/jsr.io/@std/assert/1.0.16/match.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/match.js +0 -26
- package/esm/deps/jsr.io/@std/assert/1.0.16/mod.d.ts +0 -44
- package/esm/deps/jsr.io/@std/assert/1.0.16/mod.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/mod.js +0 -45
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_equals.d.ts +0 -21
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_equals.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_equals.js +0 -33
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_instance_of.d.ts +0 -20
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_instance_of.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_instance_of.js +0 -29
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_match.d.ts +0 -18
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_match.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_match.js +0 -26
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.d.ts +0 -23
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.js +0 -32
- package/esm/deps/jsr.io/@std/assert/1.0.16/object_match.d.ts +0 -29
- package/esm/deps/jsr.io/@std/assert/1.0.16/object_match.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/object_match.js +0 -167
- package/esm/deps/jsr.io/@std/assert/1.0.16/rejects.d.ts +0 -42
- package/esm/deps/jsr.io/@std/assert/1.0.16/rejects.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/rejects.js +0 -53
- package/esm/deps/jsr.io/@std/assert/1.0.16/strict_equals.d.ts +0 -24
- package/esm/deps/jsr.io/@std/assert/1.0.16/strict_equals.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/strict_equals.js +0 -58
- package/esm/deps/jsr.io/@std/assert/1.0.16/string_includes.d.ts +0 -18
- package/esm/deps/jsr.io/@std/assert/1.0.16/string_includes.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/string_includes.js +0 -26
- package/esm/deps/jsr.io/@std/assert/1.0.16/throws.d.ts +0 -45
- package/esm/deps/jsr.io/@std/assert/1.0.16/throws.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/throws.js +0 -44
- package/esm/deps/jsr.io/@std/assert/1.0.16/unimplemented.d.ts +0 -15
- package/esm/deps/jsr.io/@std/assert/1.0.16/unimplemented.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/unimplemented.js +0 -20
- package/esm/deps/jsr.io/@std/assert/1.0.16/unreachable.d.ts +0 -15
- package/esm/deps/jsr.io/@std/assert/1.0.16/unreachable.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/unreachable.js +0 -20
- package/esm/deps/jsr.io/@std/internal/1.0.12/build_message.d.ts +0 -80
- package/esm/deps/jsr.io/@std/internal/1.0.12/build_message.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.12/build_message.js +0 -116
- package/esm/deps/jsr.io/@std/internal/1.0.12/diff.d.ts +0 -140
- package/esm/deps/jsr.io/@std/internal/1.0.12/diff.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.12/diff.js +0 -276
- package/esm/deps/jsr.io/@std/internal/1.0.12/diff_str.d.ts +0 -99
- package/esm/deps/jsr.io/@std/internal/1.0.12/diff_str.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.12/diff_str.js +0 -182
- package/esm/deps/jsr.io/@std/internal/1.0.12/format.d.ts +0 -29
- package/esm/deps/jsr.io/@std/internal/1.0.12/format.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.12/format.js +0 -70
- package/esm/deps/jsr.io/@std/internal/1.0.12/styles.d.ts +0 -159
- package/esm/deps/jsr.io/@std/internal/1.0.12/styles.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.12/styles.js +0 -207
- package/esm/deps/jsr.io/@std/internal/1.0.12/types.d.ts +0 -25
- package/esm/deps/jsr.io/@std/internal/1.0.12/types.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.12/types.js +0 -3
- package/esm/message-channel.d.ts.map +0 -1
- package/esm/mod.d.ts +0 -4
- package/esm/mod.d.ts.map +0 -1
- package/esm/package.json +0 -3
- package/esm/types.d.ts.map +0 -1
- package/esm/worker-main.d.ts.map +0 -1
- package/esm/worker.d.ts.map +0 -1
- package/script/_dnt.shims.d.ts +0 -2
- package/script/_dnt.shims.d.ts.map +0 -1
- package/script/_dnt.shims.js +0 -60
- package/script/deps/jsr.io/@std/assert/1.0.16/almost_equals.d.ts +0 -29
- package/script/deps/jsr.io/@std/assert/1.0.16/almost_equals.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/almost_equals.js +0 -49
- package/script/deps/jsr.io/@std/assert/1.0.16/array_includes.d.ts +0 -24
- package/script/deps/jsr.io/@std/assert/1.0.16/array_includes.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/array_includes.js +0 -49
- package/script/deps/jsr.io/@std/assert/1.0.16/assert.d.ts +0 -16
- package/script/deps/jsr.io/@std/assert/1.0.16/assert.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/assert.js +0 -25
- package/script/deps/jsr.io/@std/assert/1.0.16/assertion_error.d.ts +0 -26
- package/script/deps/jsr.io/@std/assert/1.0.16/assertion_error.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/assertion_error.js +0 -34
- package/script/deps/jsr.io/@std/assert/1.0.16/equal.d.ts +0 -17
- package/script/deps/jsr.io/@std/assert/1.0.16/equal.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/equal.js +0 -222
- package/script/deps/jsr.io/@std/assert/1.0.16/equals.d.ts +0 -35
- package/script/deps/jsr.io/@std/assert/1.0.16/equals.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/equals.js +0 -62
- package/script/deps/jsr.io/@std/assert/1.0.16/exists.d.ts +0 -18
- package/script/deps/jsr.io/@std/assert/1.0.16/exists.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/exists.js +0 -30
- package/script/deps/jsr.io/@std/assert/1.0.16/fail.d.ts +0 -15
- package/script/deps/jsr.io/@std/assert/1.0.16/fail.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/fail.js +0 -23
- package/script/deps/jsr.io/@std/assert/1.0.16/false.d.ts +0 -18
- package/script/deps/jsr.io/@std/assert/1.0.16/false.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/false.js +0 -25
- package/script/deps/jsr.io/@std/assert/1.0.16/greater.d.ts +0 -20
- package/script/deps/jsr.io/@std/assert/1.0.16/greater.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/greater.js +0 -32
- package/script/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.d.ts +0 -20
- package/script/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.js +0 -32
- package/script/deps/jsr.io/@std/assert/1.0.16/instance_of.d.ts +0 -23
- package/script/deps/jsr.io/@std/assert/1.0.16/instance_of.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/instance_of.js +0 -55
- package/script/deps/jsr.io/@std/assert/1.0.16/is_error.d.ts +0 -25
- package/script/deps/jsr.io/@std/assert/1.0.16/is_error.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/is_error.js +0 -56
- package/script/deps/jsr.io/@std/assert/1.0.16/less.d.ts +0 -19
- package/script/deps/jsr.io/@std/assert/1.0.16/less.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/less.js +0 -31
- package/script/deps/jsr.io/@std/assert/1.0.16/less_or_equal.d.ts +0 -20
- package/script/deps/jsr.io/@std/assert/1.0.16/less_or_equal.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/less_or_equal.js +0 -32
- package/script/deps/jsr.io/@std/assert/1.0.16/match.d.ts +0 -18
- package/script/deps/jsr.io/@std/assert/1.0.16/match.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/match.js +0 -29
- package/script/deps/jsr.io/@std/assert/1.0.16/mod.d.ts +0 -44
- package/script/deps/jsr.io/@std/assert/1.0.16/mod.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/mod.js +0 -61
- package/script/deps/jsr.io/@std/assert/1.0.16/not_equals.d.ts +0 -21
- package/script/deps/jsr.io/@std/assert/1.0.16/not_equals.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/not_equals.js +0 -36
- package/script/deps/jsr.io/@std/assert/1.0.16/not_instance_of.d.ts +0 -20
- package/script/deps/jsr.io/@std/assert/1.0.16/not_instance_of.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/not_instance_of.js +0 -32
- package/script/deps/jsr.io/@std/assert/1.0.16/not_match.d.ts +0 -18
- package/script/deps/jsr.io/@std/assert/1.0.16/not_match.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/not_match.js +0 -29
- package/script/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.d.ts +0 -23
- package/script/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.js +0 -35
- package/script/deps/jsr.io/@std/assert/1.0.16/object_match.d.ts +0 -29
- package/script/deps/jsr.io/@std/assert/1.0.16/object_match.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/object_match.js +0 -170
- package/script/deps/jsr.io/@std/assert/1.0.16/rejects.d.ts +0 -42
- package/script/deps/jsr.io/@std/assert/1.0.16/rejects.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/rejects.js +0 -56
- package/script/deps/jsr.io/@std/assert/1.0.16/strict_equals.d.ts +0 -24
- package/script/deps/jsr.io/@std/assert/1.0.16/strict_equals.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/strict_equals.js +0 -61
- package/script/deps/jsr.io/@std/assert/1.0.16/string_includes.d.ts +0 -18
- package/script/deps/jsr.io/@std/assert/1.0.16/string_includes.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/string_includes.js +0 -29
- package/script/deps/jsr.io/@std/assert/1.0.16/throws.d.ts +0 -45
- package/script/deps/jsr.io/@std/assert/1.0.16/throws.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/throws.js +0 -47
- package/script/deps/jsr.io/@std/assert/1.0.16/unimplemented.d.ts +0 -15
- package/script/deps/jsr.io/@std/assert/1.0.16/unimplemented.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/unimplemented.js +0 -23
- package/script/deps/jsr.io/@std/assert/1.0.16/unreachable.d.ts +0 -15
- package/script/deps/jsr.io/@std/assert/1.0.16/unreachable.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/unreachable.js +0 -23
- package/script/deps/jsr.io/@std/internal/1.0.12/build_message.d.ts +0 -80
- package/script/deps/jsr.io/@std/internal/1.0.12/build_message.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.12/build_message.js +0 -121
- package/script/deps/jsr.io/@std/internal/1.0.12/diff.d.ts +0 -140
- package/script/deps/jsr.io/@std/internal/1.0.12/diff.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.12/diff.js +0 -283
- package/script/deps/jsr.io/@std/internal/1.0.12/diff_str.d.ts +0 -99
- package/script/deps/jsr.io/@std/internal/1.0.12/diff_str.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.12/diff_str.js +0 -188
- package/script/deps/jsr.io/@std/internal/1.0.12/format.d.ts +0 -29
- package/script/deps/jsr.io/@std/internal/1.0.12/format.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.12/format.js +0 -106
- package/script/deps/jsr.io/@std/internal/1.0.12/styles.d.ts +0 -159
- package/script/deps/jsr.io/@std/internal/1.0.12/styles.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.12/styles.js +0 -252
- package/script/deps/jsr.io/@std/internal/1.0.12/types.d.ts +0 -25
- package/script/deps/jsr.io/@std/internal/1.0.12/types.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.12/types.js +0 -4
- package/script/message-channel.d.ts +0 -3
- package/script/message-channel.d.ts.map +0 -1
- package/script/message-channel.js +0 -16
- package/script/mod.d.ts +0 -4
- package/script/mod.d.ts.map +0 -1
- package/script/mod.js +0 -19
- package/script/package.json +0 -3
- package/script/types.d.ts +0 -33
- package/script/types.d.ts.map +0 -1
- package/script/types.js +0 -2
- package/script/worker-main.d.ts +0 -84
- package/script/worker-main.d.ts.map +0 -1
- package/script/worker-main.js +0 -190
- package/script/worker.d.ts +0 -63
- package/script/worker.d.ts.map +0 -1
- package/script/worker.js +0 -124
- /package/{esm → dist}/message-channel.d.ts +0 -0
- /package/{esm → dist}/message-channel.js +0 -0
- /package/{esm → dist}/mod.js +0 -0
- /package/{esm → dist}/types.d.ts +0 -0
- /package/{esm → dist}/types.js +0 -0
- /package/{esm → dist}/worker.d.ts +0 -0
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
-
// This module is browser compatible.
|
|
3
|
-
import { AssertionError } from "./assertion_error.js";
|
|
4
|
-
/**
|
|
5
|
-
* Make an assertion that `actual` and `expected` are almost equal numbers
|
|
6
|
-
* through a given tolerance. It can be used to take into account IEEE-754
|
|
7
|
-
* double-precision floating-point representation limitations. If the values
|
|
8
|
-
* are not almost equal then throw.
|
|
9
|
-
*
|
|
10
|
-
* The default tolerance is one hundred thousandth of a percent of the
|
|
11
|
-
* expected value.
|
|
12
|
-
*
|
|
13
|
-
* @example Usage
|
|
14
|
-
* ```ts ignore
|
|
15
|
-
* import { assertAlmostEquals } from "@std/assert";
|
|
16
|
-
*
|
|
17
|
-
* assertAlmostEquals(0.01, 0.02); // Throws
|
|
18
|
-
* assertAlmostEquals(1e-8, 1e-9); // Throws
|
|
19
|
-
* assertAlmostEquals(1.000000001e-8, 1.000000002e-8); // Doesn't throw
|
|
20
|
-
* assertAlmostEquals(0.01, 0.02, 0.1); // Doesn't throw
|
|
21
|
-
* assertAlmostEquals(0.1 + 0.2, 0.3, 1e-16); // Doesn't throw
|
|
22
|
-
* assertAlmostEquals(0.1 + 0.2, 0.3, 1e-17); // Throws
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
* @param actual The actual value to compare.
|
|
26
|
-
* @param expected The expected value to compare.
|
|
27
|
-
* @param tolerance The tolerance to consider the values almost equal. The
|
|
28
|
-
* default is one hundred thousandth of a percent of the expected value.
|
|
29
|
-
* @param msg The optional message to include in the error.
|
|
30
|
-
*/
|
|
31
|
-
export function assertAlmostEquals(actual, expected, tolerance, msg) {
|
|
32
|
-
if (Object.is(actual, expected)) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
const delta = Math.abs(expected - actual);
|
|
36
|
-
if (tolerance === undefined) {
|
|
37
|
-
tolerance = isFinite(expected) ? Math.abs(expected * 1e-7) : 1e-7;
|
|
38
|
-
}
|
|
39
|
-
if (delta <= tolerance) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
const msgSuffix = msg ? `: ${msg}` : ".";
|
|
43
|
-
const f = (n) => Number.isInteger(n) ? n : n.toExponential();
|
|
44
|
-
throw new AssertionError(`Expected actual: "${f(actual)}" to be close to "${f(expected)}": \
|
|
45
|
-
delta "${f(delta)}" is greater than "${f(tolerance)}"${msgSuffix}`);
|
|
46
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/** An array-like object (`Array`, `Uint8Array`, `NodeList`, etc.) that is not a string */
|
|
2
|
-
export type ArrayLikeArg<T> = ArrayLike<T> & object;
|
|
3
|
-
/**
|
|
4
|
-
* Make an assertion that `actual` includes the `expected` values. If not then
|
|
5
|
-
* an error will be thrown.
|
|
6
|
-
*
|
|
7
|
-
* Type parameter can be specified to ensure values under comparison have the
|
|
8
|
-
* same type.
|
|
9
|
-
*
|
|
10
|
-
* @example Usage
|
|
11
|
-
* ```ts ignore
|
|
12
|
-
* import { assertArrayIncludes } from "@std/assert";
|
|
13
|
-
*
|
|
14
|
-
* assertArrayIncludes([1, 2], [2]); // Doesn't throw
|
|
15
|
-
* assertArrayIncludes([1, 2], [3]); // Throws
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* @typeParam T The type of the elements in the array to compare.
|
|
19
|
-
* @param actual The array-like object to check for.
|
|
20
|
-
* @param expected The array-like object to check for.
|
|
21
|
-
* @param msg The optional message to display if the assertion fails.
|
|
22
|
-
*/
|
|
23
|
-
export declare function assertArrayIncludes<T>(actual: ArrayLikeArg<T>, expected: ArrayLikeArg<T>, msg?: string): void;
|
|
24
|
-
//# sourceMappingURL=array_includes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"array_includes.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/array_includes.ts"],"names":[],"mappings":"AAMA,0FAA0F;AAC1F,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,EACvB,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,EACzB,GAAG,CAAC,EAAE,MAAM,QAwBb"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
-
// This module is browser compatible.
|
|
3
|
-
import { equal } from "./equal.js";
|
|
4
|
-
import { format } from "../../internal/1.0.12/format.js";
|
|
5
|
-
import { AssertionError } from "./assertion_error.js";
|
|
6
|
-
/**
|
|
7
|
-
* Make an assertion that `actual` includes the `expected` values. If not then
|
|
8
|
-
* an error will be thrown.
|
|
9
|
-
*
|
|
10
|
-
* Type parameter can be specified to ensure values under comparison have the
|
|
11
|
-
* same type.
|
|
12
|
-
*
|
|
13
|
-
* @example Usage
|
|
14
|
-
* ```ts ignore
|
|
15
|
-
* import { assertArrayIncludes } from "@std/assert";
|
|
16
|
-
*
|
|
17
|
-
* assertArrayIncludes([1, 2], [2]); // Doesn't throw
|
|
18
|
-
* assertArrayIncludes([1, 2], [3]); // Throws
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
|
-
* @typeParam T The type of the elements in the array to compare.
|
|
22
|
-
* @param actual The array-like object to check for.
|
|
23
|
-
* @param expected The array-like object to check for.
|
|
24
|
-
* @param msg The optional message to display if the assertion fails.
|
|
25
|
-
*/
|
|
26
|
-
export function assertArrayIncludes(actual, expected, msg) {
|
|
27
|
-
const missing = [];
|
|
28
|
-
for (let i = 0; i < expected.length; i++) {
|
|
29
|
-
let found = false;
|
|
30
|
-
for (let j = 0; j < actual.length; j++) {
|
|
31
|
-
if (equal(expected[i], actual[j])) {
|
|
32
|
-
found = true;
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
if (!found) {
|
|
37
|
-
missing.push(expected[i]);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
if (missing.length === 0) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
const msgSuffix = msg ? `: ${msg}` : ".";
|
|
44
|
-
msg = `Expected actual: "${format(actual)}" to include: "${format(expected)}"${msgSuffix}\nmissing: ${format(missing)}`;
|
|
45
|
-
throw new AssertionError(msg);
|
|
46
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Make an assertion, error will be thrown if `expr` does not have truthy value.
|
|
3
|
-
*
|
|
4
|
-
* @example Usage
|
|
5
|
-
* ```ts ignore
|
|
6
|
-
* import { assert } from "@std/assert";
|
|
7
|
-
*
|
|
8
|
-
* assert("hello".includes("ello")); // Doesn't throw
|
|
9
|
-
* assert("hello".includes("world")); // Throws
|
|
10
|
-
* ```
|
|
11
|
-
*
|
|
12
|
-
* @param expr The expression to test.
|
|
13
|
-
* @param msg The optional message to display if the assertion fails.
|
|
14
|
-
*/
|
|
15
|
-
export declare function assert(expr: unknown, msg?: string): asserts expr;
|
|
16
|
-
//# sourceMappingURL=assert.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/assert.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,SAAK,GAAG,OAAO,CAAC,IAAI,CAI5D"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
-
// This module is browser compatible.
|
|
3
|
-
import { AssertionError } from "./assertion_error.js";
|
|
4
|
-
/**
|
|
5
|
-
* Make an assertion, error will be thrown if `expr` does not have truthy value.
|
|
6
|
-
*
|
|
7
|
-
* @example Usage
|
|
8
|
-
* ```ts ignore
|
|
9
|
-
* import { assert } from "@std/assert";
|
|
10
|
-
*
|
|
11
|
-
* assert("hello".includes("ello")); // Doesn't throw
|
|
12
|
-
* assert("hello".includes("world")); // Throws
|
|
13
|
-
* ```
|
|
14
|
-
*
|
|
15
|
-
* @param expr The expression to test.
|
|
16
|
-
* @param msg The optional message to display if the assertion fails.
|
|
17
|
-
*/
|
|
18
|
-
export function assert(expr, msg = "") {
|
|
19
|
-
if (!expr) {
|
|
20
|
-
throw new AssertionError(msg);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error thrown when an assertion fails.
|
|
3
|
-
*
|
|
4
|
-
* @example Usage
|
|
5
|
-
* ```ts ignore
|
|
6
|
-
* import { AssertionError } from "@std/assert";
|
|
7
|
-
*
|
|
8
|
-
* try {
|
|
9
|
-
* throw new AssertionError("foo", { cause: "bar" });
|
|
10
|
-
* } catch (error) {
|
|
11
|
-
* if (error instanceof AssertionError) {
|
|
12
|
-
* error.message === "foo"; // true
|
|
13
|
-
* error.cause === "bar"; // true
|
|
14
|
-
* }
|
|
15
|
-
* }
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export declare class AssertionError extends Error {
|
|
19
|
-
/** Constructs a new instance.
|
|
20
|
-
*
|
|
21
|
-
* @param message The error message.
|
|
22
|
-
* @param options Additional options. This argument is still unstable. It may change in the future release.
|
|
23
|
-
*/
|
|
24
|
-
constructor(message: string, options?: ErrorOptions);
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=assertion_error.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assertion_error.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/assertion_error.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC;;;;OAIG;gBACS,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAIpD"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
-
// This module is browser compatible.
|
|
3
|
-
/**
|
|
4
|
-
* Error thrown when an assertion fails.
|
|
5
|
-
*
|
|
6
|
-
* @example Usage
|
|
7
|
-
* ```ts ignore
|
|
8
|
-
* import { AssertionError } from "@std/assert";
|
|
9
|
-
*
|
|
10
|
-
* try {
|
|
11
|
-
* throw new AssertionError("foo", { cause: "bar" });
|
|
12
|
-
* } catch (error) {
|
|
13
|
-
* if (error instanceof AssertionError) {
|
|
14
|
-
* error.message === "foo"; // true
|
|
15
|
-
* error.cause === "bar"; // true
|
|
16
|
-
* }
|
|
17
|
-
* }
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export class AssertionError extends Error {
|
|
21
|
-
/** Constructs a new instance.
|
|
22
|
-
*
|
|
23
|
-
* @param message The error message.
|
|
24
|
-
* @param options Additional options. This argument is still unstable. It may change in the future release.
|
|
25
|
-
*/
|
|
26
|
-
constructor(message, options) {
|
|
27
|
-
super(message, options);
|
|
28
|
-
this.name = "AssertionError";
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deep equality comparison used in assertions.
|
|
3
|
-
*
|
|
4
|
-
* @param a The actual value
|
|
5
|
-
* @param b The expected value
|
|
6
|
-
* @returns `true` if the values are deeply equal, `false` otherwise
|
|
7
|
-
*
|
|
8
|
-
* @example Usage
|
|
9
|
-
* ```ts
|
|
10
|
-
* import { equal } from "@std/assert/equal";
|
|
11
|
-
*
|
|
12
|
-
* equal({ foo: "bar" }, { foo: "bar" }); // Returns `true`
|
|
13
|
-
* equal({ foo: "bar" }, { foo: "baz" }); // Returns `false`
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
export declare function equal(a: unknown, b: unknown): boolean;
|
|
17
|
-
//# sourceMappingURL=equal.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"equal.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/equal.ts"],"names":[],"mappings":"AA0FA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAgHrD"}
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
-
// This module is browser compatible.
|
|
3
|
-
import * as dntShim from "../../../../../_dnt.shims.js";
|
|
4
|
-
function isKeyedCollection(x) {
|
|
5
|
-
return x instanceof Set || x instanceof Map;
|
|
6
|
-
}
|
|
7
|
-
function prototypesEqual(a, b) {
|
|
8
|
-
const pa = Object.getPrototypeOf(a);
|
|
9
|
-
const pb = Object.getPrototypeOf(b);
|
|
10
|
-
return pa === pb ||
|
|
11
|
-
pa === Object.prototype && pb === null ||
|
|
12
|
-
pa === null && pb === Object.prototype;
|
|
13
|
-
}
|
|
14
|
-
function isBasicObjectOrArray(obj) {
|
|
15
|
-
const proto = Object.getPrototypeOf(obj);
|
|
16
|
-
return proto === null || proto === Object.prototype ||
|
|
17
|
-
proto === Array.prototype;
|
|
18
|
-
}
|
|
19
|
-
// Slightly faster than Reflect.ownKeys in V8 as of 12.9.202.13-rusty (2024-10-28)
|
|
20
|
-
function ownKeys(obj) {
|
|
21
|
-
return [
|
|
22
|
-
...Object.getOwnPropertyNames(obj),
|
|
23
|
-
...Object.getOwnPropertySymbols(obj),
|
|
24
|
-
];
|
|
25
|
-
}
|
|
26
|
-
function getKeysDeep(obj) {
|
|
27
|
-
const keys = new Set();
|
|
28
|
-
while (obj !== Object.prototype && obj !== Array.prototype && obj != null) {
|
|
29
|
-
for (const key of ownKeys(obj)) {
|
|
30
|
-
keys.add(key);
|
|
31
|
-
}
|
|
32
|
-
obj = Object.getPrototypeOf(obj);
|
|
33
|
-
}
|
|
34
|
-
return keys;
|
|
35
|
-
}
|
|
36
|
-
// deno-lint-ignore no-explicit-any
|
|
37
|
-
const Temporal = dntShim.dntGlobalThis.Temporal ?? Object.create(null);
|
|
38
|
-
/** A non-exhaustive list of prototypes that can be accurately fast-path compared with `String(instance)` */
|
|
39
|
-
const stringComparablePrototypes = new Set([
|
|
40
|
-
Intl.Locale,
|
|
41
|
-
RegExp,
|
|
42
|
-
Temporal.Duration,
|
|
43
|
-
Temporal.Instant,
|
|
44
|
-
Temporal.PlainDate,
|
|
45
|
-
Temporal.PlainDateTime,
|
|
46
|
-
Temporal.PlainTime,
|
|
47
|
-
Temporal.PlainYearMonth,
|
|
48
|
-
Temporal.PlainMonthDay,
|
|
49
|
-
Temporal.ZonedDateTime,
|
|
50
|
-
URL,
|
|
51
|
-
URLSearchParams,
|
|
52
|
-
].filter((x) => x != null).map((x) => x.prototype));
|
|
53
|
-
function isPrimitive(x) {
|
|
54
|
-
return typeof x === "string" ||
|
|
55
|
-
typeof x === "number" ||
|
|
56
|
-
typeof x === "boolean" ||
|
|
57
|
-
typeof x === "bigint" ||
|
|
58
|
-
typeof x === "symbol" ||
|
|
59
|
-
x == null;
|
|
60
|
-
}
|
|
61
|
-
const TypedArray = Object.getPrototypeOf(Uint8Array);
|
|
62
|
-
function compareTypedArrays(a, b) {
|
|
63
|
-
if (a.length !== b.length)
|
|
64
|
-
return false;
|
|
65
|
-
for (let i = 0; i < b.length; i++) {
|
|
66
|
-
if (!sameValueZero(a[i], b[i]))
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
/** Check both strict equality (`0 == -0`) and `Object.is` (`NaN == NaN`) */
|
|
72
|
-
function sameValueZero(a, b) {
|
|
73
|
-
return a === b || Object.is(a, b);
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Deep equality comparison used in assertions.
|
|
77
|
-
*
|
|
78
|
-
* @param a The actual value
|
|
79
|
-
* @param b The expected value
|
|
80
|
-
* @returns `true` if the values are deeply equal, `false` otherwise
|
|
81
|
-
*
|
|
82
|
-
* @example Usage
|
|
83
|
-
* ```ts
|
|
84
|
-
* import { equal } from "@std/assert/equal";
|
|
85
|
-
*
|
|
86
|
-
* equal({ foo: "bar" }, { foo: "bar" }); // Returns `true`
|
|
87
|
-
* equal({ foo: "bar" }, { foo: "baz" }); // Returns `false`
|
|
88
|
-
* ```
|
|
89
|
-
*/
|
|
90
|
-
export function equal(a, b) {
|
|
91
|
-
const seen = new Map();
|
|
92
|
-
return (function compare(a, b) {
|
|
93
|
-
if (sameValueZero(a, b))
|
|
94
|
-
return true;
|
|
95
|
-
if (isPrimitive(a) || isPrimitive(b))
|
|
96
|
-
return false;
|
|
97
|
-
if (a instanceof Date && b instanceof Date) {
|
|
98
|
-
return Object.is(a.getTime(), b.getTime());
|
|
99
|
-
}
|
|
100
|
-
if (a && typeof a === "object" && b && typeof b === "object") {
|
|
101
|
-
if (!prototypesEqual(a, b)) {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
if (a instanceof TypedArray) {
|
|
105
|
-
return compareTypedArrays(a, b);
|
|
106
|
-
}
|
|
107
|
-
if (a instanceof ArrayBuffer ||
|
|
108
|
-
(globalThis.SharedArrayBuffer && a instanceof SharedArrayBuffer)) {
|
|
109
|
-
return compareTypedArrays(new Uint8Array(a), new Uint8Array(b));
|
|
110
|
-
}
|
|
111
|
-
if (a instanceof WeakMap) {
|
|
112
|
-
throw new TypeError("Cannot compare WeakMap instances");
|
|
113
|
-
}
|
|
114
|
-
if (a instanceof WeakSet) {
|
|
115
|
-
throw new TypeError("Cannot compare WeakSet instances");
|
|
116
|
-
}
|
|
117
|
-
if (a instanceof WeakRef) {
|
|
118
|
-
return compare(a.deref(), b.deref());
|
|
119
|
-
}
|
|
120
|
-
if (seen.get(a) === b) {
|
|
121
|
-
return true;
|
|
122
|
-
}
|
|
123
|
-
if (Object.keys(a).length !== Object.keys(b).length) {
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
seen.set(a, b);
|
|
127
|
-
if (isKeyedCollection(a) && isKeyedCollection(b)) {
|
|
128
|
-
if (a.size !== b.size) {
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
const aKeys = [...a.keys()];
|
|
132
|
-
const primitiveKeysFastPath = aKeys.every(isPrimitive);
|
|
133
|
-
if (primitiveKeysFastPath) {
|
|
134
|
-
if (a instanceof Set) {
|
|
135
|
-
return a.symmetricDifference(b).size === 0;
|
|
136
|
-
}
|
|
137
|
-
for (const key of aKeys) {
|
|
138
|
-
if (!b.has(key) ||
|
|
139
|
-
!compare(a.get(key), b.get(key))) {
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return true;
|
|
144
|
-
}
|
|
145
|
-
let unmatchedEntries = a.size;
|
|
146
|
-
for (const [aKey, aValue] of a.entries()) {
|
|
147
|
-
for (const [bKey, bValue] of b.entries()) {
|
|
148
|
-
/* Given that Map keys can be references, we need
|
|
149
|
-
* to ensure that they are also deeply equal */
|
|
150
|
-
if (!compare(aKey, bKey))
|
|
151
|
-
continue;
|
|
152
|
-
if ((aKey === aValue && bKey === bValue) ||
|
|
153
|
-
(compare(aValue, bValue))) {
|
|
154
|
-
unmatchedEntries--;
|
|
155
|
-
break;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
return unmatchedEntries === 0;
|
|
160
|
-
}
|
|
161
|
-
let keys;
|
|
162
|
-
if (isBasicObjectOrArray(a)) {
|
|
163
|
-
// fast path
|
|
164
|
-
keys = ownKeys({ ...a, ...b });
|
|
165
|
-
}
|
|
166
|
-
else if (stringComparablePrototypes.has(Object.getPrototypeOf(a))) {
|
|
167
|
-
// medium path
|
|
168
|
-
return String(a) === String(b);
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
// slow path
|
|
172
|
-
keys = getKeysDeep(a).union(getKeysDeep(b));
|
|
173
|
-
}
|
|
174
|
-
for (const key of keys) {
|
|
175
|
-
if (!compare(a[key], b[key])) {
|
|
176
|
-
return false;
|
|
177
|
-
}
|
|
178
|
-
if (((key in a) && (!(key in b))) || ((key in b) && (!(key in a)))) {
|
|
179
|
-
return false;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
return true;
|
|
183
|
-
}
|
|
184
|
-
return false;
|
|
185
|
-
})(a, b);
|
|
186
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Make an assertion that `actual` and `expected` are equal, deeply. If not
|
|
3
|
-
* deeply equal, then throw.
|
|
4
|
-
*
|
|
5
|
-
* Type parameter can be specified to ensure values under comparison have the
|
|
6
|
-
* same type.
|
|
7
|
-
*
|
|
8
|
-
* Note: When comparing `Blob` objects, you should first convert them to
|
|
9
|
-
* `Uint8Array` using the `Blob.bytes()` method and then compare their
|
|
10
|
-
* contents.
|
|
11
|
-
*
|
|
12
|
-
* @example Usage
|
|
13
|
-
* ```ts ignore
|
|
14
|
-
* import { assertEquals } from "@std/assert";
|
|
15
|
-
*
|
|
16
|
-
* assertEquals("world", "world"); // Doesn't throw
|
|
17
|
-
* assertEquals("hello", "world"); // Throws
|
|
18
|
-
* ```
|
|
19
|
-
* @example Compare `Blob` objects
|
|
20
|
-
* ```ts ignore
|
|
21
|
-
* import { assertEquals } from "@std/assert";
|
|
22
|
-
*
|
|
23
|
-
* const bytes1 = await new Blob(["foo"]).bytes();
|
|
24
|
-
* const bytes2 = await new Blob(["foo"]).bytes();
|
|
25
|
-
*
|
|
26
|
-
* assertEquals(bytes1, bytes2);
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* @typeParam T The type of the values to compare. This is usually inferred.
|
|
30
|
-
* @param actual The actual value to compare.
|
|
31
|
-
* @param expected The expected value to compare.
|
|
32
|
-
* @param msg The optional message to display if the assertion fails.
|
|
33
|
-
*/
|
|
34
|
-
export declare function assertEquals<T>(actual: T, expected: T, msg?: string): void;
|
|
35
|
-
//# sourceMappingURL=equals.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"equals.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/equals.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,MAAM,EAAE,CAAC,EACT,QAAQ,EAAE,CAAC,EACX,GAAG,CAAC,EAAE,MAAM,QAmBb"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
-
// This module is browser compatible.
|
|
3
|
-
import { equal } from "./equal.js";
|
|
4
|
-
import { buildMessage } from "../../internal/1.0.12/build_message.js";
|
|
5
|
-
import { diff } from "../../internal/1.0.12/diff.js";
|
|
6
|
-
import { diffStr } from "../../internal/1.0.12/diff_str.js";
|
|
7
|
-
import { format } from "../../internal/1.0.12/format.js";
|
|
8
|
-
import { AssertionError } from "./assertion_error.js";
|
|
9
|
-
/**
|
|
10
|
-
* Make an assertion that `actual` and `expected` are equal, deeply. If not
|
|
11
|
-
* deeply equal, then throw.
|
|
12
|
-
*
|
|
13
|
-
* Type parameter can be specified to ensure values under comparison have the
|
|
14
|
-
* same type.
|
|
15
|
-
*
|
|
16
|
-
* Note: When comparing `Blob` objects, you should first convert them to
|
|
17
|
-
* `Uint8Array` using the `Blob.bytes()` method and then compare their
|
|
18
|
-
* contents.
|
|
19
|
-
*
|
|
20
|
-
* @example Usage
|
|
21
|
-
* ```ts ignore
|
|
22
|
-
* import { assertEquals } from "@std/assert";
|
|
23
|
-
*
|
|
24
|
-
* assertEquals("world", "world"); // Doesn't throw
|
|
25
|
-
* assertEquals("hello", "world"); // Throws
|
|
26
|
-
* ```
|
|
27
|
-
* @example Compare `Blob` objects
|
|
28
|
-
* ```ts ignore
|
|
29
|
-
* import { assertEquals } from "@std/assert";
|
|
30
|
-
*
|
|
31
|
-
* const bytes1 = await new Blob(["foo"]).bytes();
|
|
32
|
-
* const bytes2 = await new Blob(["foo"]).bytes();
|
|
33
|
-
*
|
|
34
|
-
* assertEquals(bytes1, bytes2);
|
|
35
|
-
* ```
|
|
36
|
-
*
|
|
37
|
-
* @typeParam T The type of the values to compare. This is usually inferred.
|
|
38
|
-
* @param actual The actual value to compare.
|
|
39
|
-
* @param expected The expected value to compare.
|
|
40
|
-
* @param msg The optional message to display if the assertion fails.
|
|
41
|
-
*/
|
|
42
|
-
export function assertEquals(actual, expected, msg) {
|
|
43
|
-
if (equal(actual, expected)) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const msgSuffix = msg ? `: ${msg}` : ".";
|
|
47
|
-
let message = `Values are not equal${msgSuffix}`;
|
|
48
|
-
const actualString = format(actual);
|
|
49
|
-
const expectedString = format(expected);
|
|
50
|
-
const stringDiff = (typeof actual === "string") &&
|
|
51
|
-
(typeof expected === "string");
|
|
52
|
-
const diffResult = stringDiff
|
|
53
|
-
? diffStr(actual, expected)
|
|
54
|
-
: diff(actualString.split("\n"), expectedString.split("\n"));
|
|
55
|
-
const diffMsg = buildMessage(diffResult, { stringDiff }, arguments[3])
|
|
56
|
-
.join("\n");
|
|
57
|
-
message = `${message}\n${diffMsg}`;
|
|
58
|
-
throw new AssertionError(message);
|
|
59
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Make an assertion that actual is not null or undefined.
|
|
3
|
-
* If not then throw.
|
|
4
|
-
*
|
|
5
|
-
* @example Usage
|
|
6
|
-
* ```ts ignore
|
|
7
|
-
* import { assertExists } from "@std/assert";
|
|
8
|
-
*
|
|
9
|
-
* assertExists("something"); // Doesn't throw
|
|
10
|
-
* assertExists(undefined); // Throws
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* @typeParam T The type of the actual value.
|
|
14
|
-
* @param actual The actual value to check.
|
|
15
|
-
* @param msg The optional message to include in the error if the assertion fails.
|
|
16
|
-
*/
|
|
17
|
-
export declare function assertExists<T>(actual: T, msg?: string): asserts actual is NonNullable<T>;
|
|
18
|
-
//# sourceMappingURL=exists.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exists.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/exists.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,MAAM,EAAE,CAAC,EACT,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC,CAOlC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
-
// This module is browser compatible.
|
|
3
|
-
import { AssertionError } from "./assertion_error.js";
|
|
4
|
-
/**
|
|
5
|
-
* Make an assertion that actual is not null or undefined.
|
|
6
|
-
* If not then throw.
|
|
7
|
-
*
|
|
8
|
-
* @example Usage
|
|
9
|
-
* ```ts ignore
|
|
10
|
-
* import { assertExists } from "@std/assert";
|
|
11
|
-
*
|
|
12
|
-
* assertExists("something"); // Doesn't throw
|
|
13
|
-
* assertExists(undefined); // Throws
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* @typeParam T The type of the actual value.
|
|
17
|
-
* @param actual The actual value to check.
|
|
18
|
-
* @param msg The optional message to include in the error if the assertion fails.
|
|
19
|
-
*/
|
|
20
|
-
export function assertExists(actual, msg) {
|
|
21
|
-
if (actual === undefined || actual === null) {
|
|
22
|
-
const msgSuffix = msg ? `: ${msg}` : ".";
|
|
23
|
-
msg =
|
|
24
|
-
`Expected actual: "${actual}" to not be null or undefined${msgSuffix}`;
|
|
25
|
-
throw new AssertionError(msg);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Forcefully throws a failed assertion.
|
|
3
|
-
*
|
|
4
|
-
* @example Usage
|
|
5
|
-
* ```ts ignore
|
|
6
|
-
* import { fail } from "@std/assert";
|
|
7
|
-
*
|
|
8
|
-
* fail("Deliberately failed!"); // Throws
|
|
9
|
-
* ```
|
|
10
|
-
*
|
|
11
|
-
* @param msg Optional message to include in the error.
|
|
12
|
-
* @returns Never returns, always throws.
|
|
13
|
-
*/
|
|
14
|
-
export declare function fail(msg?: string): never;
|
|
15
|
-
//# sourceMappingURL=fail.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fail.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/fail.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,wBAAgB,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,CAGxC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
-
// This module is browser compatible.
|
|
3
|
-
import { AssertionError } from "./assertion_error.js";
|
|
4
|
-
/**
|
|
5
|
-
* Forcefully throws a failed assertion.
|
|
6
|
-
*
|
|
7
|
-
* @example Usage
|
|
8
|
-
* ```ts ignore
|
|
9
|
-
* import { fail } from "@std/assert";
|
|
10
|
-
*
|
|
11
|
-
* fail("Deliberately failed!"); // Throws
|
|
12
|
-
* ```
|
|
13
|
-
*
|
|
14
|
-
* @param msg Optional message to include in the error.
|
|
15
|
-
* @returns Never returns, always throws.
|
|
16
|
-
*/
|
|
17
|
-
export function fail(msg) {
|
|
18
|
-
const msgSuffix = msg ? `: ${msg}` : ".";
|
|
19
|
-
throw new AssertionError(`Failed assertion${msgSuffix}`);
|
|
20
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/** Assertion condition for {@linkcode assertFalse}. */
|
|
2
|
-
export type Falsy = false | 0 | 0n | "" | null | undefined;
|
|
3
|
-
/**
|
|
4
|
-
* Make an assertion, error will be thrown if `expr` have truthy value.
|
|
5
|
-
*
|
|
6
|
-
* @example Usage
|
|
7
|
-
* ```ts ignore
|
|
8
|
-
* import { assertFalse } from "@std/assert";
|
|
9
|
-
*
|
|
10
|
-
* assertFalse(false); // Doesn't throw
|
|
11
|
-
* assertFalse(true); // Throws
|
|
12
|
-
* ```
|
|
13
|
-
*
|
|
14
|
-
* @param expr The expression to test.
|
|
15
|
-
* @param msg The optional message to display if the assertion fails.
|
|
16
|
-
*/
|
|
17
|
-
export declare function assertFalse(expr: unknown, msg?: string): asserts expr is Falsy;
|
|
18
|
-
//# sourceMappingURL=false.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"false.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/false.ts"],"names":[],"mappings":"AAIA,uDAAuD;AACvD,MAAM,MAAM,KAAK,GAAG,KAAK,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;AAE3D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,SAAK,GAAG,OAAO,CAAC,IAAI,IAAI,KAAK,CAI1E"}
|