當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。