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


TypeScript ArrayExt.firstIndexOf方法代码示例

本文整理汇总了TypeScript中@phosphor/algorithm.ArrayExt.firstIndexOf方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ArrayExt.firstIndexOf方法的具体用法?TypeScript ArrayExt.firstIndexOf怎么用?TypeScript ArrayExt.firstIndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@phosphor/algorithm.ArrayExt的用法示例。


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

示例1: it

 it('should take a rank as an option', () => {
   const menu1 = new Menu({ commands });
   const menu2 = new Menu({ commands });
   mainMenu.addMenu(menu1, { rank: 300 });
   mainMenu.addMenu(menu2, { rank: 200 });
   expect(ArrayExt.firstIndexOf(mainMenu.menus, menu1)).to.equal(6);
   expect(ArrayExt.firstIndexOf(mainMenu.menus, menu2)).to.equal(5);
 });
开发者ID:willingc,项目名称:jupyterlab,代码行数:8,代码来源:mainmenu.spec.ts

示例2: handlePayload

  /**
   * Handle payloads from an execute reply.
   *
   * #### Notes
   * Payloads are deprecated and there are no official interfaces for them in
   * the kernel type definitions.
   * See [Payloads (DEPRECATED)](https://jupyter-client.readthedocs.io/en/latest/messaging.html#payloads-deprecated).
   */
  function handlePayload(content: KernelMessage.IExecuteOkReply, parent: Notebook, child: Cell) {
    let setNextInput = content.payload.filter(i => {
      return (i as any).source === 'set_next_input';
    })[0];

    if (!setNextInput) {
      return;
    }

    let text = (setNextInput as any).text;
    let replace = (setNextInput as any).replace;

    if (replace) {
      child.model.value.text = text;
      return;
    }

    // Create a new code cell and add as the next cell.
    let cell = parent.model.contentFactory.createCodeCell({});
    cell.value.text = text;
    let cells = parent.model.cells;
    let i = ArrayExt.firstIndexOf(toArray(cells), child.model);
    if (i === -1) {
      cells.push(cell);
    } else {
      cells.insert(i + 1, cell);
    }
  }
开发者ID:7125messi,项目名称:jupyterlab,代码行数:36,代码来源:actions.ts

示例3: it

 it('should be reset when loading from disk', () => {
   let model = new NotebookModel();
   let cell = model.contentFactory.createCodeCell({});
   model.cells.push(cell);
   model.fromJSON(DEFAULT_CONTENT);
   expect(ArrayExt.firstIndexOf(toArray(model.cells), cell)).to.be(-1);
   expect(model.cells.length).to.be(6);
 });
开发者ID:cameronoelsen,项目名称:jupyterlab,代码行数:8,代码来源:model.spec.ts

示例4: it

 it('should return `-1` if there is no matching value', () => {
   let data = ['one', 'two', 'three', 'four', 'one'];
   let i = ArrayExt.firstIndexOf(data, 'red');
   expect(i).to.equal(-1);
 });
开发者ID:afshin,项目名称:phosphor,代码行数:5,代码来源:array.spec.ts


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