@netlify/plugin-nextjs 4.40.0 → 4.40.2
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/lib/helpers/edge.js +4 -2
- package/lib/templates/getHandler.js +1 -2
- package/lib/templates/handlerUtils.js +14 -1
- package/lib/templates/server.js +9 -8
- package/lib/templates/vendor.js +20 -0
- package/package.json +7 -4
- package/src/templates/edge/next-dev.js +3 -3
- package/src/templates/edge/shims.js +6 -6
- package/src/templates/edge-shared/next-utils.ts +3 -3
- package/src/templates/edge-shared/utils.ts +1 -1
- package/src/templates/vendor/deno.land/std@0.134.0/fmt/colors.ts +536 -0
- package/src/templates/vendor/deno.land/std@0.134.0/testing/_diff.ts +360 -0
- package/src/templates/vendor/deno.land/std@0.134.0/testing/asserts.ts +866 -0
- package/src/templates/vendor/deno.land/std@0.175.0/_util/asserts.ts +25 -0
- package/src/templates/vendor/deno.land/std@0.175.0/_util/os.ts +23 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/abortable.ts +149 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/deadline.ts +30 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/debounce.ts +79 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/deferred.ts +48 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/delay.ts +67 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/mod.ts +18 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/mux_async_iterator.ts +97 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/pool.ts +95 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/retry.ts +81 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/tee.ts +100 -0
- package/src/templates/vendor/deno.land/std@0.175.0/bytes/index_of_needle.ts +49 -0
- package/src/templates/vendor/deno.land/std@0.175.0/crypto/timing_safe_equal.ts +29 -0
- package/src/templates/vendor/deno.land/std@0.175.0/datetime/to_imf.ts +45 -0
- package/src/templates/vendor/deno.land/std@0.175.0/encoding/base64.ts +144 -0
- package/src/templates/vendor/deno.land/std@0.175.0/encoding/base64url.ts +70 -0
- package/src/templates/vendor/deno.land/std@0.175.0/flags/mod.ts +785 -0
- package/src/templates/vendor/deno.land/std@0.175.0/fmt/colors.ts +569 -0
- package/src/templates/vendor/deno.land/std@0.175.0/fmt/printf.ts +939 -0
- package/src/templates/vendor/deno.land/std@0.175.0/http/cookie.ts +403 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_core.ts +77 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_events.d.ts +848 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_events.mjs +1033 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_global.d.ts +66 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_next_tick.ts +173 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_process/exiting.ts +4 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_process/process.ts +131 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_process/stdio.mjs +7 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_process/streams.mjs +146 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_stream.d.ts +1488 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_stream.mjs +746 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_util/_util_callbackify.ts +129 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_utils.ts +206 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/assert.ts +940 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/assertion_error.ts +579 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/async_hooks.ts +331 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/buffer.ts +13 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/events.ts +14 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/buffer.d.ts +2074 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/buffer.mjs +2607 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/crypto/_keys.ts +16 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/crypto/constants.ts +5 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/error_codes.ts +7 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/errors.ts +2867 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/fixed_queue.ts +123 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/hide_stack_frames.ts +16 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/net.ts +95 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/normalize_encoding.mjs +72 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/options.ts +45 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/primordials.mjs +30 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/process/per_thread.mjs +272 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/readline/callbacks.mjs +137 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/readline/utils.mjs +580 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/streams/destroy.mjs +320 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/streams/end-of-stream.mjs +229 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/streams/utils.mjs +242 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/util/comparisons.ts +669 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/util/debuglog.ts +118 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/util/inspect.mjs +2237 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/util/types.ts +113 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/util.mjs +143 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/validators.mjs +317 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_libuv_winerror.ts +229 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_listen.ts +16 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_node.ts +18 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_timingSafeEqual.ts +12 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_utils.ts +86 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_winerror.ts +16873 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/ares.ts +66 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/async_wrap.ts +152 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/buffer.ts +130 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/cares_wrap.ts +541 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/config.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/connection_wrap.ts +80 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/constants.ts +900 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/contextify.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/credentials.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/crypto.ts +14 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/errors.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/fs.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/fs_dir.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/fs_event_wrap.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/handle_wrap.ts +50 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/heap_utils.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/http_parser.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/icu.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/inspector.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/js_stream.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/messaging.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/mod.ts +108 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/module_wrap.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/native_module.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/natives.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/node_file.ts +84 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/node_options.ts +39 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/options.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/os.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/performance.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/pipe_wrap.ts +392 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/process_methods.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/report.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/serdes.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/signal_wrap.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/spawn_sync.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/stream_wrap.ts +354 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/string_decoder.ts +15 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/symbols.ts +27 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/task_queue.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/tcp_wrap.ts +488 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/timers.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/tls_wrap.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/trace_events.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/tty_wrap.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/types.ts +186 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/udp_wrap.ts +496 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/url.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/util.ts +126 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/uv.ts +437 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/v8.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/worker.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/zlib.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/process.ts +705 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/stream.ts +37 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/string_decoder.ts +337 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/util/types.ts +4 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/util.ts +289 -0
- package/src/templates/vendor/deno.land/std@0.175.0/path/_constants.ts +49 -0
- package/src/templates/vendor/deno.land/std@0.175.0/path/_interface.ts +30 -0
- package/src/templates/vendor/deno.land/std@0.175.0/path/_util.ts +194 -0
- package/src/templates/vendor/deno.land/std@0.175.0/path/common.ts +40 -0
- package/src/templates/vendor/deno.land/std@0.175.0/path/glob.ts +418 -0
- package/src/templates/vendor/deno.land/std@0.175.0/path/mod.ts +53 -0
- package/src/templates/vendor/deno.land/std@0.175.0/path/posix.ts +487 -0
- package/src/templates/vendor/deno.land/std@0.175.0/path/separator.ts +7 -0
- package/src/templates/vendor/deno.land/std@0.175.0/path/win32.ts +962 -0
- package/src/templates/vendor/deno.land/std@0.175.0/streams/write_all.ts +64 -0
- package/src/templates/vendor/deno.land/std@0.175.0/testing/_diff.ts +440 -0
- package/src/templates/vendor/deno.land/std@0.175.0/testing/_format.ts +23 -0
- package/src/templates/vendor/deno.land/std@0.175.0/testing/asserts.ts +906 -0
- package/src/templates/vendor/deno.land/std@0.175.0/types.d.ts +89 -0
- package/src/templates/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/index.ts +133 -0
- package/src/templates/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/vendor/asyncify.js +112 -0
- package/src/templates/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/vendor/html_rewriter.d.ts +88 -0
- package/src/templates/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/vendor/html_rewriter.js +974 -0
- package/src/templates/vendor/deno.land/x/path_to_regexp@v6.2.1/index.ts +621 -0
- package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/compiled/cookie.js +13 -0
- package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/request.js +12 -0
- package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/response.js +5 -0
- package/src/templates/vendor/import_map.json +13 -0
- package/src/templates/vendor/raw.githubusercontent.com/worker-tools/resolvable-promise/master/index.ts +50 -0
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
2
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
|
3
|
+
//
|
|
4
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
5
|
+
// copy of this software and associated documentation files (the
|
|
6
|
+
// "Software"), to deal in the Software without restriction, including
|
|
7
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
8
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
9
|
+
// persons to whom the Software is furnished to do so, subject to the
|
|
10
|
+
// following conditions:
|
|
11
|
+
//
|
|
12
|
+
// The above copyright notice and this permission notice shall be included
|
|
13
|
+
// in all copies or substantial portions of the Software.
|
|
14
|
+
//
|
|
15
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
16
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
17
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
18
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
19
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
20
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
21
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
|
|
23
|
+
// This module ports:
|
|
24
|
+
// - https://github.com/nodejs/node/blob/master/src/tcp_wrap.cc
|
|
25
|
+
// - https://github.com/nodejs/node/blob/master/src/tcp_wrap.h
|
|
26
|
+
|
|
27
|
+
import { notImplemented } from "../_utils.ts";
|
|
28
|
+
import { unreachable } from "../../_util/asserts.ts";
|
|
29
|
+
import { ConnectionWrap } from "./connection_wrap.ts";
|
|
30
|
+
import { AsyncWrap, providerType } from "./async_wrap.ts";
|
|
31
|
+
import { LibuvStreamWrap } from "./stream_wrap.ts";
|
|
32
|
+
import { ownerSymbol } from "./symbols.ts";
|
|
33
|
+
import { codeMap } from "./uv.ts";
|
|
34
|
+
import { delay } from "../../async/mod.ts";
|
|
35
|
+
import { kStreamBaseField } from "./stream_wrap.ts";
|
|
36
|
+
import { isIP } from "../internal/net.ts";
|
|
37
|
+
import {
|
|
38
|
+
ceilPowOf2,
|
|
39
|
+
INITIAL_ACCEPT_BACKOFF_DELAY,
|
|
40
|
+
MAX_ACCEPT_BACKOFF_DELAY,
|
|
41
|
+
} from "./_listen.ts";
|
|
42
|
+
|
|
43
|
+
/** The type of TCP socket. */
|
|
44
|
+
enum socketType {
|
|
45
|
+
SOCKET,
|
|
46
|
+
SERVER,
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface AddressInfo {
|
|
50
|
+
address: string;
|
|
51
|
+
family?: number;
|
|
52
|
+
port: number;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export class TCPConnectWrap extends AsyncWrap {
|
|
56
|
+
oncomplete!: (
|
|
57
|
+
status: number,
|
|
58
|
+
handle: ConnectionWrap,
|
|
59
|
+
req: TCPConnectWrap,
|
|
60
|
+
readable: boolean,
|
|
61
|
+
writeable: boolean,
|
|
62
|
+
) => void;
|
|
63
|
+
address!: string;
|
|
64
|
+
port!: number;
|
|
65
|
+
localAddress!: string;
|
|
66
|
+
localPort!: number;
|
|
67
|
+
|
|
68
|
+
constructor() {
|
|
69
|
+
super(providerType.TCPCONNECTWRAP);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export enum constants {
|
|
74
|
+
SOCKET = socketType.SOCKET,
|
|
75
|
+
SERVER = socketType.SERVER,
|
|
76
|
+
UV_TCP_IPV6ONLY,
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export class TCP extends ConnectionWrap {
|
|
80
|
+
[ownerSymbol]: unknown = null;
|
|
81
|
+
override reading = false;
|
|
82
|
+
|
|
83
|
+
#address?: string;
|
|
84
|
+
#port?: number;
|
|
85
|
+
|
|
86
|
+
#remoteAddress?: string;
|
|
87
|
+
#remoteFamily?: number;
|
|
88
|
+
#remotePort?: number;
|
|
89
|
+
|
|
90
|
+
#backlog?: number;
|
|
91
|
+
#listener!: Deno.Listener;
|
|
92
|
+
#connections = 0;
|
|
93
|
+
|
|
94
|
+
#closed = false;
|
|
95
|
+
#acceptBackoffDelay?: number;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Creates a new TCP class instance.
|
|
99
|
+
* @param type The socket type.
|
|
100
|
+
* @param conn Optional connection object to wrap.
|
|
101
|
+
*/
|
|
102
|
+
constructor(type: number, conn?: Deno.Conn) {
|
|
103
|
+
let provider: providerType;
|
|
104
|
+
|
|
105
|
+
switch (type) {
|
|
106
|
+
case socketType.SOCKET: {
|
|
107
|
+
provider = providerType.TCPWRAP;
|
|
108
|
+
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
case socketType.SERVER: {
|
|
112
|
+
provider = providerType.TCPSERVERWRAP;
|
|
113
|
+
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
default: {
|
|
117
|
+
unreachable();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
super(provider, conn);
|
|
122
|
+
|
|
123
|
+
// TODO(cmorten): the handling of new connections and construction feels
|
|
124
|
+
// a little off. Suspect duplicating in some fashion.
|
|
125
|
+
if (conn && provider === providerType.TCPWRAP) {
|
|
126
|
+
const localAddr = conn.localAddr as Deno.NetAddr;
|
|
127
|
+
this.#address = localAddr.hostname;
|
|
128
|
+
this.#port = localAddr.port;
|
|
129
|
+
|
|
130
|
+
const remoteAddr = conn.remoteAddr as Deno.NetAddr;
|
|
131
|
+
this.#remoteAddress = remoteAddr.hostname;
|
|
132
|
+
this.#remotePort = remoteAddr.port;
|
|
133
|
+
this.#remoteFamily = isIP(remoteAddr.hostname);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Opens a file descriptor.
|
|
139
|
+
* @param fd The file descriptor to open.
|
|
140
|
+
* @return An error status code.
|
|
141
|
+
*/
|
|
142
|
+
open(_fd: number): number {
|
|
143
|
+
// REF: https://github.com/denoland/deno/issues/6529
|
|
144
|
+
notImplemented("TCP.prototype.open");
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Bind to an IPv4 address.
|
|
149
|
+
* @param address The hostname to bind to.
|
|
150
|
+
* @param port The port to bind to
|
|
151
|
+
* @return An error status code.
|
|
152
|
+
*/
|
|
153
|
+
bind(address: string, port: number): number {
|
|
154
|
+
return this.#bind(address, port, 0);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Bind to an IPv6 address.
|
|
159
|
+
* @param address The hostname to bind to.
|
|
160
|
+
* @param port The port to bind to
|
|
161
|
+
* @return An error status code.
|
|
162
|
+
*/
|
|
163
|
+
bind6(address: string, port: number, flags: number): number {
|
|
164
|
+
return this.#bind(address, port, flags);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Connect to an IPv4 address.
|
|
169
|
+
* @param req A TCPConnectWrap instance.
|
|
170
|
+
* @param address The hostname to connect to.
|
|
171
|
+
* @param port The port to connect to.
|
|
172
|
+
* @return An error status code.
|
|
173
|
+
*/
|
|
174
|
+
connect(req: TCPConnectWrap, address: string, port: number): number {
|
|
175
|
+
return this.#connect(req, address, port);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Connect to an IPv6 address.
|
|
180
|
+
* @param req A TCPConnectWrap instance.
|
|
181
|
+
* @param address The hostname to connect to.
|
|
182
|
+
* @param port The port to connect to.
|
|
183
|
+
* @return An error status code.
|
|
184
|
+
*/
|
|
185
|
+
connect6(req: TCPConnectWrap, address: string, port: number): number {
|
|
186
|
+
return this.#connect(req, address, port);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Listen for new connections.
|
|
191
|
+
* @param backlog The maximum length of the queue of pending connections.
|
|
192
|
+
* @return An error status code.
|
|
193
|
+
*/
|
|
194
|
+
listen(backlog: number): number {
|
|
195
|
+
this.#backlog = ceilPowOf2(backlog + 1);
|
|
196
|
+
|
|
197
|
+
const listenOptions = {
|
|
198
|
+
hostname: this.#address!,
|
|
199
|
+
port: this.#port!,
|
|
200
|
+
transport: "tcp" as const,
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
let listener;
|
|
204
|
+
|
|
205
|
+
try {
|
|
206
|
+
listener = Deno.listen(listenOptions);
|
|
207
|
+
} catch (e) {
|
|
208
|
+
if (e instanceof Deno.errors.AddrInUse) {
|
|
209
|
+
return codeMap.get("EADDRINUSE")!;
|
|
210
|
+
} else if (e instanceof Deno.errors.AddrNotAvailable) {
|
|
211
|
+
return codeMap.get("EADDRNOTAVAIL")!;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// TODO(cmorten): map errors to appropriate error codes.
|
|
215
|
+
return codeMap.get("UNKNOWN")!;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const address = listener.addr as Deno.NetAddr;
|
|
219
|
+
this.#address = address.hostname;
|
|
220
|
+
this.#port = address.port;
|
|
221
|
+
|
|
222
|
+
this.#listener = listener;
|
|
223
|
+
this.#accept();
|
|
224
|
+
|
|
225
|
+
return 0;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
override ref() {
|
|
229
|
+
if (this.#listener) {
|
|
230
|
+
this.#listener.ref();
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (this[kStreamBaseField]) {
|
|
234
|
+
this[kStreamBaseField].ref();
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
override unref() {
|
|
239
|
+
if (this.#listener) {
|
|
240
|
+
this.#listener.unref();
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (this[kStreamBaseField]) {
|
|
244
|
+
this[kStreamBaseField].unref();
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Populates the provided object with local address entries.
|
|
250
|
+
* @param sockname An object to add the local address entries to.
|
|
251
|
+
* @return An error status code.
|
|
252
|
+
*/
|
|
253
|
+
getsockname(sockname: Record<string, never> | AddressInfo): number {
|
|
254
|
+
if (
|
|
255
|
+
typeof this.#address === "undefined" ||
|
|
256
|
+
typeof this.#port === "undefined"
|
|
257
|
+
) {
|
|
258
|
+
return codeMap.get("EADDRNOTAVAIL")!;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
sockname.address = this.#address;
|
|
262
|
+
sockname.port = this.#port;
|
|
263
|
+
sockname.family = isIP(this.#address);
|
|
264
|
+
|
|
265
|
+
return 0;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Populates the provided object with remote address entries.
|
|
270
|
+
* @param peername An object to add the remote address entries to.
|
|
271
|
+
* @return An error status code.
|
|
272
|
+
*/
|
|
273
|
+
getpeername(peername: Record<string, never> | AddressInfo): number {
|
|
274
|
+
if (
|
|
275
|
+
typeof this.#remoteAddress === "undefined" ||
|
|
276
|
+
typeof this.#remotePort === "undefined"
|
|
277
|
+
) {
|
|
278
|
+
return codeMap.get("EADDRNOTAVAIL")!;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
peername.address = this.#remoteAddress;
|
|
282
|
+
peername.port = this.#remotePort;
|
|
283
|
+
peername.family = this.#remoteFamily;
|
|
284
|
+
|
|
285
|
+
return 0;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* @param noDelay
|
|
290
|
+
* @return An error status code.
|
|
291
|
+
*/
|
|
292
|
+
setNoDelay(_noDelay: boolean): number {
|
|
293
|
+
// TODO(bnoordhuis) https://github.com/denoland/deno/pull/13103
|
|
294
|
+
return 0;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* @param enable
|
|
299
|
+
* @param initialDelay
|
|
300
|
+
* @return An error status code.
|
|
301
|
+
*/
|
|
302
|
+
setKeepAlive(_enable: boolean, _initialDelay: number): number {
|
|
303
|
+
// TODO(bnoordhuis) https://github.com/denoland/deno/pull/13103
|
|
304
|
+
return 0;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Windows only.
|
|
309
|
+
*
|
|
310
|
+
* Deprecated by Node.
|
|
311
|
+
* REF: https://github.com/nodejs/node/blob/master/lib/net.js#L1731
|
|
312
|
+
*
|
|
313
|
+
* @param enable
|
|
314
|
+
* @return An error status code.
|
|
315
|
+
* @deprecated
|
|
316
|
+
*/
|
|
317
|
+
setSimultaneousAccepts(_enable: boolean) {
|
|
318
|
+
// Low priority to implement owing to it being deprecated in Node.
|
|
319
|
+
notImplemented("TCP.prototype.setSimultaneousAccepts");
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Bind to an IPv4 or IPv6 address.
|
|
324
|
+
* @param address The hostname to bind to.
|
|
325
|
+
* @param port The port to bind to
|
|
326
|
+
* @param _flags
|
|
327
|
+
* @return An error status code.
|
|
328
|
+
*/
|
|
329
|
+
#bind(address: string, port: number, _flags: number): number {
|
|
330
|
+
// Deno doesn't currently separate bind from connect etc.
|
|
331
|
+
// REF:
|
|
332
|
+
// - https://doc.deno.land/deno/stable/~/Deno.connect
|
|
333
|
+
// - https://doc.deno.land/deno/stable/~/Deno.listen
|
|
334
|
+
//
|
|
335
|
+
// This also means we won't be connecting from the specified local address
|
|
336
|
+
// and port as providing these is not an option in Deno.
|
|
337
|
+
// REF:
|
|
338
|
+
// - https://doc.deno.land/deno/stable/~/Deno.ConnectOptions
|
|
339
|
+
// - https://doc.deno.land/deno/stable/~/Deno.ListenOptions
|
|
340
|
+
|
|
341
|
+
this.#address = address;
|
|
342
|
+
this.#port = port;
|
|
343
|
+
|
|
344
|
+
return 0;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Connect to an IPv4 or IPv6 address.
|
|
349
|
+
* @param req A TCPConnectWrap instance.
|
|
350
|
+
* @param address The hostname to connect to.
|
|
351
|
+
* @param port The port to connect to.
|
|
352
|
+
* @return An error status code.
|
|
353
|
+
*/
|
|
354
|
+
#connect(req: TCPConnectWrap, address: string, port: number): number {
|
|
355
|
+
this.#remoteAddress = address;
|
|
356
|
+
this.#remotePort = port;
|
|
357
|
+
this.#remoteFamily = isIP(address);
|
|
358
|
+
|
|
359
|
+
const connectOptions: Deno.ConnectOptions = {
|
|
360
|
+
hostname: address,
|
|
361
|
+
port,
|
|
362
|
+
transport: "tcp",
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
Deno.connect(connectOptions).then(
|
|
366
|
+
(conn: Deno.Conn) => {
|
|
367
|
+
// Incorrect / backwards, but correcting the local address and port with
|
|
368
|
+
// what was actually used given we can't actually specify these in Deno.
|
|
369
|
+
const localAddr = conn.localAddr as Deno.NetAddr;
|
|
370
|
+
this.#address = req.localAddress = localAddr.hostname;
|
|
371
|
+
this.#port = req.localPort = localAddr.port;
|
|
372
|
+
this[kStreamBaseField] = conn;
|
|
373
|
+
|
|
374
|
+
try {
|
|
375
|
+
this.afterConnect(req, 0);
|
|
376
|
+
} catch {
|
|
377
|
+
// swallow callback errors.
|
|
378
|
+
}
|
|
379
|
+
},
|
|
380
|
+
() => {
|
|
381
|
+
try {
|
|
382
|
+
// TODO(cmorten): correct mapping of connection error to status code.
|
|
383
|
+
this.afterConnect(req, codeMap.get("ECONNREFUSED")!);
|
|
384
|
+
} catch {
|
|
385
|
+
// swallow callback errors.
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
);
|
|
389
|
+
|
|
390
|
+
return 0;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/** Handle backoff delays following an unsuccessful accept. */
|
|
394
|
+
async #acceptBackoff() {
|
|
395
|
+
// Backoff after transient errors to allow time for the system to
|
|
396
|
+
// recover, and avoid blocking up the event loop with a continuously
|
|
397
|
+
// running loop.
|
|
398
|
+
if (!this.#acceptBackoffDelay) {
|
|
399
|
+
this.#acceptBackoffDelay = INITIAL_ACCEPT_BACKOFF_DELAY;
|
|
400
|
+
} else {
|
|
401
|
+
this.#acceptBackoffDelay *= 2;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
if (this.#acceptBackoffDelay >= MAX_ACCEPT_BACKOFF_DELAY) {
|
|
405
|
+
this.#acceptBackoffDelay = MAX_ACCEPT_BACKOFF_DELAY;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
await delay(this.#acceptBackoffDelay);
|
|
409
|
+
|
|
410
|
+
this.#accept();
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/** Accept new connections. */
|
|
414
|
+
async #accept(): Promise<void> {
|
|
415
|
+
if (this.#closed) {
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
if (this.#connections > this.#backlog!) {
|
|
420
|
+
this.#acceptBackoff();
|
|
421
|
+
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
let connection: Deno.Conn;
|
|
426
|
+
|
|
427
|
+
try {
|
|
428
|
+
connection = await this.#listener.accept();
|
|
429
|
+
} catch (e) {
|
|
430
|
+
if (e instanceof Deno.errors.BadResource && this.#closed) {
|
|
431
|
+
// Listener and server has closed.
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
try {
|
|
436
|
+
// TODO(cmorten): map errors to appropriate error codes.
|
|
437
|
+
this.onconnection!(codeMap.get("UNKNOWN")!, undefined);
|
|
438
|
+
} catch {
|
|
439
|
+
// swallow callback errors.
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
this.#acceptBackoff();
|
|
443
|
+
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// Reset the backoff delay upon successful accept.
|
|
448
|
+
this.#acceptBackoffDelay = undefined;
|
|
449
|
+
|
|
450
|
+
const connectionHandle = new TCP(socketType.SOCKET, connection);
|
|
451
|
+
this.#connections++;
|
|
452
|
+
|
|
453
|
+
try {
|
|
454
|
+
this.onconnection!(0, connectionHandle);
|
|
455
|
+
} catch {
|
|
456
|
+
// swallow callback errors.
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
return this.#accept();
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/** Handle server closure. */
|
|
463
|
+
override _onClose(): number {
|
|
464
|
+
this.#closed = true;
|
|
465
|
+
this.reading = false;
|
|
466
|
+
|
|
467
|
+
this.#address = undefined;
|
|
468
|
+
this.#port = undefined;
|
|
469
|
+
|
|
470
|
+
this.#remoteAddress = undefined;
|
|
471
|
+
this.#remoteFamily = undefined;
|
|
472
|
+
this.#remotePort = undefined;
|
|
473
|
+
|
|
474
|
+
this.#backlog = undefined;
|
|
475
|
+
this.#connections = 0;
|
|
476
|
+
this.#acceptBackoffDelay = undefined;
|
|
477
|
+
|
|
478
|
+
if (this.provider === providerType.TCPSERVERWRAP) {
|
|
479
|
+
try {
|
|
480
|
+
this.#listener.close();
|
|
481
|
+
} catch {
|
|
482
|
+
// listener already closed
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
return LibuvStreamWrap.prototype._onClose.call(this);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
2
|
+
//
|
|
3
|
+
// Adapted from Node.js. Copyright Joyent, Inc. and other Node contributors.
|
|
4
|
+
//
|
|
5
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
6
|
+
// copy of this software and associated documentation files (the
|
|
7
|
+
// "Software"), to deal in the Software without restriction, including
|
|
8
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
10
|
+
// persons to whom the Software is furnished to do so, subject to the
|
|
11
|
+
// following conditions:
|
|
12
|
+
//
|
|
13
|
+
// The above copyright notice and this permission notice shall be included
|
|
14
|
+
// in all copies or substantial portions of the Software.
|
|
15
|
+
//
|
|
16
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
17
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
19
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
20
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
21
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
22
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
|
|
24
|
+
import { core } from "../_core.ts";
|
|
25
|
+
|
|
26
|
+
const _toString = Object.prototype.toString;
|
|
27
|
+
|
|
28
|
+
const _isObjectLike = (value: unknown): boolean =>
|
|
29
|
+
value !== null && typeof value === "object";
|
|
30
|
+
|
|
31
|
+
const _isFunctionLike = (value: unknown): boolean =>
|
|
32
|
+
value !== null && typeof value === "function";
|
|
33
|
+
|
|
34
|
+
export function isAnyArrayBuffer(value: unknown): boolean {
|
|
35
|
+
return (
|
|
36
|
+
_isObjectLike(value) &&
|
|
37
|
+
(_toString.call(value) === "[object ArrayBuffer]" ||
|
|
38
|
+
_toString.call(value) === "[object SharedArrayBuffer]")
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function isArgumentsObject(value: unknown): boolean {
|
|
43
|
+
return _isObjectLike(value) && _toString.call(value) === "[object Arguments]";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function isArrayBuffer(value: unknown): boolean {
|
|
47
|
+
return (
|
|
48
|
+
_isObjectLike(value) && _toString.call(value) === "[object ArrayBuffer]"
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function isAsyncFunction(value: unknown): boolean {
|
|
53
|
+
return (
|
|
54
|
+
_isFunctionLike(value) && _toString.call(value) === "[object AsyncFunction]"
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function isBooleanObject(value: unknown): boolean {
|
|
59
|
+
return _isObjectLike(value) && _toString.call(value) === "[object Boolean]";
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function isBoxedPrimitive(value: unknown): boolean {
|
|
63
|
+
return (
|
|
64
|
+
isBooleanObject(value) ||
|
|
65
|
+
isStringObject(value) ||
|
|
66
|
+
isNumberObject(value) ||
|
|
67
|
+
isSymbolObject(value) ||
|
|
68
|
+
isBigIntObject(value)
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function isDataView(value: unknown): boolean {
|
|
73
|
+
return _isObjectLike(value) && _toString.call(value) === "[object DataView]";
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function isDate(value: unknown): boolean {
|
|
77
|
+
return _isObjectLike(value) && _toString.call(value) === "[object Date]";
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function isGeneratorFunction(value: unknown): boolean {
|
|
81
|
+
return (
|
|
82
|
+
_isFunctionLike(value) &&
|
|
83
|
+
_toString.call(value) === "[object GeneratorFunction]"
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function isGeneratorObject(value: unknown): boolean {
|
|
88
|
+
return _isObjectLike(value) && _toString.call(value) === "[object Generator]";
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function isMap(value: unknown): boolean {
|
|
92
|
+
return _isObjectLike(value) && _toString.call(value) === "[object Map]";
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function isMapIterator(value: unknown): boolean {
|
|
96
|
+
return (
|
|
97
|
+
_isObjectLike(value) && _toString.call(value) === "[object Map Iterator]"
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function isModuleNamespaceObject(value: unknown): boolean {
|
|
102
|
+
return _isObjectLike(value) && _toString.call(value) === "[object Module]";
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function isNativeError(value: unknown): boolean {
|
|
106
|
+
return _isObjectLike(value) && _toString.call(value) === "[object Error]";
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function isNumberObject(value: unknown): boolean {
|
|
110
|
+
return _isObjectLike(value) && _toString.call(value) === "[object Number]";
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function isBigIntObject(value: unknown): boolean {
|
|
114
|
+
return _isObjectLike(value) && _toString.call(value) === "[object BigInt]";
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export function isPromise(value: unknown): boolean {
|
|
118
|
+
return _isObjectLike(value) && _toString.call(value) === "[object Promise]";
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function isProxy(value: unknown): boolean {
|
|
122
|
+
return core.isProxy(value);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function isRegExp(value: unknown): boolean {
|
|
126
|
+
return _isObjectLike(value) && _toString.call(value) === "[object RegExp]";
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function isSet(value: unknown): boolean {
|
|
130
|
+
return _isObjectLike(value) && _toString.call(value) === "[object Set]";
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function isSetIterator(value: unknown): boolean {
|
|
134
|
+
return (
|
|
135
|
+
_isObjectLike(value) && _toString.call(value) === "[object Set Iterator]"
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function isSharedArrayBuffer(value: unknown): boolean {
|
|
140
|
+
return (
|
|
141
|
+
_isObjectLike(value) &&
|
|
142
|
+
_toString.call(value) === "[object SharedArrayBuffer]"
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function isStringObject(value: unknown): boolean {
|
|
147
|
+
return _isObjectLike(value) && _toString.call(value) === "[object String]";
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export function isSymbolObject(value: unknown): boolean {
|
|
151
|
+
return _isObjectLike(value) && _toString.call(value) === "[object Symbol]";
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export function isWeakMap(value: unknown): boolean {
|
|
155
|
+
return _isObjectLike(value) && _toString.call(value) === "[object WeakMap]";
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export function isWeakSet(value: unknown): boolean {
|
|
159
|
+
return _isObjectLike(value) && _toString.call(value) === "[object WeakSet]";
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export default {
|
|
163
|
+
isAsyncFunction,
|
|
164
|
+
isGeneratorFunction,
|
|
165
|
+
isAnyArrayBuffer,
|
|
166
|
+
isArrayBuffer,
|
|
167
|
+
isArgumentsObject,
|
|
168
|
+
isBoxedPrimitive,
|
|
169
|
+
isDataView,
|
|
170
|
+
// isExternal,
|
|
171
|
+
isMap,
|
|
172
|
+
isMapIterator,
|
|
173
|
+
isModuleNamespaceObject,
|
|
174
|
+
isNativeError,
|
|
175
|
+
isPromise,
|
|
176
|
+
isSet,
|
|
177
|
+
isSetIterator,
|
|
178
|
+
isWeakMap,
|
|
179
|
+
isWeakSet,
|
|
180
|
+
isRegExp,
|
|
181
|
+
isDate,
|
|
182
|
+
isStringObject,
|
|
183
|
+
isNumberObject,
|
|
184
|
+
isBooleanObject,
|
|
185
|
+
isBigIntObject,
|
|
186
|
+
};
|