Hyperlinkv0.8.0-beta.28

Hyperlink

Hyperlink.andNodeconstsrc/Hyperlink.ts:4822
<HSelf>(node: AddressedNode<HSelf>): <T extends PipeableTag>(
  tag: T
) => AndNodeResult<T, AddressedNode<HSelf>>
<HSelf>(node: NodeKey<HSelf>): <T extends PipeableTag>(
  tag: T
) => AndNodeResult<T, NodeKey<HSelf>>
<T extends PipeableTag>(node: AnyNode): (tag: T) => T
<Self, S extends Spec, HSelf>(
  tag: HyperlinkTag<Self, S> | NodeBoundTag<Self, S, HSelf>,
  node: AddressedNode<HSelf>
): AndNodeResult<
  HyperlinkTag<Self, S> | NodeBoundTag<Self, S, HSelf>,
  AddressedNode<HSelf>
>
<Self, S extends Spec, HSelf>(
  tag: HyperlinkTag<Self, S> | NodeBoundTag<Self, S, HSelf>,
  node: NodeKey<HSelf>
): AndNodeResult<
  HyperlinkTag<Self, S> | NodeBoundTag<Self, S, HSelf>,
  NodeKey<HSelf>
>
<Self, S extends Spec, HSelf>(
  tag: NodeBoundTag<Self, S, HSelf>,
  node: AnyNode
): NodeBoundTag<Self, S, HSelf>
<Self, S extends Spec>(
  tag: HyperlinkTag<Self, S>,
  node: AnyNode
): HyperlinkTag<Self, S>

Append one Node to a Tag's set (C1). From an empty set this is nodes([node]) — including the size-1 type bind for client(Tag). Identity Tags refuse a second Node (IdentityMultiNode).

class Mail extends Hyperlink.Tag<Mail>()("app/Mail", spec).pipe(
  Hyperlink.andNode(Worker), // ≡ nodes([Worker]) when starting empty
) {}
class PoolPlus extends PoolBase.pipe(Hyperlink.andNode(StatsNode)) {}

Type narrowing to a sole bind is only claimed when the input has no non-empty Node set. After a populated set, overwrite with nodes([x]) if you need a fresh typed sole bind for client(Tag).

nodes & fleetNodenodesclientIdentityMultiNode
Source src/Hyperlink.ts:482241 lines
export const andNode: {
  // data-last — addressed first (AddressedNode ⊆ NodeKey)
  <HSelf>(
    node: AddressedNode<HSelf>,
  ): <T extends PipeableTag>(
    tag: T,
  ) => AndNodeResult<T, AddressedNode<HSelf>>;
  <HSelf>(
    node: NodeKey<HSelf>,
  ): <T extends PipeableTag>(tag: T) => AndNodeResult<T, NodeKey<HSelf>>;
  <T extends PipeableTag>(node: AnyNode): (tag: T) => T;
  // data-first
  <Self, S extends Spec, HSelf>(
    tag: HyperlinkTag<Self, S> | NodeBoundTag<Self, S, HSelf>,
    node: AddressedNode<HSelf>,
  ): AndNodeResult<
    HyperlinkTag<Self, S> | NodeBoundTag<Self, S, HSelf>,
    AddressedNode<HSelf>
  >;
  <Self, S extends Spec, HSelf>(
    tag: HyperlinkTag<Self, S> | NodeBoundTag<Self, S, HSelf>,
    node: NodeKey<HSelf>,
  ): AndNodeResult<
    HyperlinkTag<Self, S> | NodeBoundTag<Self, S, HSelf>,
    NodeKey<HSelf>
  >;
  <Self, S extends Spec, HSelf>(
    tag: NodeBoundTag<Self, S, HSelf>,
    node: AnyNode,
  ): NodeBoundTag<Self, S, HSelf>;
  <Self, S extends Spec>(
    tag: HyperlinkTag<Self, S>,
    node: AnyNode,
  ): HyperlinkTag<Self, S>;
} = Fn.dual(
  2,
  <T extends HyperlinkTag<any, any, any>>(tag: T, node: AnyNode): T => {
    const current = tag[nodesSym] ?? [];
    return nodes(tag, [...current, node]) as T;
  },
);