Hyperlinkv0.8.0-beta.28

Hyperlink

Hyperlink.nodesconstsrc/Hyperlink.ts:4753
<HSelf>(nodeSet: readonly [AddressedNode<HSelf>]): <
  T extends PipeableTag
>(
  tag: T
) => SoleNodeBind<T, AddressedNode<HSelf>>
<HSelf>(nodeSet: readonly [NodeKey<HSelf>]): <T extends PipeableTag>(
  tag: T
) => SoleNodeBind<T, NodeKey<HSelf>>
<T extends PipeableTag>(nodeSet: ReadonlyArray<AnyNode>): (tag: T) => T
<Self, S extends Spec, HSelf>(
  tag: HyperlinkTag<Self, S> | NodeBoundTag<Self, S, HSelf>,
  nodeSet: readonly [AddressedNode<HSelf>]
): SoleNodeBind<NodeBoundTag<Self, S, HSelf>, AddressedNode<HSelf>>
<Self, S extends Spec, HSelf>(
  tag: HyperlinkTag<Self, S> | NodeBoundTag<Self, S, HSelf>,
  nodeSet: readonly [NodeKey<HSelf>]
): SoleNodeBind<NodeBoundTag<Self, S, HSelf>, NodeKey<HSelf>>
<Self, S extends Spec, HSelf>(
  tag: NodeBoundTag<Self, S, HSelf>,
  nodeSet: ReadonlyArray<AnyNode>
): NodeBoundTag<Self, S, HSelf>
<Self, S extends Spec>(
  tag: HyperlinkTag<Self, S>,
  nodeSet: ReadonlyArray<AnyNode>
): HyperlinkTag<Self, S>

Stamp a Tag's Node set (C1) — overwrites. Size 1 also syncs nodeSym so client(Tag) works; size ≠ 1 clears nodeSym (use client(Tag, node)). Identity Tags may only carry ≤ 1 Node (IdentityMultiNode). Empty nodes([]) is discoverable membership (same as bare distributed); peersLayer reads Lookup directory.

A size-1 tuple of an AddressedNode narrows like { node: X } on the Tag ctor — client(Tag) is fully wired. andNode(X) from an empty set is the same bind.

class Mail extends Hyperlink.Tag<Mail>()("app/Mail", spec).pipe(
  Hyperlink.nodes([WorkerA]), // or Hyperlink.andNode(WorkerA)
) {}
class Pool extends Hyperlink.Tag<Pool>()("app/Pool", spec).pipe(
  Hyperlink.nodes([A, B, C]),
) {}
Source src/Hyperlink.ts:475349 lines
export const nodes: {
  // data-last — addressed sole node (before bare NodeKey; AddressedNode ⊆ NodeKey)
  <HSelf>(
    nodeSet: readonly [AddressedNode<HSelf>],
  ): <T extends PipeableTag>(tag: T) => SoleNodeBind<T, AddressedNode<HSelf>>;
  <HSelf>(
    nodeSet: readonly [NodeKey<HSelf>],
  ): <T extends PipeableTag>(tag: T) => SoleNodeBind<T, NodeKey<HSelf>>;
  <T extends PipeableTag>(
    nodeSet: ReadonlyArray<AnyNode>,
  ): (tag: T) => T;
  // data-first
  <Self, S extends Spec, HSelf>(
    tag: HyperlinkTag<Self, S> | NodeBoundTag<Self, S, HSelf>,
    nodeSet: readonly [AddressedNode<HSelf>],
  ): SoleNodeBind<
    NodeBoundTag<Self, S, HSelf>,
    AddressedNode<HSelf>
  >;
  <Self, S extends Spec, HSelf>(
    tag: HyperlinkTag<Self, S> | NodeBoundTag<Self, S, HSelf>,
    nodeSet: readonly [NodeKey<HSelf>],
  ): SoleNodeBind<NodeBoundTag<Self, S, HSelf>, NodeKey<HSelf>>;
  <Self, S extends Spec, HSelf>(
    tag: NodeBoundTag<Self, S, HSelf>,
    nodeSet: ReadonlyArray<AnyNode>,
  ): NodeBoundTag<Self, S, HSelf>;
  <Self, S extends Spec>(
    tag: HyperlinkTag<Self, S>,
    nodeSet: ReadonlyArray<AnyNode>,
  ): HyperlinkTag<Self, S>;
} = Fn.dual(
  2,
  <T extends HyperlinkTag<any, any, any>>(
    tag: T,
    nodeSet: ReadonlyArray<AnyNode>,
  ): T => {
    if (isIdentity(tag)) {
      assertIdentityNodeCount(tag, nodeSet);
    }
    // Size 1 → client(Tag); otherwise nodeless for client (explicit node / ambient Protocol).
    const node =
      nodeSet.length === 1 ? (nodeSet[0] as NodeKey<unknown>) : undefined;
    return Object.assign(tag, {
      [nodesSym]: nodeSet,
      [nodeSym]: node,
    });
  },
);
Referenced by 2 symbols