本文整理匯總了TypeScript中@phosphor/algorithm.ArrayExt類的典型用法代碼示例。如果您正苦於以下問題:TypeScript ArrayExt類的具體用法?TypeScript ArrayExt怎麽用?TypeScript ArrayExt使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ArrayExt類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('should be reset when loading from disk', () => {
let model = new NotebookModel();
let cell = model.contentFactory.createCodeCell({});
model.cells.pushBack(cell);
model.fromJSON(DEFAULT_CONTENT);
expect(ArrayExt.firstIndexOf(toArray(model.cells), cell)).to.be(-1);
expect(model.cells.length).to.be(6);
});
示例2: it
it('adjust after inserting an item', function() {
const insertedValue = 'value-before-1';
ArrayExt.insert(sequence, 1, insertedValue);
// sequence is now [value-0, value-before-1, value-1]
selection.adjustSelectionForInsert(1, insertedValue);
expect(selection.index).to.equal(1);
expect(selection.value).to.equal(insertedValue);
});
示例3: _resolve
/**
* Resolve a button item.
*/
private _resolve(item: Dialog.IButton): void {
// Prevent loopback.
let promise = this._promise;
this._promise = null;
this.close();
ArrayExt.removeFirstOf(Private.launchQueue, promise.promise);
promise.resolve(item);
}
示例4: it
it('should be reset when loading from disk', () => {
const model = new NotebookModel();
const cell = model.contentFactory.createCodeCell({});
model.cells.push(cell);
model.fromJSON(NBTestUtils.DEFAULT_CONTENT);
expect(ArrayExt.firstIndexOf(toArray(model.cells), cell)).to.equal(-1);
expect(model.cells.length).to.equal(6);
});
示例5: dispose
/**
* Dispose of the resources used by the dialog.
*/
dispose(): void {
const promise = this._promise;
if (promise) {
this._promise = null;
promise.reject(void 0);
ArrayExt.removeFirstOf(Private.launchQueue, promise.promise);
}
super.dispose();
}
示例6: hitTestNodes
export function hitTestNodes(
nodes: HTMLElement[] | HTMLCollection,
x: number,
y: number
): number {
return ArrayExt.findFirstIndex(nodes, node => {
return ElementExt.hitTest(node, x, y);
});
}
示例7: dispose
/**
* Dispose of the resources used by the dialog.
*/
dispose(): void {
if (this._promise) {
let promise = this._promise;
this._promise = null;
promise.resolve(void 0);
ArrayExt.removeFirstOf(Private.launchQueue, promise.promise);
}
super.dispose();
}
示例8: _evtDragEnter
/**
* Handle the `'p-dragenter'` event for the widget.
*/
private _evtDragEnter(event: IDragEvent): void {
if (event.mimeData.hasData(CONTENTS_MIME)) {
let index = ArrayExt.findFirstIndex(this._crumbs, node => ElementExt.hitTest(node, event.clientX, event.clientY));
if (index !== -1) {
if (index !== Private.Crumb.Current) {
this._crumbs[index].classList.add(DROP_TARGET_CLASS);
event.preventDefault();
event.stopPropagation();
}
}
}
}
示例9: it
it('should remove a group from the menu', () => {
const group1 = [ { command: 'run1'}, { command: 'run2' }];
const group2 = [ { command: 'run3'}, { command: 'run4' }];
menu.addGroup(group1);
menu.addGroup(group2);
menu.removeGroup(group1);
let idx1 = ArrayExt.findFirstIndex(menu.menu.items,
m => m.command === 'run1');
let idx2 = ArrayExt.findFirstIndex(menu.menu.items,
m => m.command === 'run2');
let idx3 = ArrayExt.findFirstIndex(menu.menu.items,
m => m.command === 'run3');
let idx4 = ArrayExt.findFirstIndex(menu.menu.items,
m => m.command === 'run4');
expect(idx1).to.be(-1);
expect(idx2).to.be(-1);
expect(idx3 === -1).to.be(false);
expect(idx4 === -1).to.be(false);
});
示例10: it
it('adjust after removing the selected item', function() {
ArrayExt.removeAt(sequence, 1);
selection.adjustSelectionForRemove(1, 'value-1');
expect(selection.index).to.equal(0);
expect(selection.value).to.equal('value-0');
const message = getLastMessage(subscriber);
expect(message).to.deep.equal({
previousIndex: 1,
previousValue: 'value-1',
currentIndex: 0,
currentValue: 'value-0'
});
});