本文整理匯總了TypeScript中@phosphor/algorithm.iter函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript iter函數的具體用法?TypeScript iter怎麽用?TypeScript iter使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了iter函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: testIterator
testIterator(() => {
let a = iter([1, 2, 3]);
let b = iter(['four', 'five']);
let c = iter([true, false]);
type T = number | string | boolean;
let it = new ChainIterator<T>(iter([a, b, c]));
let expected = [1, 2, 3, 'four', 'five', true, false];
return [it, expected];
});
示例2: testIterator
testIterator(() => {
let i1 = iter(['one', 'two']);
let i2 = iter([1, 2]);
let i3 = iter([true, false]);
type T = string | number | boolean;
let it = new ZipIterator<T>([i1, i2, i3]);
let results = [['one', 1, true], ['two', 2, false]];
return [it, results];
});
示例3: createRowsWithGeneratedIndex
createRowsWithGeneratedIndex(data) {
this.rowsIterator = new MapIterator<any[], DataGridRow>(
iter(data),
(values, index) => new DataGridRow(index, values)
);
this.rows = toArray(this.rowsIterator.clone());
}
示例4: createRowsWithIndex
createRowsWithIndex(data) {
this.rowsIterator = new MapIterator<any[], DataGridRow>(
iter(data),
(values) => new DataGridRow(values[0], values.slice(1)
));
this.rows = toArray(this.rowsIterator.clone());
}
示例5: switch
const findTab = (
area: DockLayout.AreaConfig,
widget: Widget
): DockLayout.ITabAreaConfig | null => {
switch (area.type) {
case 'split-area':
const iterator = iter(area.children);
let tab: DockLayout.ITabAreaConfig | null = null;
let value: DockLayout.AreaConfig | null = null;
do {
value = iterator.next();
if (value) {
tab = findTab(value, widget);
}
} while (!tab && value);
return tab;
case 'tab-area':
const { id } = widget;
return area.widgets.some(widget => widget.id === id) ? area : null;
default:
return null;
}
};
示例6: testIterator
testIterator(() => {
return [new TakeIterator(iter([0, 1, 2, 3]), 1), [0]];
});
示例7: testIterator
testIterator(() => {
let result = [0, 1, 8, 27];
let it = new MapIterator(iter([0, 1, 2, 3]), x => x ** 3);
return [it, result];
});
示例8: it
it('should call `iter` on an iterable', () => {
let iterator = iter([1, 2, 3, 4]);
expect(iter(iterator)).to.equal(iterator);
});
示例9: testIterator
testIterator(() => {
let expected = [1, 3, 5];
let data = [0, 1, 2, 3, 4, 5];
let it = new FilterIterator(iter(data), n => n % 2 !== 0);
return [it, expected];
});