当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript messaging.createMessage函数代码示例

本文整理汇总了TypeScript中@nteract/messaging.createMessage函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createMessage函数的具体用法?TypeScript createMessage怎么用?TypeScript createMessage使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了createMessage函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: createMessage

export const completionRequest = (code: string, cursorPos: number) =>
  createMessage("complete_request", {
    content: {
      code,
      cursor_pos: cursorPos
    }
  });
开发者ID:kelleyblackmore,项目名称:nteract,代码行数:7,代码来源:complete.ts

示例2: createCommMessage

export function createCommMessage(
  comm_id: string,
  data: any = {},
  buffers: Uint8Array = new Uint8Array([])
) {
  return createMessage("comm_msg", { content: { comm_id, data }, buffers });
}
开发者ID:kelleyblackmore,项目名称:nteract,代码行数:7,代码来源:comm.ts

示例3: createMessage

export const tooltipRequest = (code: string, cursorPos: number) =>
  createMessage("inspect_request", {
    content: {
      code,
      cursor_pos: cursorPos,
      detail_level: 0
    }
  });
开发者ID:kelleyblackmore,项目名称:nteract,代码行数:8,代码来源:tooltip.ts

示例4: createCommCloseMessage

export function createCommCloseMessage(
  parent_header: any,
  comm_id: string,
  data: any = {}
) {
  return createMessage("comm_close", {
    content: { comm_id, data },
    parent_header
  });
}
开发者ID:kelleyblackmore,项目名称:nteract,代码行数:10,代码来源:comm.ts

示例5: expect

    sent.subscribe((msg: JupyterMessage) => {
      expect(msg.header.msg_type).toEqual("kernel_info_request");

      const response = createMessage("kernel_info_reply" as MessageType);
      response.parent_header = msg.header;
      response.content = {
        status: "ok",
        protocol_version: "5.1",
        implementation: "ipython",
        implementation_version: "6.2.1",
        language_info: {
          name: "python",
          version: "3.6.5",
          mimetype: "text/x-python",
          codemirror_mode: { name: "ipython", version: 3 },
          pygments_lexer: "ipython3",
          nbconvert_exporter: "python",
          file_extension: ".py"
        },
        banner:
          "Python 3.6.5 (default, Mar 30 2018, 06:41:53) \nType 'copyright', 'credits' or 'license' for more information\nIPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.\n",
        help_links: [
          { text: "Python Reference", url: "https://docs.python.org/3.6" },
          {
            text: "IPython Reference",
            url: "https://ipython.org/documentation.html"
          },
          {
            text: "NumPy Reference",
            url: "https://docs.scipy.org/doc/numpy/reference/"
          },
          {
            text: "SciPy Reference",
            url: "https://docs.scipy.org/doc/scipy/reference/"
          },
          {
            text: "Matplotlib Reference",
            url: "https://matplotlib.org/contents.html"
          },
          {
            text: "SymPy Reference",
            url: "http://docs.sympy.org/latest/index.html"
          },
          {
            text: "pandas Reference",
            url: "https://pandas.pydata.org/pandas-docs/stable/"
          }
        ]
      };

      // TODO: Get the Rx handling proper here
      setTimeout(() => received.next(response), 100);
    });
开发者ID:kelleyblackmore,项目名称:nteract,代码行数:53,代码来源:kernel-lifecycle.spec.ts

示例6: executeCellStream

 test.only("outright rejects a lack of channels.shell and iopub", done => {
   const obs = executeCellStream(
     null,
     "0",
     createMessage("execute_request"),
     "fakeContentRef"
   );
   obs.subscribe(null, err => {
     expect(err.message).toEqual("kernel not connected");
     done();
   });
 });
开发者ID:nteract,项目名称:nteract,代码行数:12,代码来源:execute.spec.ts

示例7: tooltipRequest

export function tooltipRequest(
  code: string,
  cursorPos: number
): JupyterMessage<"inspect_request", any> {
  return createMessage("inspect_request", {
    content: {
      code,
      cursor_pos: cursorPos,
      detail_level: 0
    }
  });
}
开发者ID:nteract,项目名称:nteract,代码行数:12,代码来源:tooltip.ts

示例8: it

  it("handles code completion", done => {
    const sent = new Subject();
    const received = new Subject();
    const mockSocket = Subject.create(sent, received);
    const channels = mockSocket;

    const cm = {
      getCursor: () => ({ line: 2 }),
      getValue: () => "\n\nimport thi",
      indexFromPos: () => 12,
      posFromIndex: x => ({ ch: x, line: 3 })
    };

    const message = createMessage("complete_request");
    const observable = complete.codeCompleteObservable(channels, cm, message);

    // Craft the response to their message
    const response = createMessage("complete_reply");
    response.content = {
      matches: ["import this"],
      cursor_start: 9,
      cursor_end: 10
    }; // Likely hokey values
    response.parent_header = Object.assign({}, message.header);

    // Listen on the Observable
    observable.subscribe(
      msg => {
        expect(msg.from).toEqual({ line: 3, ch: 9 });
        expect(msg.list[0].text).toEqual("import this");
        expect(msg.to).toEqual({ ch: 10, line: 3 });
      },
      err => {
        throw err;
      },
      done
    );
    received.next(response);
  });
开发者ID:kelleyblackmore,项目名称:nteract,代码行数:39,代码来源:complete.spec.ts

示例9: acquireKernelInfo

export function acquireKernelInfo(
  channels: Channels,
  kernelRef: KernelRef,
  contentRef: ContentRef
) {
  const message = createMessage("kernel_info_request");

  const obs = channels.pipe(
    childOf(message),
    ofMessageType("kernel_info_reply"),
    first(),
    mergeMap(msg => {
      const c = msg.content;
      const l = c.language_info;

      const info: KernelInfo = {
        protocolVersion: c.protocol_version,
        implementation: c.implementation,
        implementationVersion: c.implementation_version,
        banner: c.banner,
        helpLinks: c.help_links,
        languageName: l.name,
        languageVersion: l.version,
        mimetype: l.mimetype,
        fileExtension: l.file_extension,
        pygmentsLexer: l.pygments_lexer,
        codemirrorMode: l.codemirror_mode,
        nbconvertExporter: l.nbconvert_exporter
      };

      return of(
        // The original action we were using
        actions.setLanguageInfo({
          langInfo: msg.content.language_info,
          kernelRef,
          contentRef
        }),
        actions.setKernelInfo({
          kernelRef,
          info
        })
      );
    })
  );

  return Observable.create((observer: Observer<any>) => {
    const subscription = obs.subscribe(observer);
    channels.next(message);
    return subscription;
  });
}
开发者ID:kelleyblackmore,项目名称:nteract,代码行数:51,代码来源:kernel-lifecycle.ts

示例10: createCommOpenMessage

export function createCommOpenMessage(
  comm_id: string,
  target_name: string,
  data: any = {},
  target_module: string
) {
  const msg = createMessage("comm_open", {
    content: { comm_id, target_name, data }
  });
  if (target_module) {
    msg.content.target_module = target_module;
  }
  return msg;
}
开发者ID:kelleyblackmore,项目名称:nteract,代码行数:14,代码来源:comm.ts


注:本文中的@nteract/messaging.createMessage函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。