本文整理匯總了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);
}