本文整理汇总了TypeScript中@phosphor/algorithm.map函数的典型用法代码示例。如果您正苦于以下问题:TypeScript map函数的具体用法?TypeScript map怎么用?TypeScript map使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了map函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should create a reverse iterator over the nodes', () => {
let list = LinkedList.from([0, 1, 2, 3, 4]);
let n = find(list.nodes(), n => n.value === 2)!;
let it1 = new LinkedList.RetroNodeIterator(n);
let it2 = it1.clone();
let v1 = map(it1, n => n.value);
let v2 = map(it2, n => n.value);
expect(it1.iter()).to.equal(it1);
expect(it2.iter()).to.equal(it2);
expect(toArray(v1)).to.deep.equal([2, 1, 0]);
expect(toArray(v2)).to.deep.equal([2, 1, 0]);
});
示例2: constructor
/**
* Create a dialog panel instance.
*
* @param options - The dialog setup options.
*/
constructor(options: Dialog.IOptions={}) {
super();
this.addClass('jp-Dialog');
options = Private.handleOptions(options);
let renderer = options.renderer;
this._host = options.host;
this._defaultButton = options.defaultButton;
this._buttons = options.buttons;
this._buttonNodes = toArray(map(this._buttons, button => {
return renderer.createButtonNode(button);
}));
this._primary = (
options.primaryElement || this._buttonNodes[this._defaultButton]
);
let layout = this.layout = new PanelLayout();
let content = new Panel();
content.addClass('jp-Dialog-content');
layout.addWidget(content);
let header = renderer.createHeader(options.title);
let body = renderer.createBody(options.body);
let footer = renderer.createFooter(this._buttonNodes);
content.addWidget(header);
content.addWidget(body);
content.addWidget(footer);
}
示例3: toArray
node.addEventListener('contextmenu', (event: MouseEvent) => {
event.preventDefault();
let path = fbWidget.pathForClick(event) || '';
let ext = DocumentRegistry.extname(path);
let factories = registry.preferredWidgetFactories(ext);
let widgetNames = toArray(map(factories, factory => factory.name));
let prefix = `${namespace}-contextmenu-${++Private.id}`;
let openWith: Menu = null;
if (path && widgetNames.length > 1) {
let disposables = new DisposableSet();
let command: string;
openWith = new Menu({ commands });
openWith.title.label = 'Open With...';
openWith.disposed.connect(() => { disposables.dispose(); });
for (let widgetName of widgetNames) {
command = `${prefix}:${widgetName}`;
disposables.add(commands.addCommand(command, {
execute: () => fbWidget.openPath(path, widgetName),
label: widgetName
}));
openWith.addItem({ command });
}
}
let menu = createContextMenu(fbWidget, openWith);
menu.open(event.clientX, event.clientY);
});
示例4:
execute: () => {
const widget = tracker.currentWidget;
if (!widget) {
return;
}
return Promise.all(toArray(map(widget.selectedItems(), item => {
return commands.execute('docmanager:open-browser-tab', { path: item.path });
})));
},
示例5: toArray
execute: args => {
const factory = (args['factory'] as string) || void 0;
const widget = tracker.currentWidget;
if (!widget) {
return;
}
return Promise.all(
toArray(
map(widget.selectedItems(), item => {
if (item.type === 'directory') {
return widget.model.cd(item.name);
}
return commands.execute('docmanager:open', {
factory: factory,
path: item.path
});
})
)
);
},
示例6: onBeforeAttach
protected onBeforeAttach(msg: Message): void {
// clear the current menu items
this.clearItems();
// get the widget factories that could be used to open all of the items
// in the current filebrowser selection
let factories = OpenWithMenu._intersection(
map(tracker.currentWidget.selectedItems(), i => {
return OpenWithMenu._getFactories(i);
})
);
if (factories) {
// make new menu items from the widget factories
factories.forEach(factory => {
this.addItem({
args: { factory: factory },
command: CommandIDs.open
});
});
}
super.onBeforeAttach(msg);
}
示例7: constructor
/**
* Create a dialog panel instance.
*
* @param options - The dialog setup options.
*/
constructor(options: Partial<Dialog.IOptions<T>>={}) {
super();
this.addClass('jp-Dialog');
let normalized = Private.handleOptions(options);
let renderer = normalized.renderer;
this._host = normalized.host;
this._defaultButton = normalized.defaultButton;
this._buttons = normalized.buttons;
this._buttonNodes = toArray(map(this._buttons, button => {
return renderer.createButtonNode(button);
}));
let layout = this.layout = new PanelLayout();
let content = new Panel();
content.addClass('jp-Dialog-content');
layout.addWidget(content);
this._body = normalized.body;
let header = renderer.createHeader(normalized.title);
let body = renderer.createBody(normalized.body);
let footer = renderer.createFooter(this._buttonNodes);
content.addWidget(header);
content.addWidget(body);
content.addWidget(footer);
this._primary = this._buttonNodes[this._defaultButton];
if (options.focusNodeSelector) {
let el = body.node.querySelector(options.focusNodeSelector);
if (el) {
this._primary = el as HTMLElement;
}
}
}
示例8: names
/**
* Get an iterator over the ordered toolbar item names.
*
* @returns An iterator over the toolbar item names.
*/
names(): IIterator<string> {
let layout = this.layout as PanelLayout;
return map(layout.widgets, widget => {
return Private.nameProperty.get(widget);
});
}