當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript iteration.each函數代碼示例

本文整理匯總了TypeScript中phosphor/lib/algorithm/iteration.each函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript each函數的具體用法?TypeScript each怎麽用?TypeScript each使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了each函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

 it('should add a class name to the flex panel children', () => {
   let p = new FlexPanel();
   p.addWidget(new Widget());
   p.addWidget(new Widget());
   p.addWidget(new Widget());
   each(p.widgets, (child) => {
     expect(child.hasClass('p-FlexPanel-child')).to.be(true);
   });
 });
開發者ID:minrk,項目名稱:nbdime,代碼行數:9,代碼來源:flexpanel.spec.ts

示例2: toggleLineNumbers

 function toggleLineNumbers(widget: Notebook): void {
   if (!widget.model || !widget.activeCell) {
     return;
   }
   let lineNumbers = widget.activeCell.editor.lineNumbers;
   each(widget.widgets, child => {
     if (widget.isSelected(child)) {
       child.editor.lineNumbers = !lineNumbers;
     }
   });
 }
開發者ID:Carreau,項目名稱:jupyterlab,代碼行數:11,代碼來源:actions.ts

示例3: clearAllOutputs

 function clearAllOutputs(widget: Notebook): void {
   if (!widget.model || !widget.activeCell) {
     return;
   }
   each(widget.model.cells, (cell: ICodeCellModel) => {
     if (cell.type === 'code') {
       cell.outputs.clear();
       cell.executionCount = null;
     }
   });
 }
開發者ID:Carreau,項目名稱:jupyterlab,代碼行數:11,代碼來源:actions.ts

示例4: it

 it('should clear the existing selection', () => {
   each(widget.widgets, child => {
     widget.select(child);
   });
   NotebookActions.splitCell(widget);
   for (let i = 0; i < widget.widgets.length; i++) {
     if (i === widget.activeCellIndex) {
       continue;
     }
     expect(widget.isSelected(widget.widgets.at(i))).to.be(false);
   }
 });
開發者ID:marami52,項目名稱:jupyterlab,代碼行數:12,代碼來源:actions.spec.ts

示例5: deleteCells

  function deleteCells(widget: Notebook): void {
    if (!widget.model || !widget.activeCell) {
      return;
    }
    let model = widget.model;
    let cells = model.cells;
    let toDelete: number[] = [];
    widget.mode = 'command';

    // Find the cells to delete.
    each(enumerate(widget.widgets), ([i, child]) => {
      let deletable = child.model.getMetadata('deletable').getValue();
      if (widget.isSelected(child) && deletable !== false) {
        toDelete.push(i);
      }
    });

    // If cells are not deletable, we may not have anything to delete.
    if (toDelete.length > 0) {
      // Delete the cells as one undo event.
      cells.beginCompoundOperation();
      each(toDelete.reverse(), i => {
        cells.removeAt(i);
      });
      // The model will add a new code cell if there are no
      // remaining cells.
      model.cells.endCompoundOperation();

      // Select the *first* interior cell not deleted or the cell
      // *after* the last selected cell.
      // Note: The activeCellIndex is clamped to the available cells,
      // so if the last cell is deleted the previous cell will be activated.
      widget.activeCellIndex = toDelete[0];
    }

    // Deselect any remaining, undeletable cells. Do this even if we don't
    // delete anything so that users are aware *something* happened.
    widget.deselectAll();
  }
開發者ID:Carreau,項目名稱:jupyterlab,代碼行數:39,代碼來源:actions.ts

示例6: each

 execute: () => {
   if (options.background === 'black') {
     options.background = 'white';
     options.color = 'black';
   } else {
     options.background = 'black';
     options.color = 'white';
   }
   each(tracker.widgets, widget => {
     widget.background = options.background;
     widget.color = options.color;
   });
 }
開發者ID:TypeFox,項目名稱:jupyterlab,代碼行數:13,代碼來源:plugin.ts

示例7: paste

  function paste(widget: Notebook, clipboard: IClipboard): void {
    if (!widget.model || !widget.activeCell) {
      return;
    }
    if (!clipboard.hasData(JUPYTER_CELL_MIME)) {
      return;
    }
    let values = clipboard.getData(JUPYTER_CELL_MIME) as nbformat.IBaseCell[];
    let model = widget.model;
    let newCells: ICellModel[] = [];
    widget.mode = 'command';

    each(values, cell => {
      switch (cell.cell_type) {
      case 'code':
        newCells.push(model.contentFactory.createCodeCell({ cell }));
        break;
      case 'markdown':
        newCells.push(model.contentFactory.createMarkdownCell({ cell }));
        break;
      default:
        newCells.push(model.contentFactory.createRawCell({ cell }));
        break;
      }
    });
    let index = widget.activeCellIndex;

    let cells = widget.model.cells;
    cells.beginCompoundOperation();
    each(newCells, cell => {
      cells.insert(++index, cell);
    });
    cells.endCompoundOperation();

    widget.activeCellIndex += newCells.length;
    widget.deselectAll();
  }
開發者ID:Carreau,項目名稱:jupyterlab,代碼行數:37,代碼來源:actions.ts

示例8: run

  function run(widget: Notebook, kernel?: Kernel.IKernel): Promise<boolean> {
    if (!widget.model || !widget.activeCell) {
      return Promise.resolve(false);
    }
    widget.mode = 'command';
    let selected: BaseCellWidget[] = [];
    let lastIndex = widget.activeCellIndex;
    let i = 0;
    each(widget.widgets, child => {
      if (widget.isSelected(child)) {
        selected.push(child);
        lastIndex = i;
      }
      i++;
    });
    widget.activeCellIndex = lastIndex;
    widget.deselectAll();

    let promises: Promise<boolean>[] = [];
    each(selected, child => {
      promises.push(Private.runCell(widget, child, kernel));
    });
    return Promise.all(promises).then(results => {
      if (widget.isDisposed) {
        return false;
      }
      // Post an update request.
      widget.update();
      for (let result of results) {
        if (!result) {
          return false;
        }
      }
      return true;
    });
  }
開發者ID:Carreau,項目名稱:jupyterlab,代碼行數:36,代碼來源:actions.ts

示例9: clearOutputs

 function clearOutputs(widget: Notebook): void {
   if (!widget.model || !widget.activeCell) {
     return;
   }
   let cells = widget.model.cells;
   let i = 0;
   each(cells, (cell: ICodeCellModel) => {
     let child = widget.widgets.at(i);
     if (widget.isSelected(child) && cell.type === 'code') {
       cell.outputs.clear();
       cell.executionCount = null;
     }
     i++;
   });
 }
開發者ID:Carreau,項目名稱:jupyterlab,代碼行數:15,代碼來源:actions.ts

示例10: setMarkdownHeader

 function setMarkdownHeader(widget: Notebook, level: number) {
   if (!widget.model || !widget.activeCell) {
     return;
   }
   level = Math.min(Math.max(level, 1), 6);
   let cells = widget.model.cells;
   let i = 0;
   each(widget.widgets, (child: MarkdownCellWidget) => {
     if (widget.isSelected(child)) {
       Private.setMarkdownHeader(cells.at(i), level);
     }
     i++;
   });
   changeCellType(widget, 'markdown');
 }
開發者ID:Carreau,項目名稱:jupyterlab,代碼行數:15,代碼來源:actions.ts


注:本文中的phosphor/lib/algorithm/iteration.each函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。