Create a CapTP connection.

  • Parameters

    • ourId: string

      our name for the current side

    • rawSend: ((obj: Record<string, any>) => void) | ((obj: Record<string, any>) => PromiseLike<void>)

      send a JSONable packet

    • bootstrapObj: any = undefined

      the object to export to the other side

    • opts: CapTPOptions = {}

      options to the connection

    Returns {
        Trap: undefined | Trap;
        abort: ((reason?: undefined) => void);
        dispatch: ((obj: any) => boolean);
        getBootstrap: (() => Promise<any>);
        getStats: (() => {
            gc: {
                DROPPED: number;
            };
            recv: {};
            send: {};
        });
        isOnlyLocal: ((specimen: any) => boolean);
        makeRemoteKit: (<T>(target: string) => RemoteKit<T>);
        makeTrapHandler: ((name: any, obj: any) => any);
        serialize: ToCapData<string>;
        unserialize: FromCapData<string>;
    }

    • Trap: undefined | Trap
    • abort: ((reason?: undefined) => void)
        • (reason?): void
        • Parameters

          • reason: undefined = undefined

          Returns void

    • dispatch: ((obj: any) => boolean)
        • (obj): boolean
        • Parameters

          • obj: any

          Returns boolean

    • getBootstrap: (() => Promise<any>)
        • (): Promise<any>
        • Returns Promise<any>

    • getStats: (() => {
          gc: {
              DROPPED: number;
          };
          recv: {};
          send: {};
      })
        • (): {
              gc: {
                  DROPPED: number;
              };
              recv: {};
              send: {};
          }
        • Returns {
              gc: {
                  DROPPED: number;
              };
              recv: {};
              send: {};
          }

          • gc: {
                DROPPED: number;
            }
            • DROPPED: number
          • recv: {}
            • send: {}
        • isOnlyLocal: ((specimen: any) => boolean)
            • (specimen): boolean
            • Parameters

              • specimen: any

              Returns boolean

        • makeRemoteKit: (<T>(target: string) => RemoteKit<T>)
            • <T>(target): RemoteKit<T>
            • Type Parameters

              • T = unknown

              Parameters

              • target: string

              Returns RemoteKit<T>

              Make a remote promise for target (an id in the questions table)

        • makeTrapHandler: ((name: any, obj: any) => any)
            • (name, obj): any
            • Parameters

              • name: any
              • obj: any

              Returns any

        • serialize: ToCapData<string>
        • unserialize: FromCapData<string>