本文整理汇总了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;
});
}
示例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);
});
示例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);
});
});
示例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;
}
示例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);
}
示例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;
}
});
}
示例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);
}
示例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);
});
示例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);
}