当前位置: 首页>>代码示例>>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;未经允许,请勿转载。