當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript algorithm.map函數代碼示例

本文整理匯總了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]);
 });
開發者ID:afshin,項目名稱:phosphor,代碼行數:12,代碼來源:linkedlist.spec.ts

示例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);
  }
開發者ID:charnpreetsingh185,項目名稱:jupyterlab,代碼行數:33,代碼來源:dialog.ts

示例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);
  });
開發者ID:samvasko,項目名稱:jupyterlab,代碼行數:29,代碼來源:index.ts

示例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 });
      })));
    },
開發者ID:cfsmile,項目名稱:jupyterlab,代碼行數:11,代碼來源:index.ts

示例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
            });
          })
        )
      );
    },
開發者ID:ellisonbg,項目名稱:jupyterlab,代碼行數:23,代碼來源:index.ts

示例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);
    }
開發者ID:ellisonbg,項目名稱:jupyterlab,代碼行數:24,代碼來源:index.ts

示例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;
      }
    }
  }
開發者ID:cameronoelsen,項目名稱:jupyterlab,代碼行數:41,代碼來源:dialog.ts

示例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);
   });
 }
開發者ID:rlugojr,項目名稱:jupyterlab,代碼行數:11,代碼來源:index.ts


注:本文中的@phosphor/algorithm.map函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。