(node: AnyNode): node is AddressedNode<unknown>Runtime predicate: node declares a ProtocolKind and the matching address
(path for IpcSocket, url otherwise) so connect can derive a transport.
Source src/internal/nodeCore.ts:4879 lines
export const const isAddressedNode: (
node: AnyNode
) => node is AddressedNode<unknown>
Runtime predicate: node declares a
ProtocolKind
and the matching address
(path for IpcSocket, url otherwise) so
connect
can derive a transport.
isAddressedNode = (
node: AnyNodenode: type AnyNode = NodeKey<unknown> & {
readonly url: string | undefined
readonly path: string | undefined
readonly kind: ProtocolKind | undefined
readonly endpoints?: Endpoints
readonly onConflict?: OnConflict
readonly [portSym]?: number
}
A
Tag
erased — its transport endpoints set, plus the primary address
(url and/or Unix path) and
ProtocolKind
kind (the first-declared endpoint, kept for
single-protocol readers), so a tag's distributed set is self-describing about where AND how to
reach each one.
AnyNode,
): node: AnyNodenode is type AddressedNode<HSelf> =
NodeKey<HSelf> &
(
| {
readonly kind: "IpcSocket"
readonly path: string
readonly url: string | undefined
}
| {
readonly kind: "Http"
readonly url: string
readonly path: string | undefined
}
| {
readonly kind: "WebSocket"
readonly url: string
readonly path: string | undefined
}
| {
readonly kind: "Http" | "WebSocket"
readonly url: string
readonly path: string | undefined
}
)
An
AnyNode
that can derive
connect
with no protocol argument —
kind set, and either a url (Http/WebSocket) or a Unix path (IpcSocket).
AddressedNode<unknown> => {
if (node: AnyNodenode.kind: ProtocolKind | undefinedkind === "IpcSocket") return typeof node: AnyNodenode.path: string | undefinedpath === "string";
if (node: AnyNodenode.kind: ProtocolKind | undefinedkind === "Http" || node: AnyNodenode.kind: ProtocolKind | undefinedkind === "WebSocket") {
return typeof node: AnyNodenode.url: string | undefinedurl === "string";
}
return false;
};
Referenced by 1 symbols