cf-workers-native 0.0.0-stage → 0.1.2-beta.local.sha2f5e4e6956f4
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/LICENSE +21 -0
- package/Package.swift +25 -0
- package/README.md +92 -2
- package/dist/android.d.ts +2 -0
- package/dist/android.js +1 -0
- package/dist/browser/abort/index.d.ts +13 -0
- package/dist/browser/abort/index.js +66 -0
- package/dist/browser/body/index.d.ts +24 -0
- package/dist/browser/body/index.js +116 -0
- package/dist/browser/body/stream-body.d.ts +13 -0
- package/dist/browser/body/stream-body.js +84 -0
- package/dist/browser/documents/body.d.ts +3 -0
- package/dist/browser/documents/body.js +48 -0
- package/dist/browser/documents/form-body.d.ts +1 -0
- package/dist/browser/documents/form-body.js +54 -0
- package/dist/browser/documents/host.d.ts +11 -0
- package/dist/browser/documents/host.js +256 -0
- package/dist/browser/documents/links-source.d.ts +1 -0
- package/dist/browser/documents/links-source.js +1 -0
- package/dist/browser/documents/links.d.ts +1 -0
- package/dist/browser/documents/links.js +33 -0
- package/dist/browser/documents/page-config.d.ts +5 -0
- package/dist/browser/documents/page-config.js +5 -0
- package/dist/browser/documents/page-source.d.ts +1 -0
- package/dist/browser/documents/page-source.js +1 -0
- package/dist/browser/documents/page.d.ts +2 -0
- package/dist/browser/documents/page.js +153 -0
- package/dist/browser/documents/registration.d.ts +5 -0
- package/dist/browser/documents/registration.js +75 -0
- package/dist/browser/documents/runtime.d.ts +7 -0
- package/dist/browser/documents/runtime.js +161 -0
- package/dist/browser/documents/service-worker.js +285 -0
- package/dist/browser/encoding/index.d.ts +7 -0
- package/dist/browser/encoding/index.js +3 -0
- package/dist/browser/fetch/LICENSE-3RD-PARTY.md +9 -0
- package/dist/browser/fetch/LICENSE-APACHE +177 -0
- package/dist/browser/fetch/host-call.d.ts +3 -0
- package/dist/browser/fetch/host-call.js +67 -0
- package/dist/browser/fetch/index.d.ts +5 -0
- package/dist/browser/fetch/index.js +96 -0
- package/dist/browser/fetch/interop.d.ts +6 -0
- package/dist/browser/fetch/interop.js +48 -0
- package/dist/browser/fetch/native-network.d.ts +20 -0
- package/dist/browser/fetch/native-network.js +233 -0
- package/dist/browser/fetch/outbound.d.ts +2 -0
- package/dist/browser/fetch/outbound.js +11 -0
- package/dist/browser/fetch/relay.d.ts +7 -0
- package/dist/browser/fetch/relay.js +100 -0
- package/dist/browser/fetch/scope.d.ts +8 -0
- package/dist/browser/fetch/scope.js +108 -0
- package/dist/browser/fetch/transport.d.ts +39 -0
- package/dist/browser/fetch/transport.js +136 -0
- package/dist/browser/headers/LICENSE-3RD-PARTY.md +9 -0
- package/dist/browser/headers/LICENSE-APACHE +177 -0
- package/dist/browser/headers/index.d.ts +20 -0
- package/dist/browser/headers/index.js +194 -0
- package/dist/browser/isolated/bridge.d.ts +8 -0
- package/dist/browser/isolated/bridge.js +267 -0
- package/dist/browser/isolated/protocol.d.ts +40 -0
- package/dist/browser/isolated/protocol.js +1 -0
- package/dist/browser/isolated/transport.d.ts +2 -0
- package/dist/browser/isolated/transport.js +157 -0
- package/dist/browser/request/LICENSE-3RD-PARTY.md +10 -0
- package/dist/browser/request/LICENSE-APACHE +177 -0
- package/dist/browser/request/index.d.ts +48 -0
- package/dist/browser/request/index.js +182 -0
- package/dist/browser/response/LICENSE-3RD-PARTY.md +10 -0
- package/dist/browser/response/LICENSE-APACHE +177 -0
- package/dist/browser/response/index.d.ts +43 -0
- package/dist/browser/response/index.js +192 -0
- package/dist/browser/response/status.d.ts +1 -0
- package/dist/browser/response/status.js +75 -0
- package/dist/browser/structured-clone/index.d.ts +1 -0
- package/dist/browser/structured-clone/index.js +479 -0
- package/dist/cloudflare/apis/cloudflare-node/index.d.ts +18 -0
- package/dist/cloudflare/apis/cloudflare-node/index.js +150 -0
- package/dist/cloudflare/apis/cloudflare-workers/index.d.ts +8 -0
- package/dist/cloudflare/apis/cloudflare-workers/index.js +37 -0
- package/dist/cloudflare/apis/types.d.ts +7 -0
- package/dist/cloudflare/apis/types.js +1 -0
- package/dist/cloudflare/bindings/config.d.ts +42 -0
- package/dist/cloudflare/bindings/config.js +280 -0
- package/dist/cloudflare/bindings/kv/contract.d.ts +6 -0
- package/dist/cloudflare/bindings/kv/contract.js +181 -0
- package/dist/cloudflare/bindings/kv/index.d.ts +18 -0
- package/dist/cloudflare/bindings/kv/index.js +61 -0
- package/dist/cloudflare/bindings/kv/storage.d.ts +25 -0
- package/dist/cloudflare/bindings/kv/storage.js +320 -0
- package/dist/cloudflare/bindings/kv/types.d.ts +50 -0
- package/dist/cloudflare/bindings/kv/types.js +1 -0
- package/dist/cloudflare/bindings/remote.d.ts +8 -0
- package/dist/cloudflare/bindings/remote.js +261 -0
- package/dist/cloudflare/workers/contract.d.ts +8 -0
- package/dist/cloudflare/workers/contract.js +65 -0
- package/dist/cloudflare/workers/feature.d.ts +10 -0
- package/dist/cloudflare/workers/feature.js +28 -0
- package/dist/cloudflare/workers/runtime.d.ts +23 -0
- package/dist/cloudflare/workers/runtime.js +121 -0
- package/dist/cloudflare/workers/types.d.ts +49 -0
- package/dist/cloudflare/workers/types.js +1 -0
- package/dist/cloudflare/workers/worker-runtime.d.ts +44 -0
- package/dist/cloudflare/workers/worker-runtime.js +267 -0
- package/dist/compat/assert/LICENSE-3RD-PARTY.md +5 -0
- package/dist/compat/assert/LICENSE-APACHE +177 -0
- package/dist/compat/assert/assertion-error.d.ts +26 -0
- package/dist/compat/assert/assertion-error.js +468 -0
- package/dist/compat/assert/diff.d.ts +26 -0
- package/dist/compat/assert/diff.js +329 -0
- package/dist/compat/assert/errors.d.ts +11 -0
- package/dist/compat/assert/errors.js +55 -0
- package/dist/compat/assert/index.cjs +24 -0
- package/dist/compat/assert/index.d.cts +43 -0
- package/dist/compat/assert/index.d.ts +50 -0
- package/dist/compat/assert/index.js +858 -0
- package/dist/compat/async-hooks/LICENSE-APACHE +177 -0
- package/dist/compat/async-hooks/NOTICE.md +8 -0
- package/dist/compat/async-hooks/callbacks.d.ts +7 -0
- package/dist/compat/async-hooks/callbacks.js +18 -0
- package/dist/compat/async-hooks/hooks.d.ts +10 -0
- package/dist/compat/async-hooks/hooks.js +111 -0
- package/dist/compat/async-hooks/index.d.ts +41 -0
- package/dist/compat/async-hooks/index.js +298 -0
- package/dist/compat/buffer/LICENSE-3RD-PARTY.md +15 -0
- package/dist/compat/buffer/LICENSE-APACHE +177 -0
- package/dist/compat/buffer/blob.d.ts +22 -0
- package/dist/compat/buffer/blob.js +210 -0
- package/dist/compat/buffer/bytes.d.ts +34 -0
- package/dist/compat/buffer/bytes.js +228 -0
- package/dist/compat/buffer/errors.d.ts +41 -0
- package/dist/compat/buffer/errors.js +265 -0
- package/dist/compat/buffer/index.d.ts +25 -0
- package/dist/compat/buffer/index.js +24 -0
- package/dist/compat/buffer/internal-buffer.d.ts +148 -0
- package/dist/compat/buffer/internal-buffer.js +1809 -0
- package/dist/compat/buffer/support.d.ts +13 -0
- package/dist/compat/buffer/support.js +65 -0
- package/dist/compat/child-process/LICENSE-3RD-PARTY.md +8 -0
- package/dist/compat/child-process/LICENSE-APACHE +177 -0
- package/dist/compat/child-process/errors.d.ts +4 -0
- package/dist/compat/child-process/errors.js +6 -0
- package/dist/compat/child-process/index.d.ts +49 -0
- package/dist/compat/child-process/index.js +96 -0
- package/dist/compat/cluster/LICENSE-3RD-PARTY.md +40 -0
- package/dist/compat/cluster/LICENSE-APACHE +177 -0
- package/dist/compat/cluster/errors.d.ts +4 -0
- package/dist/compat/cluster/errors.js +6 -0
- package/dist/compat/cluster/index.d.ts +47 -0
- package/dist/compat/cluster/index.js +88 -0
- package/dist/compat/constants/LICENSE-3RD-PARTY.md +6 -0
- package/dist/compat/constants/LICENSE-APACHE +177 -0
- package/dist/compat/constants/index.d.ts +481 -0
- package/dist/compat/constants/index.js +488 -0
- package/dist/compat/dgram/LICENSE-3RD-PARTY.md +8 -0
- package/dist/compat/dgram/LICENSE-APACHE +177 -0
- package/dist/compat/dgram/index.d.ts +10 -0
- package/dist/compat/dgram/index.js +132 -0
- package/dist/compat/diagnostics-channel/LICENSE-3RD-PARTY.md +13 -0
- package/dist/compat/diagnostics-channel/LICENSE-APACHE +177 -0
- package/dist/compat/diagnostics-channel/index.d.ts +73 -0
- package/dist/compat/diagnostics-channel/index.js +261 -0
- package/dist/compat/diagnostics-channel/native.d.ts +26 -0
- package/dist/compat/diagnostics-channel/native.js +154 -0
- package/dist/compat/dns/LICENSE-3RD-PARTY.md +5 -0
- package/dist/compat/dns/LICENSE-APACHE +177 -0
- package/dist/compat/dns/client.d.ts +72 -0
- package/dist/compat/dns/client.js +161 -0
- package/dist/compat/dns/constants.d.ts +27 -0
- package/dist/compat/dns/constants.js +31 -0
- package/dist/compat/dns/errors.d.ts +8 -0
- package/dist/compat/dns/errors.js +12 -0
- package/dist/compat/dns/index.d.ts +97 -0
- package/dist/compat/dns/index.js +127 -0
- package/dist/compat/dns/parser.d.ts +18 -0
- package/dist/compat/dns/parser.js +144 -0
- package/dist/compat/dns/promise-resolver.d.ts +82 -0
- package/dist/compat/dns/promise-resolver.js +113 -0
- package/dist/compat/dns/promises.d.ts +50 -0
- package/dist/compat/dns/promises.js +53 -0
- package/dist/compat/dns/resolver.d.ts +34 -0
- package/dist/compat/dns/resolver.js +415 -0
- package/dist/compat/domain/LICENSE-3RD-PARTY.md +5 -0
- package/dist/compat/domain/LICENSE-APACHE +177 -0
- package/dist/compat/domain/index.d.ts +22 -0
- package/dist/compat/domain/index.js +79 -0
- package/dist/compat/fs/index.d.ts +85 -0
- package/dist/compat/fs/index.js +255 -0
- package/dist/compat/fs/promises/index.d.ts +3 -0
- package/dist/compat/fs/promises/index.js +3 -0
- package/dist/compat/http/index.d.ts +322 -0
- package/dist/compat/http/index.js +1356 -0
- package/dist/compat/http/registry.d.ts +19 -0
- package/dist/compat/http/registry.js +13 -0
- package/dist/compat/http-agent/LICENSE-3RD-PARTY.md +5 -0
- package/dist/compat/http-agent/LICENSE-APACHE +177 -0
- package/dist/compat/http-agent/index.d.ts +7 -0
- package/dist/compat/http-agent/index.js +10 -0
- package/dist/compat/http-client/LICENSE-3RD-PARTY.md +5 -0
- package/dist/compat/http-client/LICENSE-APACHE +177 -0
- package/dist/compat/http-client/index.d.ts +6 -0
- package/dist/compat/http-client/index.js +7 -0
- package/dist/compat/http-incoming/LICENSE-3RD-PARTY.md +5 -0
- package/dist/compat/http-incoming/LICENSE-APACHE +177 -0
- package/dist/compat/http-incoming/index.d.ts +6 -0
- package/dist/compat/http-incoming/index.js +9 -0
- package/dist/compat/http2/LICENSE-3RD-PARTY.md +29 -0
- package/dist/compat/http2/LICENSE-APACHE +177 -0
- package/dist/compat/http2/constants.d.ts +255 -0
- package/dist/compat/http2/constants.js +515 -0
- package/dist/compat/http2/errors.d.ts +4 -0
- package/dist/compat/http2/errors.js +6 -0
- package/dist/compat/http2/index.d.ts +283 -0
- package/dist/compat/http2/index.js +68 -0
- package/dist/compat/https/LICENSE-3RD-PARTY.md +5 -0
- package/dist/compat/https/LICENSE-APACHE +177 -0
- package/dist/compat/https/agent.d.ts +10 -0
- package/dist/compat/https/agent.js +99 -0
- package/dist/compat/https/errors.d.ts +4 -0
- package/dist/compat/https/errors.js +6 -0
- package/dist/compat/https/index.d.ts +20 -0
- package/dist/compat/https/index.js +50 -0
- package/dist/compat/https/server.d.ts +8 -0
- package/dist/compat/https/server.js +27 -0
- package/dist/compat/immediate/index.d.ts +11 -0
- package/dist/compat/immediate/index.js +58 -0
- package/dist/compat/inspector/LICENSE-3RD-PARTY.md +34 -0
- package/dist/compat/inspector/LICENSE-APACHE +177 -0
- package/dist/compat/inspector/errors.d.ts +4 -0
- package/dist/compat/inspector/errors.js +6 -0
- package/dist/compat/inspector/index.d.ts +18 -0
- package/dist/compat/inspector/index.js +117 -0
- package/dist/compat/inspector/promises.d.ts +18 -0
- package/dist/compat/inspector/promises.js +114 -0
- package/dist/compat/module/index.cjs +2 -0
- package/dist/compat/module/index.d.cts +2 -0
- package/dist/compat/module/index.d.ts +11 -0
- package/dist/compat/module/index.js +44 -0
- package/dist/compat/module/resolve-unavailable.d.ts +1 -0
- package/dist/compat/module/resolve-unavailable.js +3 -0
- package/dist/compat/net/LICENSE-3RD-PARTY.md +15 -0
- package/dist/compat/net/LICENSE-APACHE +177 -0
- package/dist/compat/net/error-base.d.ts +14 -0
- package/dist/compat/net/error-base.js +62 -0
- package/dist/compat/net/errors.d.ts +76 -0
- package/dist/compat/net/errors.js +333 -0
- package/dist/compat/net/index.d.ts +23 -0
- package/dist/compat/net/index.js +46 -0
- package/dist/compat/net/internal-net.d.ts +236 -0
- package/dist/compat/net/internal-net.js +2292 -0
- package/dist/compat/net/ports.d.ts +32 -0
- package/dist/compat/net/ports.js +149 -0
- package/dist/compat/net/reader.d.ts +8 -0
- package/dist/compat/net/reader.js +36 -0
- package/dist/compat/net/sockets.d.ts +20 -0
- package/dist/compat/net/sockets.js +195 -0
- package/dist/compat/net/validators.d.ts +18 -0
- package/dist/compat/net/validators.js +154 -0
- package/dist/compat/os/LICENSE-3RD-PARTY.md +8 -0
- package/dist/compat/os/LICENSE-APACHE +177 -0
- package/dist/compat/os/index.d.ts +329 -0
- package/dist/compat/os/index.js +278 -0
- package/dist/compat/path/LICENSE-3RD-PARTY.md +35 -0
- package/dist/compat/path/LICENSE-APACHE +177 -0
- package/dist/compat/path/index.d.ts +4 -0
- package/dist/compat/path/index.js +11 -0
- package/dist/compat/path/internal-path.d.ts +95 -0
- package/dist/compat/path/internal-path.js +1542 -0
- package/dist/compat/path/posix/index.d.ts +4 -0
- package/dist/compat/path/posix/index.js +5 -0
- package/dist/compat/path/win32/index.d.ts +4 -0
- package/dist/compat/path/win32/index.js +5 -0
- package/dist/compat/perf-hooks/LICENSE-3RD-PARTY.md +5 -0
- package/dist/compat/perf-hooks/LICENSE-APACHE +177 -0
- package/dist/compat/perf-hooks/index.d.ts +85 -0
- package/dist/compat/perf-hooks/index.js +79 -0
- package/dist/compat/perf-hooks/performance.d.ts +96 -0
- package/dist/compat/perf-hooks/performance.js +445 -0
- package/dist/compat/punycode/LICENSE-3RD-PARTY.md +7 -0
- package/dist/compat/punycode/LICENSE-APACHE +177 -0
- package/dist/compat/punycode/index.d.ts +93 -0
- package/dist/compat/punycode/index.js +410 -0
- package/dist/compat/querystring/LICENSE-3RD-PARTY.md +35 -0
- package/dist/compat/querystring/LICENSE-APACHE +177 -0
- package/dist/compat/querystring/index.d.ts +14 -0
- package/dist/compat/querystring/index.js +18 -0
- package/dist/compat/querystring/internal-querystring.d.ts +22 -0
- package/dist/compat/querystring/internal-querystring.js +498 -0
- package/dist/compat/readline/LICENSE-3RD-PARTY.md +37 -0
- package/dist/compat/readline/LICENSE-APACHE +177 -0
- package/dist/compat/readline/index.d.ts +21 -0
- package/dist/compat/readline/index.js +56 -0
- package/dist/compat/readline/interface.d.ts +22 -0
- package/dist/compat/readline/interface.js +85 -0
- package/dist/compat/readline/internal-promises.d.ts +32 -0
- package/dist/compat/readline/internal-promises.js +104 -0
- package/dist/compat/readline/promises.d.ts +8 -0
- package/dist/compat/readline/promises.js +32 -0
- package/dist/compat/repl/LICENSE-3RD-PARTY.md +5 -0
- package/dist/compat/repl/LICENSE-APACHE +177 -0
- package/dist/compat/repl/builtin-modules.d.ts +1 -0
- package/dist/compat/repl/builtin-modules.js +101 -0
- package/dist/compat/repl/errors.d.ts +4 -0
- package/dist/compat/repl/errors.js +6 -0
- package/dist/compat/repl/index.d.ts +53 -0
- package/dist/compat/repl/index.js +106 -0
- package/dist/compat/sqlite/LICENSE-3RD-PARTY.md +6 -0
- package/dist/compat/sqlite/LICENSE-APACHE +177 -0
- package/dist/compat/sqlite/index.d.ts +12 -0
- package/dist/compat/sqlite/index.js +101 -0
- package/dist/compat/sqlite/native.d.ts +16 -0
- package/dist/compat/sqlite/native.js +33 -0
- package/dist/compat/stream/LICENSE-3RD-PARTY.md +13 -0
- package/dist/compat/stream/LICENSE-APACHE +177 -0
- package/dist/compat/stream/add-abort-signal.d.ts +4 -0
- package/dist/compat/stream/add-abort-signal.js +73 -0
- package/dist/compat/stream/compose.d.ts +1 -0
- package/dist/compat/stream/compose.js +313 -0
- package/dist/compat/stream/destroy.d.ts +5 -0
- package/dist/compat/stream/destroy.js +315 -0
- package/dist/compat/stream/duplex.d.ts +48 -0
- package/dist/compat/stream/duplex.js +789 -0
- package/dist/compat/stream/end-of-stream.d.ts +16 -0
- package/dist/compat/stream/end-of-stream.js +269 -0
- package/dist/compat/stream/errors.d.ts +40 -0
- package/dist/compat/stream/errors.js +86 -0
- package/dist/compat/stream/events.d.ts +6 -0
- package/dist/compat/stream/events.js +28 -0
- package/dist/compat/stream/index.cjs +27 -0
- package/dist/compat/stream/index.d.cts +25 -0
- package/dist/compat/stream/index.d.ts +20 -0
- package/dist/compat/stream/index.js +55 -0
- package/dist/compat/stream/legacy.d.ts +8 -0
- package/dist/compat/stream/legacy.js +105 -0
- package/dist/compat/stream/once.d.ts +7 -0
- package/dist/compat/stream/once.js +13 -0
- package/dist/compat/stream/pipeline.d.ts +5 -0
- package/dist/compat/stream/pipeline.js +567 -0
- package/dist/compat/stream/process.d.ts +1 -0
- package/dist/compat/stream/process.js +4 -0
- package/dist/compat/stream/promises.d.ts +7 -0
- package/dist/compat/stream/promises.js +60 -0
- package/dist/compat/stream/readable.d.ts +29 -0
- package/dist/compat/stream/readable.js +2267 -0
- package/dist/compat/stream/state.d.ts +8 -0
- package/dist/compat/stream/state.js +63 -0
- package/dist/compat/stream/transform.d.ts +2 -0
- package/dist/compat/stream/transform.js +202 -0
- package/dist/compat/stream/util.d.ts +55 -0
- package/dist/compat/stream/util.js +345 -0
- package/dist/compat/stream/validators.d.ts +2 -0
- package/dist/compat/stream/validators.js +14 -0
- package/dist/compat/stream/writable.d.ts +21 -0
- package/dist/compat/stream/writable.js +1325 -0
- package/dist/compat/stream-consumers/LICENSE-3RD-PARTY.md +5 -0
- package/dist/compat/stream-consumers/LICENSE-APACHE +177 -0
- package/dist/compat/stream-consumers/index.d.ts +14 -0
- package/dist/compat/stream-consumers/index.js +62 -0
- package/dist/compat/stream-consumers/iterable.d.ts +1 -0
- package/dist/compat/stream-consumers/iterable.js +34 -0
- package/dist/compat/stream-duplex/LICENSE-3RD-PARTY.md +13 -0
- package/dist/compat/stream-duplex/LICENSE-APACHE +177 -0
- package/dist/compat/stream-duplex/index.cjs +3 -0
- package/dist/compat/stream-duplex/index.d.cts +2 -0
- package/dist/compat/stream-duplex/index.d.ts +3 -0
- package/dist/compat/stream-duplex/index.js +8 -0
- package/dist/compat/stream-passthrough/LICENSE-3RD-PARTY.md +13 -0
- package/dist/compat/stream-passthrough/LICENSE-APACHE +177 -0
- package/dist/compat/stream-passthrough/index.cjs +3 -0
- package/dist/compat/stream-passthrough/index.d.cts +2 -0
- package/dist/compat/stream-passthrough/index.d.ts +3 -0
- package/dist/compat/stream-passthrough/index.js +8 -0
- package/dist/compat/stream-promises/LICENSE-3RD-PARTY.md +13 -0
- package/dist/compat/stream-promises/LICENSE-APACHE +177 -0
- package/dist/compat/stream-promises/index.d.ts +1 -0
- package/dist/compat/stream-promises/index.js +1 -0
- package/dist/compat/stream-readable/LICENSE-3RD-PARTY.md +13 -0
- package/dist/compat/stream-readable/LICENSE-APACHE +177 -0
- package/dist/compat/stream-readable/index.cjs +3 -0
- package/dist/compat/stream-readable/index.d.cts +2 -0
- package/dist/compat/stream-readable/index.d.ts +3 -0
- package/dist/compat/stream-readable/index.js +8 -0
- package/dist/compat/stream-transform/LICENSE-3RD-PARTY.md +13 -0
- package/dist/compat/stream-transform/LICENSE-APACHE +177 -0
- package/dist/compat/stream-transform/index.cjs +3 -0
- package/dist/compat/stream-transform/index.d.cts +2 -0
- package/dist/compat/stream-transform/index.d.ts +3 -0
- package/dist/compat/stream-transform/index.js +8 -0
- package/dist/compat/stream-web/LICENSE-MIT +22 -0
- package/dist/compat/stream-web/NOTICE.md +3 -0
- package/dist/compat/stream-web/context.d.ts +2 -0
- package/dist/compat/stream-web/context.js +35 -0
- package/dist/compat/stream-web/index.d.ts +80 -0
- package/dist/compat/stream-web/index.js +129 -0
- package/dist/compat/stream-web/interop.d.ts +6 -0
- package/dist/compat/stream-web/interop.js +72 -0
- package/dist/compat/stream-web/ponyfill.d.ts +1 -0
- package/dist/compat/stream-web/ponyfill.js +2093 -0
- package/dist/compat/stream-web/runtime.d.ts +16 -0
- package/dist/compat/stream-web/runtime.js +51 -0
- package/dist/compat/stream-writable/LICENSE-3RD-PARTY.md +13 -0
- package/dist/compat/stream-writable/LICENSE-APACHE +177 -0
- package/dist/compat/stream-writable/index.cjs +3 -0
- package/dist/compat/stream-writable/index.d.cts +2 -0
- package/dist/compat/stream-writable/index.d.ts +3 -0
- package/dist/compat/stream-writable/index.js +8 -0
- package/dist/compat/string-decoder/LICENSE-3RD-PARTY.md +38 -0
- package/dist/compat/string-decoder/LICENSE-APACHE +177 -0
- package/dist/compat/string-decoder/index.d.ts +33 -0
- package/dist/compat/string-decoder/index.js +518 -0
- package/dist/compat/test/LICENSE-3RD-PARTY.md +37 -0
- package/dist/compat/test/LICENSE-APACHE +177 -0
- package/dist/compat/test/index.d.ts +9 -0
- package/dist/compat/test/index.js +11 -0
- package/dist/compat/test/mock.d.ts +103 -0
- package/dist/compat/test/mock.js +397 -0
- package/dist/compat/test/validators.d.ts +2 -0
- package/dist/compat/test/validators.js +14 -0
- package/dist/compat/timers/LICENSE-3RD-PARTY.md +7 -0
- package/dist/compat/timers/LICENSE-APACHE +177 -0
- package/dist/compat/timers/errors.d.ts +28 -0
- package/dist/compat/timers/errors.js +206 -0
- package/dist/compat/timers/host.d.ts +11 -0
- package/dist/compat/timers/host.js +60 -0
- package/dist/compat/timers/index.cjs +3 -0
- package/dist/compat/timers/index.d.cts +23 -0
- package/dist/compat/timers/index.d.ts +36 -0
- package/dist/compat/timers/index.js +20 -0
- package/dist/compat/timers/installation.d.ts +4 -0
- package/dist/compat/timers/installation.js +61 -0
- package/dist/compat/timers/internal-promises.d.ts +19 -0
- package/dist/compat/timers/internal-promises.js +173 -0
- package/dist/compat/timers/promises.cjs +2 -0
- package/dist/compat/timers/promises.d.cts +12 -0
- package/dist/compat/timers/promises.d.ts +14 -0
- package/dist/compat/timers/promises.js +3 -0
- package/dist/compat/timers/timers.d.ts +32 -0
- package/dist/compat/timers/timers.js +147 -0
- package/dist/compat/timers/validation.d.ts +5 -0
- package/dist/compat/timers/validation.js +22 -0
- package/dist/compat/timers/wait.d.ts +4 -0
- package/dist/compat/timers/wait.js +91 -0
- package/dist/compat/tls-common/LICENSE-3RD-PARTY.md +11 -0
- package/dist/compat/tls-common/LICENSE-APACHE +177 -0
- package/dist/compat/tls-common/index.d.ts +14 -0
- package/dist/compat/tls-common/index.js +88 -0
- package/dist/compat/trace-events/LICENSE-3RD-PARTY.md +5 -0
- package/dist/compat/trace-events/LICENSE-APACHE +177 -0
- package/dist/compat/trace-events/index.d.ts +18 -0
- package/dist/compat/trace-events/index.js +88 -0
- package/dist/compat/tty/LICENSE-3RD-PARTY.md +8 -0
- package/dist/compat/tty/LICENSE-APACHE +177 -0
- package/dist/compat/tty/index.d.ts +17 -0
- package/dist/compat/tty/index.js +101 -0
- package/dist/compat/url/LICENSE-3RD-PARTY.md +63 -0
- package/dist/compat/url/LICENSE-ADA +18 -0
- package/dist/compat/url/LICENSE-APACHE +177 -0
- package/dist/compat/url/LICENSE-UNICODE +39 -0
- package/dist/compat/url/LICENSE-WHATWG-URL +21 -0
- package/dist/compat/url/brand.d.ts +4 -0
- package/dist/compat/url/brand.js +10 -0
- package/dist/compat/url/constants.d.ts +27 -0
- package/dist/compat/url/constants.js +28 -0
- package/dist/compat/url/errors.d.ts +44 -0
- package/dist/compat/url/errors.js +248 -0
- package/dist/compat/url/idna-data.d.ts +3958 -0
- package/dist/compat/url/idna-data.js +22 -0
- package/dist/compat/url/idna.d.ts +9 -0
- package/dist/compat/url/idna.js +47 -0
- package/dist/compat/url/index.d.ts +48 -0
- package/dist/compat/url/index.js +39 -0
- package/dist/compat/url/installation.d.ts +4 -0
- package/dist/compat/url/installation.js +61 -0
- package/dist/compat/url/internal-url.d.ts +34 -0
- package/dist/compat/url/internal-url.js +264 -0
- package/dist/compat/url/legacy-url.d.ts +28 -0
- package/dist/compat/url/legacy-url.js +870 -0
- package/dist/compat/url/parser-platform.d.ts +3 -0
- package/dist/compat/url/parser-platform.js +26 -0
- package/dist/compat/url/standard-url.d.ts +2 -0
- package/dist/compat/url/standard-url.js +3189 -0
- package/dist/compat/url/unicode.d.ts +2 -0
- package/dist/compat/url/unicode.js +119 -0
- package/dist/compat/url/validation.d.ts +2 -0
- package/dist/compat/url/validation.js +9 -0
- package/dist/compat/url/web-url.d.ts +27 -0
- package/dist/compat/url/web-url.js +119 -0
- package/dist/compat/util/LICENSE-3RD-PARTY.md +5 -0
- package/dist/compat/util/LICENSE-APACHE +177 -0
- package/dist/compat/util/additional.d.ts +11 -0
- package/dist/compat/util/additional.js +121 -0
- package/dist/compat/util/comparison-types.d.ts +16 -0
- package/dist/compat/util/comparison-types.js +50 -0
- package/dist/compat/util/comparisons.d.ts +1 -0
- package/dist/compat/util/comparisons.js +527 -0
- package/dist/compat/util/core.d.ts +18 -0
- package/dist/compat/util/core.js +265 -0
- package/dist/compat/util/debuglog.d.ts +1 -0
- package/dist/compat/util/debuglog.js +78 -0
- package/dist/compat/util/index.d.ts +35 -0
- package/dist/compat/util/index.js +77 -0
- package/dist/compat/util/inspect-binding.d.ts +13 -0
- package/dist/compat/util/inspect-binding.js +39 -0
- package/dist/compat/util/inspect-types.d.ts +13 -0
- package/dist/compat/util/inspect-types.js +30 -0
- package/dist/compat/util/inspect.d.ts +152 -0
- package/dist/compat/util/inspect.js +2503 -0
- package/dist/compat/util/mime.d.ts +24 -0
- package/dist/compat/util/mime.js +284 -0
- package/dist/compat/util/properties.d.ts +9 -0
- package/dist/compat/util/properties.js +76 -0
- package/dist/compat/v8/LICENSE-3RD-PARTY.md +6 -0
- package/dist/compat/v8/LICENSE-APACHE +177 -0
- package/dist/compat/v8/errors.d.ts +5 -0
- package/dist/compat/v8/errors.js +7 -0
- package/dist/compat/v8/index.d.ts +106 -0
- package/dist/compat/v8/index.js +280 -0
- package/dist/compat/vm/LICENSE-3RD-PARTY.md +39 -0
- package/dist/compat/vm/LICENSE-APACHE +177 -0
- package/dist/compat/vm/errors.d.ts +5 -0
- package/dist/compat/vm/errors.js +7 -0
- package/dist/compat/vm/index.d.ts +47 -0
- package/dist/compat/vm/index.js +231 -0
- package/dist/compat/vm/validation.d.ts +3 -0
- package/dist/compat/vm/validation.js +14 -0
- package/dist/compat/wasi/LICENSE-3RD-PARTY.md +8 -0
- package/dist/compat/wasi/LICENSE-APACHE +177 -0
- package/dist/compat/wasi/errors.d.ts +4 -0
- package/dist/compat/wasi/errors.js +6 -0
- package/dist/compat/wasi/index.d.ts +15 -0
- package/dist/compat/wasi/index.js +44 -0
- package/dist/compat/worker-threads/LICENSE-3RD-PARTY.md +5 -0
- package/dist/compat/worker-threads/LICENSE-APACHE +177 -0
- package/dist/compat/worker-threads/errors.d.ts +4 -0
- package/dist/compat/worker-threads/errors.js +6 -0
- package/dist/compat/worker-threads/index.d.ts +71 -0
- package/dist/compat/worker-threads/index.js +138 -0
- package/dist/compat/worker-threads/message-channel.d.ts +18 -0
- package/dist/compat/worker-threads/message-channel.js +157 -0
- package/dist/configured.d.ts +3 -0
- package/dist/configured.js +4 -0
- package/dist/environment.d.ts +4 -0
- package/dist/environment.js +18 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +107 -0
- package/dist/ios.d.ts +2 -0
- package/dist/ios.js +1 -0
- package/dist/native-entry.d.ts +8 -0
- package/dist/native-entry.js +67 -0
- package/dist/shared/brotli/LICENSE-APACHE +201 -0
- package/dist/shared/brotli/LICENSE-MIT +9 -0
- package/dist/shared/brotli/NOTICE +3 -0
- package/dist/shared/brotli/index.d.ts +2 -0
- package/dist/shared/brotli/index.js +288 -0
- package/dist/shared/contracts/index.d.ts +42 -0
- package/dist/shared/contracts/index.js +88 -0
- package/dist/shared/contracts/testing.d.ts +22 -0
- package/dist/shared/contracts/testing.js +57 -0
- package/dist/shared/globals/index.d.ts +3 -0
- package/dist/shared/globals/index.js +87 -0
- package/dist/shared/globals/inject.d.ts +2 -0
- package/dist/shared/globals/inject.js +3 -0
- package/dist/shared/globals/install.d.ts +1 -0
- package/dist/shared/globals/install.js +15 -0
- package/dist/shared/globals/node-install.d.ts +1 -0
- package/dist/shared/globals/node-install.js +4 -0
- package/dist/shared/globals/platform.d.ts +104 -0
- package/dist/shared/globals/platform.js +37 -0
- package/dist/shared/globals/runtime.d.ts +6 -0
- package/dist/shared/globals/runtime.js +8 -0
- package/dist/shared/globals/symbols.d.ts +4 -0
- package/dist/shared/globals/symbols.js +35 -0
- package/dist/shared/globals/web.d.ts +4 -0
- package/dist/shared/globals/web.js +108 -0
- package/dist/shared/http-wire/LICENSE.llhttp +22 -0
- package/dist/shared/http-wire/LICENSE.undici +21 -0
- package/dist/shared/http-wire/NOTICE.md +14 -0
- package/dist/shared/http-wire/index.d.ts +27 -0
- package/dist/shared/http-wire/index.js +132 -0
- package/dist/shared/http-wire/wasm.d.ts +2 -0
- package/dist/shared/http-wire/wasm.js +2 -0
- package/dist/tooling/async.d.ts +7 -0
- package/dist/tooling/async.js +99 -0
- package/dist/tooling/build-isolation.d.ts +4 -0
- package/dist/tooling/build-isolation.js +34 -0
- package/dist/tooling/documents.d.ts +7 -0
- package/dist/tooling/documents.js +26 -0
- package/dist/tooling/esbuild.d.ts +15 -0
- package/dist/tooling/esbuild.js +193 -0
- package/dist/tooling/files.d.ts +2 -0
- package/dist/tooling/files.js +18 -0
- package/dist/tooling/opennext/build.d.ts +1 -0
- package/dist/tooling/opennext/build.js +121 -0
- package/dist/tooling/opennext/index.d.ts +3 -0
- package/dist/tooling/opennext/index.js +213 -0
- package/dist/tooling/opennext/plan.d.ts +9 -0
- package/dist/tooling/opennext/plan.js +36 -0
- package/dist/tooling/opennext/safety.d.ts +4 -0
- package/dist/tooling/opennext/safety.js +36 -0
- package/dist/tooling/route-permissions.d.ts +3 -0
- package/dist/tooling/route-permissions.js +15 -0
- package/dist/tooling/server-modules.d.ts +30 -0
- package/dist/tooling/server-modules.js +98 -0
- package/dist/tooling/server-only-html.d.ts +1 -0
- package/dist/tooling/server-only-html.js +66 -0
- package/dist/tooling/server-only.d.ts +6 -0
- package/dist/tooling/server-only.js +53 -0
- package/dist/tooling/server.d.ts +25 -0
- package/dist/tooling/server.js +981 -0
- package/dist/tooling/shared.d.ts +13 -0
- package/dist/tooling/shared.js +130 -0
- package/dist/tooling/vite.d.ts +18 -0
- package/dist/tooling/vite.js +448 -0
- package/dist/tooling/void/index.d.ts +3 -0
- package/dist/tooling/void/index.js +205 -0
- package/dist/tooling/void/plan.d.ts +17 -0
- package/dist/tooling/void/plan.js +288 -0
- package/native/android/build.gradle +68 -0
- package/native/android/consumer-rules.pro +2 -0
- package/native/android/src/main/AndroidManifest.xml +6 -0
- package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkerSockets.java +202 -0
- package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkersCapacitorPlugin.java +256 -0
- package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkersNative.java +22 -0
- package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkersNativeActivity.java +178 -0
- package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkersNativeBridge.java +45 -0
- package/native/ios/DocumentBridge.swift +330 -0
- package/native/ios/NetworkBridge.swift +51 -0
- package/native/ios/SocketBridge.swift +180 -0
- package/native/ios/WorkersCapacitorPlugin.swift +152 -0
- package/native/ios-host/WorkersView.swift +194 -0
- package/package.json +154 -4
|
@@ -0,0 +1,858 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
// Copyright (c) 2017-2022 Cloudflare, Inc.
|
|
3
|
+
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
4
|
+
// https://opensource.org/licenses/Apache-2.0
|
|
5
|
+
//
|
|
6
|
+
// Adapted from Deno and Node.js:
|
|
7
|
+
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
|
8
|
+
//
|
|
9
|
+
// Adapted from Node.js. Copyright Joyent, Inc. and other Node contributors.
|
|
10
|
+
//
|
|
11
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
12
|
+
// copy of this software and associated documentation files (the
|
|
13
|
+
// "Software"), to deal in the Software without restriction, including
|
|
14
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
15
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
16
|
+
// persons to whom the Software is furnished to do so, subject to the
|
|
17
|
+
// following conditions:
|
|
18
|
+
//
|
|
19
|
+
// The above copyright notice and this permission notice shall be included
|
|
20
|
+
// in all copies or substantial portions of the Software.
|
|
21
|
+
//
|
|
22
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
23
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
24
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
25
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
26
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
27
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
28
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
29
|
+
/* eslint-disable */
|
|
30
|
+
import { AssertionError, } from "./assertion-error.js";
|
|
31
|
+
import { diffstr, diff, buildMessage } from "./diff.js";
|
|
32
|
+
import { isDeepStrictEqual } from "../util/comparisons.js";
|
|
33
|
+
import { ERR_AMBIGUOUS_ARGUMENT, ERR_INVALID_ARG_TYPE, ERR_INVALID_ARG_VALUE, ERR_INVALID_RETURN_VALUE, ERR_MISSING_ARGS, } from "./errors.js";
|
|
34
|
+
import { inspect } from "../util/inspect.js";
|
|
35
|
+
function createAssertionError(options) {
|
|
36
|
+
const error = new AssertionError(options);
|
|
37
|
+
if (options.generatedMessage) {
|
|
38
|
+
error.generatedMessage = true;
|
|
39
|
+
}
|
|
40
|
+
return error;
|
|
41
|
+
}
|
|
42
|
+
// Note: Intentionally not exported, use assert.ok() instead.
|
|
43
|
+
function assert(actual, message) {
|
|
44
|
+
if (arguments.length === 0) {
|
|
45
|
+
throw new AssertionError({
|
|
46
|
+
message: "No value argument passed to `assert.ok()`",
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
if (!actual) {
|
|
50
|
+
throw new AssertionError({
|
|
51
|
+
message,
|
|
52
|
+
actual,
|
|
53
|
+
expected: true,
|
|
54
|
+
operator: "==",
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export const ok = assert;
|
|
59
|
+
export function throws(fn, error, message) {
|
|
60
|
+
// Check arg types
|
|
61
|
+
if (typeof fn !== "function") {
|
|
62
|
+
throw new ERR_INVALID_ARG_TYPE("fn", "function", fn);
|
|
63
|
+
}
|
|
64
|
+
if (typeof error === "object" &&
|
|
65
|
+
error !== null &&
|
|
66
|
+
Object.getPrototypeOf(error) === Object.prototype &&
|
|
67
|
+
Object.keys(error).length === 0) {
|
|
68
|
+
// error is an empty object
|
|
69
|
+
throw new ERR_INVALID_ARG_VALUE("error", error, "may not be an empty object");
|
|
70
|
+
}
|
|
71
|
+
if (typeof message === "string") {
|
|
72
|
+
if (!(error instanceof RegExp) &&
|
|
73
|
+
typeof error !== "function" &&
|
|
74
|
+
!(error instanceof Error) &&
|
|
75
|
+
typeof error !== "object") {
|
|
76
|
+
throw new ERR_INVALID_ARG_TYPE("error", ["Function", "Error", "RegExp", "Object"], error);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
if (typeof error !== "undefined" &&
|
|
81
|
+
typeof error !== "string" &&
|
|
82
|
+
!(error instanceof RegExp) &&
|
|
83
|
+
typeof error !== "function" &&
|
|
84
|
+
!(error instanceof Error) &&
|
|
85
|
+
typeof error !== "object") {
|
|
86
|
+
throw new ERR_INVALID_ARG_TYPE("error", ["Function", "Error", "RegExp", "Object"], error);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Checks test function
|
|
90
|
+
try {
|
|
91
|
+
fn();
|
|
92
|
+
}
|
|
93
|
+
catch (e) {
|
|
94
|
+
if (validateThrownError(e, error, message, {
|
|
95
|
+
operator: throws,
|
|
96
|
+
})) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (message) {
|
|
101
|
+
let msg = `Missing expected exception: ${message}`;
|
|
102
|
+
if (typeof error === "function" && error?.name) {
|
|
103
|
+
msg = `Missing expected exception (${error.name}): ${message}`;
|
|
104
|
+
}
|
|
105
|
+
throw new AssertionError({
|
|
106
|
+
message: msg,
|
|
107
|
+
operator: "throws",
|
|
108
|
+
actual: undefined,
|
|
109
|
+
expected: error,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
else if (typeof error === "string") {
|
|
113
|
+
// Use case of throws(fn, message)
|
|
114
|
+
throw new AssertionError({
|
|
115
|
+
message: `Missing expected exception: ${error}`,
|
|
116
|
+
operator: "throws",
|
|
117
|
+
actual: undefined,
|
|
118
|
+
expected: undefined,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
else if (typeof error === "function" && error?.prototype !== undefined) {
|
|
122
|
+
throw new AssertionError({
|
|
123
|
+
message: `Missing expected exception (${error.name}).`,
|
|
124
|
+
operator: "throws",
|
|
125
|
+
actual: undefined,
|
|
126
|
+
expected: error,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
throw new AssertionError({
|
|
131
|
+
message: "Missing expected exception.",
|
|
132
|
+
operator: "throws",
|
|
133
|
+
actual: undefined,
|
|
134
|
+
expected: error,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
export function doesNotThrow(fn, expected, message) {
|
|
139
|
+
// Check arg type
|
|
140
|
+
if (typeof fn !== "function") {
|
|
141
|
+
throw new ERR_INVALID_ARG_TYPE("fn", "function", fn);
|
|
142
|
+
}
|
|
143
|
+
else if (!(expected instanceof RegExp) &&
|
|
144
|
+
typeof expected !== "function" &&
|
|
145
|
+
typeof expected !== "string" &&
|
|
146
|
+
typeof expected !== "undefined") {
|
|
147
|
+
throw new ERR_INVALID_ARG_TYPE("expected", ["Function", "RegExp"], fn);
|
|
148
|
+
}
|
|
149
|
+
// Checks test function
|
|
150
|
+
try {
|
|
151
|
+
fn();
|
|
152
|
+
}
|
|
153
|
+
catch (e) {
|
|
154
|
+
gotUnwantedException(e, expected, message, doesNotThrow);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
export function equal(actual, expected, message) {
|
|
158
|
+
return strictEqual(actual, expected, message);
|
|
159
|
+
}
|
|
160
|
+
export function notEqual(actual, expected, message) {
|
|
161
|
+
return notStrictEqual(actual, expected, message);
|
|
162
|
+
}
|
|
163
|
+
export function strictEqual(actual, expected, message) {
|
|
164
|
+
if (arguments.length < 2) {
|
|
165
|
+
throw new ERR_MISSING_ARGS("actual", "expected");
|
|
166
|
+
}
|
|
167
|
+
if (Object.is(actual, expected)) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (message) {
|
|
171
|
+
message = `${message}`;
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
const actualString = inspect(actual);
|
|
175
|
+
const expectedString = inspect(expected);
|
|
176
|
+
if (actualString === expectedString) {
|
|
177
|
+
const withOffset = actualString
|
|
178
|
+
.split("\n")
|
|
179
|
+
.map((l) => ` ${l}`)
|
|
180
|
+
.join("\n");
|
|
181
|
+
message = `Values have the same structure but are not reference-equal:\n\n${withOffset}\n`;
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
try {
|
|
185
|
+
const stringDiff = typeof actual === "string" && typeof expected === "string";
|
|
186
|
+
const diffResult = stringDiff
|
|
187
|
+
? diffstr(actual, expected)
|
|
188
|
+
: diff(actualString.split("\n"), expectedString.split("\n"));
|
|
189
|
+
const diffMsg = buildMessage(diffResult, { stringDiff }).join("\n");
|
|
190
|
+
message = `Values are not strictly equal:\n${diffMsg}`;
|
|
191
|
+
}
|
|
192
|
+
catch {
|
|
193
|
+
message = "\n$[Cannot display] + \n\n";
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
throw new AssertionError({
|
|
198
|
+
message,
|
|
199
|
+
actual,
|
|
200
|
+
expected,
|
|
201
|
+
operator: "strictEqual",
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
export function notStrictEqual(actual, expected, message) {
|
|
205
|
+
if (arguments.length < 2) {
|
|
206
|
+
throw new ERR_MISSING_ARGS("actual", "expected");
|
|
207
|
+
}
|
|
208
|
+
if (!Object.is(actual, expected)) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
if (message) {
|
|
212
|
+
message = `${message}`;
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
message = "Expected actual to be strictly unequal to expected";
|
|
216
|
+
}
|
|
217
|
+
throw new AssertionError({
|
|
218
|
+
message,
|
|
219
|
+
actual,
|
|
220
|
+
expected,
|
|
221
|
+
operator: "notStrictEqual",
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
export function deepEqual(actual, expected, message) {
|
|
225
|
+
return deepStrictEqual(actual, expected, message);
|
|
226
|
+
}
|
|
227
|
+
export function notDeepEqual(actual, expected, message) {
|
|
228
|
+
return notDeepStrictEqual(actual, expected, message);
|
|
229
|
+
}
|
|
230
|
+
export function deepStrictEqual(actual, expected, message) {
|
|
231
|
+
if (arguments.length < 2) {
|
|
232
|
+
throw new ERR_MISSING_ARGS("actual", "expected");
|
|
233
|
+
}
|
|
234
|
+
if (isDeepStrictEqual(actual, expected)) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (message) {
|
|
238
|
+
message = `${message}`;
|
|
239
|
+
}
|
|
240
|
+
throw new AssertionError({
|
|
241
|
+
message,
|
|
242
|
+
actual,
|
|
243
|
+
expected,
|
|
244
|
+
operator: "deepStrictEqual",
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
export function notDeepStrictEqual(actual, expected, message) {
|
|
248
|
+
if (arguments.length < 2) {
|
|
249
|
+
throw new ERR_MISSING_ARGS("actual", "expected");
|
|
250
|
+
}
|
|
251
|
+
if (isDeepStrictEqual(actual, expected)) {
|
|
252
|
+
if (message) {
|
|
253
|
+
message = `${message}`;
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
message = "Expected actual to not be deeply strictly equal to expected";
|
|
257
|
+
}
|
|
258
|
+
throw new AssertionError({
|
|
259
|
+
message,
|
|
260
|
+
actual,
|
|
261
|
+
expected,
|
|
262
|
+
operator: "notDeepStrictEqual",
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
// Helper function to check if actual contains all properties from expected with deep strict equality
|
|
267
|
+
function isPartialDeepStrictEqual(actual, expected, memo) {
|
|
268
|
+
// Handle primitive cases first
|
|
269
|
+
if (expected === null || typeof expected !== "object") {
|
|
270
|
+
return Object.is(actual, expected);
|
|
271
|
+
}
|
|
272
|
+
if (actual === null || typeof actual !== "object") {
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
// Initialize memo for cycle detection on first call
|
|
276
|
+
memo ??= new Map();
|
|
277
|
+
// Cycle detection: check if we're already comparing this pair
|
|
278
|
+
if (memo.has(actual)) {
|
|
279
|
+
const actualSet = memo.get(actual);
|
|
280
|
+
if (actualSet.has(expected)) {
|
|
281
|
+
// We're already comparing this pair, assume they match to avoid infinite recursion
|
|
282
|
+
return true;
|
|
283
|
+
}
|
|
284
|
+
actualSet.add(expected);
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
memo.set(actual, new Set([expected]));
|
|
288
|
+
}
|
|
289
|
+
try {
|
|
290
|
+
// Handle Date objects
|
|
291
|
+
if (expected instanceof Date) {
|
|
292
|
+
return actual instanceof Date && actual.getTime() === expected.getTime();
|
|
293
|
+
}
|
|
294
|
+
// Handle RegExp objects
|
|
295
|
+
if (expected instanceof RegExp) {
|
|
296
|
+
return (actual instanceof RegExp &&
|
|
297
|
+
actual.source === expected.source &&
|
|
298
|
+
actual.flags === expected.flags &&
|
|
299
|
+
actual.lastIndex === expected.lastIndex);
|
|
300
|
+
}
|
|
301
|
+
// Handle Error objects
|
|
302
|
+
if (expected instanceof Error) {
|
|
303
|
+
return (actual instanceof Error &&
|
|
304
|
+
actual.name === expected.name &&
|
|
305
|
+
actual.message === expected.message);
|
|
306
|
+
}
|
|
307
|
+
// Handle arrays
|
|
308
|
+
if (Array.isArray(expected)) {
|
|
309
|
+
if (!Array.isArray(actual)) {
|
|
310
|
+
return false;
|
|
311
|
+
}
|
|
312
|
+
// For arrays, check if all expected elements are present in actual
|
|
313
|
+
// This allows for sparse checking - actual can have more elements
|
|
314
|
+
for (let i = 0; i < expected.length; i++) {
|
|
315
|
+
if (i in expected) {
|
|
316
|
+
if (!(i in actual) ||
|
|
317
|
+
!isPartialDeepStrictEqual(actual[i], expected[i], memo)) {
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return true;
|
|
323
|
+
}
|
|
324
|
+
// Handle Sets
|
|
325
|
+
if (expected instanceof Set) {
|
|
326
|
+
if (!(actual instanceof Set)) {
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
// Check if all expected values are in actual set
|
|
330
|
+
for (const expectedValue of expected) {
|
|
331
|
+
let found = false;
|
|
332
|
+
for (const actualValue of actual) {
|
|
333
|
+
if (isDeepStrictEqual(expectedValue, actualValue)) {
|
|
334
|
+
found = true;
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
if (!found) {
|
|
339
|
+
return false;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return true;
|
|
343
|
+
}
|
|
344
|
+
// Handle Maps
|
|
345
|
+
if (expected instanceof Map) {
|
|
346
|
+
if (!(actual instanceof Map)) {
|
|
347
|
+
return false;
|
|
348
|
+
}
|
|
349
|
+
// Check if all expected key-value pairs are in actual map
|
|
350
|
+
for (const [expectedKey, expectedValue] of expected) {
|
|
351
|
+
let found = false;
|
|
352
|
+
for (const [actualKey, actualValue] of actual) {
|
|
353
|
+
if (isDeepStrictEqual(expectedKey, actualKey)) {
|
|
354
|
+
if (!isPartialDeepStrictEqual(actualValue, expectedValue, memo)) {
|
|
355
|
+
return false;
|
|
356
|
+
}
|
|
357
|
+
found = true;
|
|
358
|
+
break;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
if (!found) {
|
|
362
|
+
return false;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return true;
|
|
366
|
+
}
|
|
367
|
+
// Check prototypes are the same (required for deepStrictEqual behavior)
|
|
368
|
+
if (Object.getPrototypeOf(actual) !== Object.getPrototypeOf(expected)) {
|
|
369
|
+
return false;
|
|
370
|
+
}
|
|
371
|
+
// Handle regular objects
|
|
372
|
+
const expectedKeys = Object.keys(expected);
|
|
373
|
+
for (const key of expectedKeys) {
|
|
374
|
+
if (!(key in actual)) {
|
|
375
|
+
return false;
|
|
376
|
+
}
|
|
377
|
+
if (!isPartialDeepStrictEqual(actual[key], expected[key], memo)) {
|
|
378
|
+
return false;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
// Handle symbol properties
|
|
382
|
+
const expectedSymbols = Object.getOwnPropertySymbols(expected);
|
|
383
|
+
for (const symbol of expectedSymbols) {
|
|
384
|
+
if (expected.propertyIsEnumerable(symbol)) {
|
|
385
|
+
if (!(symbol in actual) ||
|
|
386
|
+
!isPartialDeepStrictEqual(actual[symbol], expected[symbol], memo)) {
|
|
387
|
+
return false;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
return true;
|
|
392
|
+
}
|
|
393
|
+
finally {
|
|
394
|
+
// Clean up memo to prevent memory leaks
|
|
395
|
+
if (memo.has(actual)) {
|
|
396
|
+
const actualSet = memo.get(actual);
|
|
397
|
+
actualSet.delete(expected);
|
|
398
|
+
if (actualSet.size === 0) {
|
|
399
|
+
memo.delete(actual);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
export function partialDeepStrictEqual(actual, expected, message) {
|
|
405
|
+
if (arguments.length < 2) {
|
|
406
|
+
throw new ERR_MISSING_ARGS("actual", "expected");
|
|
407
|
+
}
|
|
408
|
+
if (isPartialDeepStrictEqual(actual, expected)) {
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
if (message) {
|
|
412
|
+
message = `${message}`;
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
message =
|
|
416
|
+
"Expected actual to be partially deeply strictly equal to expected";
|
|
417
|
+
}
|
|
418
|
+
throw new AssertionError({
|
|
419
|
+
message,
|
|
420
|
+
actual,
|
|
421
|
+
expected,
|
|
422
|
+
operator: "partialDeepStrictEqual",
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
export function fail(message) {
|
|
426
|
+
if (typeof message === "string" || message == null) {
|
|
427
|
+
throw createAssertionError({
|
|
428
|
+
message: message ?? "Failed",
|
|
429
|
+
operator: "fail",
|
|
430
|
+
generatedMessage: message == null,
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
else {
|
|
434
|
+
throw message;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
export function match(actual, regexp, message) {
|
|
438
|
+
if (arguments.length < 2) {
|
|
439
|
+
throw new ERR_MISSING_ARGS("actual", "regexp");
|
|
440
|
+
}
|
|
441
|
+
if (!(regexp instanceof RegExp)) {
|
|
442
|
+
throw new ERR_INVALID_ARG_TYPE("regexp", "RegExp", regexp);
|
|
443
|
+
}
|
|
444
|
+
if (!regexp.test(actual)) {
|
|
445
|
+
if (!message) {
|
|
446
|
+
message = `actual: "${actual}" expected to match: "${regexp}"`;
|
|
447
|
+
}
|
|
448
|
+
else {
|
|
449
|
+
message = `${message}`;
|
|
450
|
+
}
|
|
451
|
+
throw new AssertionError({
|
|
452
|
+
message,
|
|
453
|
+
actual,
|
|
454
|
+
expected: regexp,
|
|
455
|
+
operator: "match",
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
export function doesNotMatch(string, regexp, message) {
|
|
460
|
+
if (arguments.length < 2) {
|
|
461
|
+
throw new ERR_MISSING_ARGS("string", "regexp");
|
|
462
|
+
}
|
|
463
|
+
if (!(regexp instanceof RegExp)) {
|
|
464
|
+
throw new ERR_INVALID_ARG_TYPE("regexp", "RegExp", regexp);
|
|
465
|
+
}
|
|
466
|
+
if (typeof string !== "string") {
|
|
467
|
+
if (message instanceof Error) {
|
|
468
|
+
throw message;
|
|
469
|
+
}
|
|
470
|
+
throw new AssertionError({
|
|
471
|
+
message: message ||
|
|
472
|
+
`The "string" argument must be of type string. Received type ${typeof string} (${inspect(string)})`,
|
|
473
|
+
actual: string,
|
|
474
|
+
expected: regexp,
|
|
475
|
+
operator: "doesNotMatch",
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
if (regexp.test(string)) {
|
|
479
|
+
if (!message) {
|
|
480
|
+
message = `actual: "${string}" expected to not match: "${regexp}"`;
|
|
481
|
+
}
|
|
482
|
+
else {
|
|
483
|
+
message = `${message}`;
|
|
484
|
+
}
|
|
485
|
+
throw new AssertionError({
|
|
486
|
+
message,
|
|
487
|
+
actual: string,
|
|
488
|
+
expected: regexp,
|
|
489
|
+
operator: "doesNotMatch",
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
export function strict(actual, message) {
|
|
494
|
+
if (arguments.length === 0) {
|
|
495
|
+
throw new AssertionError({
|
|
496
|
+
message: "No value argument passed to `assert.ok()`",
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
assert(actual, message);
|
|
500
|
+
}
|
|
501
|
+
export function rejects(asyncFn, error, message) {
|
|
502
|
+
let promise;
|
|
503
|
+
if (typeof asyncFn === "function") {
|
|
504
|
+
try {
|
|
505
|
+
promise = asyncFn();
|
|
506
|
+
}
|
|
507
|
+
catch (err) {
|
|
508
|
+
return Promise.reject(err);
|
|
509
|
+
}
|
|
510
|
+
if (!isValidThenable(promise)) {
|
|
511
|
+
return Promise.reject(new ERR_INVALID_RETURN_VALUE("instance of Promise", "promiseFn", promise));
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
else if (!isValidThenable(asyncFn)) {
|
|
515
|
+
return Promise.reject(new ERR_INVALID_ARG_TYPE("promiseFn", ["function", "Promise"], asyncFn));
|
|
516
|
+
}
|
|
517
|
+
else {
|
|
518
|
+
promise = asyncFn;
|
|
519
|
+
}
|
|
520
|
+
function onFulfilled() {
|
|
521
|
+
let message = "Missing expected rejection";
|
|
522
|
+
if (typeof error === "string") {
|
|
523
|
+
message += `: ${error}`;
|
|
524
|
+
}
|
|
525
|
+
else if (typeof error === "function" && error.prototype !== undefined) {
|
|
526
|
+
message += ` (${error.name}).`;
|
|
527
|
+
}
|
|
528
|
+
else {
|
|
529
|
+
message += ".";
|
|
530
|
+
}
|
|
531
|
+
return Promise.reject(createAssertionError({
|
|
532
|
+
message,
|
|
533
|
+
operator: "rejects",
|
|
534
|
+
generatedMessage: true,
|
|
535
|
+
}));
|
|
536
|
+
}
|
|
537
|
+
function rejects_onRejected(e) {
|
|
538
|
+
if (validateThrownError(e, error, message, {
|
|
539
|
+
operator: rejects,
|
|
540
|
+
validationFunctionName: "validate",
|
|
541
|
+
})) {
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
return promise.then(onFulfilled, rejects_onRejected);
|
|
546
|
+
}
|
|
547
|
+
export function doesNotReject(asyncFn, error, message) {
|
|
548
|
+
let promise;
|
|
549
|
+
if (typeof asyncFn === "function") {
|
|
550
|
+
try {
|
|
551
|
+
const value = asyncFn();
|
|
552
|
+
if (!isValidThenable(value)) {
|
|
553
|
+
return Promise.reject(new ERR_INVALID_RETURN_VALUE("instance of Promise", "promiseFn", value));
|
|
554
|
+
}
|
|
555
|
+
promise = value;
|
|
556
|
+
}
|
|
557
|
+
catch (e) {
|
|
558
|
+
return Promise.reject(e);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
else if (!isValidThenable(asyncFn)) {
|
|
562
|
+
return Promise.reject(new ERR_INVALID_ARG_TYPE("promiseFn", ["function", "Promise"], asyncFn));
|
|
563
|
+
}
|
|
564
|
+
else {
|
|
565
|
+
promise = asyncFn;
|
|
566
|
+
}
|
|
567
|
+
return promise.then(() => { }, (e) => gotUnwantedException(e, error, message, doesNotReject));
|
|
568
|
+
}
|
|
569
|
+
function gotUnwantedException(e, expected, message, operator) {
|
|
570
|
+
if (typeof expected === "string") {
|
|
571
|
+
// The use case of doesNotThrow(fn, message);
|
|
572
|
+
throw new AssertionError({
|
|
573
|
+
message: `Got unwanted exception: ${expected}\nActual message: "${e.message}"`,
|
|
574
|
+
operator: operator.name,
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
else if (typeof expected === "function" &&
|
|
578
|
+
expected.prototype !== undefined) {
|
|
579
|
+
// The use case of doesNotThrow(fn, Error, message);
|
|
580
|
+
if (e instanceof expected) {
|
|
581
|
+
let msg = `Got unwanted exception: ${e.constructor?.name}`;
|
|
582
|
+
if (message) {
|
|
583
|
+
msg += ` ${String(message)}`;
|
|
584
|
+
}
|
|
585
|
+
throw new AssertionError({
|
|
586
|
+
message: msg,
|
|
587
|
+
operator: operator.name,
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
else if (expected.prototype instanceof Error) {
|
|
591
|
+
throw e;
|
|
592
|
+
}
|
|
593
|
+
else {
|
|
594
|
+
const result = expected(e);
|
|
595
|
+
if (result === true) {
|
|
596
|
+
let msg = `Got unwanted rejection.\nActual message: "${e.message}"`;
|
|
597
|
+
if (message) {
|
|
598
|
+
msg += ` ${String(message)}`;
|
|
599
|
+
}
|
|
600
|
+
throw new AssertionError({
|
|
601
|
+
message: msg,
|
|
602
|
+
operator: operator.name,
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
throw e;
|
|
607
|
+
}
|
|
608
|
+
else {
|
|
609
|
+
if (message) {
|
|
610
|
+
throw new AssertionError({
|
|
611
|
+
message: `Got unwanted exception: ${message}\nActual message: "${e ? e.message : String(e)}"`,
|
|
612
|
+
operator: operator.name,
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
throw new AssertionError({
|
|
616
|
+
message: `Got unwanted exception.\nActual message: "${e ? e.message : String(e)}"`,
|
|
617
|
+
operator: operator.name,
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
export function ifError(err) {
|
|
622
|
+
if (err !== null && err !== undefined) {
|
|
623
|
+
let message = "ifError got unwanted exception: ";
|
|
624
|
+
if (typeof err === "object" && typeof err.message === "string") {
|
|
625
|
+
if (err.message.length === 0 && err.constructor) {
|
|
626
|
+
message += err.constructor.name;
|
|
627
|
+
}
|
|
628
|
+
else {
|
|
629
|
+
message += err.message;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
else {
|
|
633
|
+
message += inspect(err);
|
|
634
|
+
}
|
|
635
|
+
const newErr = new AssertionError({
|
|
636
|
+
actual: err,
|
|
637
|
+
expected: null,
|
|
638
|
+
operator: "ifError",
|
|
639
|
+
message,
|
|
640
|
+
stackStartFn: ifError,
|
|
641
|
+
});
|
|
642
|
+
// Make sure we actually have a stack trace!
|
|
643
|
+
const origStack = err.stack;
|
|
644
|
+
if (typeof origStack === "string") {
|
|
645
|
+
const tmp2 = origStack.split("\n");
|
|
646
|
+
tmp2.shift();
|
|
647
|
+
let tmp1 = newErr.stack?.split("\n");
|
|
648
|
+
for (const errFrame of tmp2) {
|
|
649
|
+
const pos = tmp1?.indexOf(errFrame);
|
|
650
|
+
if (pos !== -1) {
|
|
651
|
+
tmp1 = tmp1?.slice(0, pos);
|
|
652
|
+
break;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
newErr.stack = `${tmp1?.join("\n")}\n${tmp2.join("\n")}`;
|
|
656
|
+
}
|
|
657
|
+
throw newErr;
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
function validateThrownError(e, error, message, options) {
|
|
661
|
+
if (typeof error === "string") {
|
|
662
|
+
if (message != null) {
|
|
663
|
+
throw new ERR_INVALID_ARG_TYPE("error", ["Object", "Error", "Function", "RegExp"], error);
|
|
664
|
+
}
|
|
665
|
+
else if (typeof e === "object" && e !== null) {
|
|
666
|
+
if (e.message === error) {
|
|
667
|
+
throw new ERR_AMBIGUOUS_ARGUMENT("error/message", `The error message "${e.message}" is identical to the message.`);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
else if (e === error) {
|
|
671
|
+
throw new ERR_AMBIGUOUS_ARGUMENT("error/message", `The error "${e}" is identical to the message.`);
|
|
672
|
+
}
|
|
673
|
+
message = error;
|
|
674
|
+
error = undefined;
|
|
675
|
+
}
|
|
676
|
+
if (error instanceof Function &&
|
|
677
|
+
error.prototype !== undefined &&
|
|
678
|
+
(error === Error || error.prototype instanceof Error)) {
|
|
679
|
+
// error is a constructor (Error itself or a subclass of Error)
|
|
680
|
+
if (e instanceof error) {
|
|
681
|
+
return true;
|
|
682
|
+
}
|
|
683
|
+
throw createAssertionError({
|
|
684
|
+
message: `The error is expected to be an instance of "${error.name}". Received "${e?.constructor?.name}"\n\nError message:\n\n${e?.message}`,
|
|
685
|
+
actual: e,
|
|
686
|
+
expected: error,
|
|
687
|
+
operator: options.operator.name,
|
|
688
|
+
generatedMessage: true,
|
|
689
|
+
});
|
|
690
|
+
}
|
|
691
|
+
if (error instanceof Function) {
|
|
692
|
+
const received = error(e);
|
|
693
|
+
if (received === true) {
|
|
694
|
+
return true;
|
|
695
|
+
}
|
|
696
|
+
throw createAssertionError({
|
|
697
|
+
message: `The ${options.validationFunctionName
|
|
698
|
+
? `"${options.validationFunctionName}" validation`
|
|
699
|
+
: "validation"} function is expected to return "true". Received ${inspect(received)}\n\nCaught error:\n\n${e}`,
|
|
700
|
+
actual: e,
|
|
701
|
+
expected: error,
|
|
702
|
+
operator: options.operator.name,
|
|
703
|
+
generatedMessage: true,
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
if (error instanceof RegExp) {
|
|
707
|
+
if (error.test(String(e))) {
|
|
708
|
+
return true;
|
|
709
|
+
}
|
|
710
|
+
throw createAssertionError({
|
|
711
|
+
message: `The input did not match the regular expression ${error.toString()}. Input:\n\n'${String(e)}'\n`,
|
|
712
|
+
actual: e,
|
|
713
|
+
expected: error,
|
|
714
|
+
operator: options.operator.name,
|
|
715
|
+
generatedMessage: true,
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
if (typeof error === "object" && error !== null) {
|
|
719
|
+
const keys = Object.keys(error);
|
|
720
|
+
if (error instanceof Error) {
|
|
721
|
+
keys.push("name", "message");
|
|
722
|
+
}
|
|
723
|
+
for (const k of keys) {
|
|
724
|
+
if (e == null) {
|
|
725
|
+
throw createAssertionError({
|
|
726
|
+
message: message || "object is expected to thrown, but got null",
|
|
727
|
+
actual: e,
|
|
728
|
+
expected: error,
|
|
729
|
+
operator: options.operator.name,
|
|
730
|
+
generatedMessage: message == null,
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
if (typeof e === "string") {
|
|
734
|
+
throw createAssertionError({
|
|
735
|
+
message: message || `object is expected to thrown, but got string: ${e}`,
|
|
736
|
+
actual: e,
|
|
737
|
+
expected: error,
|
|
738
|
+
operator: options.operator.name,
|
|
739
|
+
generatedMessage: message == null,
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
if (typeof e === "number") {
|
|
743
|
+
throw createAssertionError({
|
|
744
|
+
message: message || `object is expected to thrown, but got number: ${e}`,
|
|
745
|
+
actual: e,
|
|
746
|
+
expected: error,
|
|
747
|
+
operator: options.operator.name,
|
|
748
|
+
generatedMessage: message == null,
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
if (!(k in e)) {
|
|
752
|
+
throw createAssertionError({
|
|
753
|
+
message: message || `A key in the expected object is missing: ${k}`,
|
|
754
|
+
actual: e,
|
|
755
|
+
expected: error,
|
|
756
|
+
operator: options.operator.name,
|
|
757
|
+
generatedMessage: message == null,
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
const actual = e[k];
|
|
761
|
+
const expected = error[k];
|
|
762
|
+
if (typeof actual === "string" && expected instanceof RegExp) {
|
|
763
|
+
match(actual, expected);
|
|
764
|
+
}
|
|
765
|
+
else {
|
|
766
|
+
deepStrictEqual(actual, expected);
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
return true;
|
|
770
|
+
}
|
|
771
|
+
if (typeof error === "undefined") {
|
|
772
|
+
return true;
|
|
773
|
+
}
|
|
774
|
+
throw createAssertionError({
|
|
775
|
+
message: `Invalid expectation: ${error}`,
|
|
776
|
+
operator: options.operator.name,
|
|
777
|
+
generatedMessage: true,
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
function isValidThenable(maybeThennable) {
|
|
781
|
+
if (!maybeThennable) {
|
|
782
|
+
return false;
|
|
783
|
+
}
|
|
784
|
+
if (maybeThennable instanceof Promise) {
|
|
785
|
+
return true;
|
|
786
|
+
}
|
|
787
|
+
return typeof maybeThennable.then === "function";
|
|
788
|
+
}
|
|
789
|
+
export { AssertionError };
|
|
790
|
+
Object.assign(strict, {
|
|
791
|
+
AssertionError,
|
|
792
|
+
deepEqual: deepStrictEqual,
|
|
793
|
+
deepStrictEqual,
|
|
794
|
+
doesNotMatch,
|
|
795
|
+
doesNotReject,
|
|
796
|
+
doesNotThrow,
|
|
797
|
+
equal: strictEqual,
|
|
798
|
+
fail,
|
|
799
|
+
ifError,
|
|
800
|
+
match,
|
|
801
|
+
notDeepEqual: notDeepStrictEqual,
|
|
802
|
+
notDeepStrictEqual,
|
|
803
|
+
notEqual: notStrictEqual,
|
|
804
|
+
notStrictEqual,
|
|
805
|
+
ok,
|
|
806
|
+
partialDeepStrictEqual,
|
|
807
|
+
rejects,
|
|
808
|
+
strict,
|
|
809
|
+
strictEqual,
|
|
810
|
+
throws,
|
|
811
|
+
});
|
|
812
|
+
export default Object.assign(assert, {
|
|
813
|
+
AssertionError,
|
|
814
|
+
deepEqual,
|
|
815
|
+
deepStrictEqual,
|
|
816
|
+
doesNotMatch,
|
|
817
|
+
doesNotReject,
|
|
818
|
+
doesNotThrow,
|
|
819
|
+
equal,
|
|
820
|
+
fail,
|
|
821
|
+
ifError,
|
|
822
|
+
match,
|
|
823
|
+
notDeepEqual,
|
|
824
|
+
notDeepStrictEqual,
|
|
825
|
+
notEqual,
|
|
826
|
+
notStrictEqual,
|
|
827
|
+
ok,
|
|
828
|
+
partialDeepStrictEqual,
|
|
829
|
+
rejects,
|
|
830
|
+
strict,
|
|
831
|
+
strictEqual,
|
|
832
|
+
throws,
|
|
833
|
+
});
|
|
834
|
+
// These names are part of Workers' assertion error metadata. Bundlers may
|
|
835
|
+
// otherwise shorten functions used as the operator by throws/doesNotThrow.
|
|
836
|
+
for (const [name, fn] of Object.entries({
|
|
837
|
+
assert,
|
|
838
|
+
AssertionError,
|
|
839
|
+
deepEqual,
|
|
840
|
+
deepStrictEqual,
|
|
841
|
+
doesNotMatch,
|
|
842
|
+
doesNotReject,
|
|
843
|
+
doesNotThrow,
|
|
844
|
+
equal,
|
|
845
|
+
fail,
|
|
846
|
+
ifError,
|
|
847
|
+
match,
|
|
848
|
+
notDeepEqual,
|
|
849
|
+
notDeepStrictEqual,
|
|
850
|
+
notEqual,
|
|
851
|
+
notStrictEqual,
|
|
852
|
+
partialDeepStrictEqual,
|
|
853
|
+
rejects,
|
|
854
|
+
strict,
|
|
855
|
+
strictEqual,
|
|
856
|
+
throws,
|
|
857
|
+
}))
|
|
858
|
+
Object.defineProperty(fn, "name", { value: name, configurable: true });
|