本文整理汇总了TypeScript中@phosphor/algorithm.ArrayExt.firstIndexOf方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ArrayExt.firstIndexOf方法的具体用法?TypeScript ArrayExt.firstIndexOf怎么用?TypeScript ArrayExt.firstIndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@phosphor/algorithm.ArrayExt
的用法示例。
在下文中一共展示了ArrayExt.firstIndexOf方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should take a rank as an option', () => {
const menu1 = new Menu({ commands });
const menu2 = new Menu({ commands });
mainMenu.addMenu(menu1, { rank: 300 });
mainMenu.addMenu(menu2, { rank: 200 });
expect(ArrayExt.firstIndexOf(mainMenu.menus, menu1)).to.equal(6);
expect(ArrayExt.firstIndexOf(mainMenu.menus, menu2)).to.equal(5);
});
示例2: handlePayload
/**
* Handle payloads from an execute reply.
*
* #### Notes
* Payloads are deprecated and there are no official interfaces for them in
* the kernel type definitions.
* See [Payloads (DEPRECATED)](https://jupyter-client.readthedocs.io/en/latest/messaging.html#payloads-deprecated).
*/
function handlePayload(content: KernelMessage.IExecuteOkReply, parent: Notebook, child: Cell) {
let setNextInput = content.payload.filter(i => {
return (i as any).source === 'set_next_input';
})[0];
if (!setNextInput) {
return;
}
let text = (setNextInput as any).text;
let replace = (setNextInput as any).replace;
if (replace) {
child.model.value.text = text;
return;
}
// Create a new code cell and add as the next cell.
let cell = parent.model.contentFactory.createCodeCell({});
cell.value.text = text;
let cells = parent.model.cells;
let i = ArrayExt.firstIndexOf(toArray(cells), child.model);
if (i === -1) {
cells.push(cell);
} else {
cells.insert(i + 1, cell);
}
}
示例3: it
it('should be reset when loading from disk', () => {
let model = new NotebookModel();
let cell = model.contentFactory.createCodeCell({});
model.cells.push(cell);
model.fromJSON(DEFAULT_CONTENT);
expect(ArrayExt.firstIndexOf(toArray(model.cells), cell)).to.be(-1);
expect(model.cells.length).to.be(6);
});
示例4: it
it('should return `-1` if there is no matching value', () => {
let data = ['one', 'two', 'three', 'four', 'one'];
let i = ArrayExt.firstIndexOf(data, 'red');
expect(i).to.equal(-1);
});