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


TypeScript algorithm.each函數代碼示例

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


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

示例1: toggleAllLineNumbers

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

示例2: it

 it('should insert a widget into the tab panel at a specified index', () => {
   let panel = new TabPanel();
   let widgets = [new Widget(), new Widget(), new Widget()];
   each(widgets, w => { panel.addWidget(w); });
   let widget = new Widget();
   panel.insertWidget(1, widget);
   expect(panel.widgets[1]).to.equal(widget);
   expect(panel.tabBar.titles[1]).to.equal(widget.title);
 });
開發者ID:afshin,項目名稱:phosphor,代碼行數:9,代碼來源:tabpanel.spec.ts

示例3: 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:vidartf,項目名稱:nbdime,代碼行數:9,代碼來源:flexpanel.spec.ts

示例4: createFooter

 /**
  * Create the footer of the dialog.
  *
  * @param buttonNodes - The buttons nodes to add to the footer.
  *
  * @returns A widget for the footer.
  */
 createFooter(buttons: ReadonlyArray<HTMLElement>): Widget {
   let footer = new Widget();
   footer.addClass('jp-Dialog-footer');
   each(buttons, button => {
     footer.node.appendChild(button);
   });
   Styling.styleNode(footer.node);
   return footer;
 }
開發者ID:cameronoelsen,項目名稱:jupyterlab,代碼行數:16,代碼來源:dialog.ts

示例5: runAll

 function runAll(widget: Notebook, kernel?: Kernel.IKernel): Promise<boolean> {
   if (!widget.model || !widget.activeCell) {
     return Promise.resolve(false);
   }
   each(widget.widgets, child => {
     widget.select(child);
   });
   return run(widget, kernel);
 }
開發者ID:rlugojr,項目名稱:jupyterlab,代碼行數:9,代碼來源:actions.ts

示例6: 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:rlugojr,項目名稱:jupyterlab,代碼行數:11,代碼來源:actions.ts

示例7: toggleAllLineNumbers

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

示例8: it

 it('should break early if the callback returns `false`', () => {
   let result = 0;
   let data = [1, 2, 3, 4, 5];
   each(data, x => {
     if (x > 3) {
       return false;
     }
     result += x;
     return true;
   });
   expect(result).to.equal(6);
 });
開發者ID:afshin,項目名稱:phosphor,代碼行數:12,代碼來源:iter.spec.ts

示例9: each

 execute: () => {
   const promises: Promise<void>[] = [];
   const paths = new Set<string>(); // Cache so we don't double save files.
   each(shell.widgets('main'), widget => {
     const context = docManager.contextForWidget(widget);
     if (context && !context.model.readOnly && !paths.has(context.path)) {
       paths.add(context.path);
       promises.push(context.save());
     }
   });
   return Promise.all(promises);
 }
開發者ID:afshin,項目名稱:jupyterlab,代碼行數:12,代碼來源:index.ts


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