How to use the @lumino/algorithm.each function in @lumino/algorithm

To help you get started, we’ve selected a few @lumino/algorithm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jupyterlab / lumino / packages / widgets / src / docklayout.ts View on Github external
function realizeTabAreaConfig(config: DockLayout.ITabAreaConfig, renderer: DockLayout.IRenderer): TabLayoutNode {
    // Create the tab bar for the layout node.
    let tabBar = renderer.createTabBar();

    // Hide each widget and add it to the tab bar.
    each(config.widgets, widget => {
      widget.hide();
      tabBar.addTab(widget.title);
    });

    // Set the current index of the tab bar.
    tabBar.currentIndex = config.currentIndex;

    // Return the new tab layout node.
    return new TabLayoutNode(tabBar);
  }
github jupyterlab / lumino / packages / widgets / src / contextmenu.ts View on Github external
// Bail early if there are no items to match.
    if (this._items.length === 0) {
      return false;
    }

    // Find the matching items for the event.
    let items = Private.matchItems(this._items, event);

    // Bail if there are no matching items.
    if (!items || items.length === 0) {
      return false;
    }

    // Add the filtered items to the menu.
    each(items, item => { this.menu.addItem(item); });

    // Open the context menu at the current mouse position.
    this.menu.open(event.clientX, event.clientY);

    // Indicate success.
    return true;
  }
github jupyterlab / lumino / packages / widgets / src / docklayout.ts View on Github external
function normalizeTabAreaConfig(config: DockLayout.ITabAreaConfig, widgetSet: Set): DockLayout.ITabAreaConfig | null {
    // Bail early if there is no content.
    if (config.widgets.length === 0) {
      return null;
    }

    // Setup the filtered widgets array.
    let widgets: Widget[] = [];

    // Filter the config for unique widgets.
    each(config.widgets, widget => {
      if (!widgetSet.has(widget)) {
        widgetSet.add(widget);
        widgets.push(widget);
      }
    });

    // Bail if there are no effective widgets.
    if (widgets.length === 0) {
      return null;
    }

    // Normalize the current index.
    let index = config.currentIndex;
    if (index !== -1 && (index < 0 || index >= widgets.length)) {
      index = 0;
    }
github jupyterlab / lumino / packages / widgets / src / gridlayout.ts View on Github external
dispose(): void {
    // Dispose of the widgets and layout items.
    each(this._items, item => {
      let widget = item.widget;
      item.dispose();
      widget.dispose();
    });

    // Clear the layout state.
    this._box = null;
    this._items.length = 0;
    this._rowStarts.length = 0;
    this._rowSizers.length = 0;
    this._columnStarts.length = 0;
    this._columnSizers.length = 0;

    // Dispose of the rest of the layout.
    super.dispose();
  }
github jupyterlab / lumino / packages / signaling / src / index.ts View on Github external
function disconnectAll(object: any): void {
    // Clear and cleanup any receiver connections.
    let receivers = receiversForSender.get(object);
    if (receivers && receivers.length > 0) {
      each(receivers, connection => { connection.signal = null; });
      scheduleCleanup(receivers);
    }

    // Clear and cleanup any sender connections.
    let senders = sendersForReceiver.get(object);
    if (senders && senders.length > 0) {
      each(senders, connection => { connection.signal = null; });
      scheduleCleanup(senders);
    }
  }
github jupyterlab / lumino / packages / signaling / src / index.ts View on Github external
function disconnectAll(object: any): void {
    // Clear and cleanup any receiver connections.
    let receivers = receiversForSender.get(object);
    if (receivers && receivers.length > 0) {
      each(receivers, connection => { connection.signal = null; });
      scheduleCleanup(receivers);
    }

    // Clear and cleanup any sender connections.
    let senders = sendersForReceiver.get(object);
    if (senders && senders.length > 0) {
      each(senders, connection => { connection.signal = null; });
      scheduleCleanup(senders);
    }
  }
github jupyterlab / jupyterlab / packages / services / src / session / default.ts View on Github external
function killSessions(id: string, baseUrl: string): void {
    let running = runningSessions.get(baseUrl) || [];
    each(running.slice(), session => {
      if (session.id === id) {
        session.dispose();
      }
    });
  }
github jupyterlab / lumino / packages / widgets / src / docklayout.ts View on Github external
holdSizes(): void {
      each(this.sizers, sizer => { sizer.sizeHint = sizer.size; });
    }
github jupyterlab / lumino / packages / collections / src / bplustree.ts View on Github external
function clear(node: Node): void {
    if (node.type === NodeType.Branch) {
      each(node.children, clear);
      node.children.length = 0;
      node.sizes.length = 0;
      node.items.length = 0;
    } else {
      node.items.length = 0;
      node.next = null;
      node.prev = null;
    }
  }
github jupyterlab / jupyterlab / packages / docregistry / src / registry.ts View on Github external
fts.forEach(ft => {
      if (ft.name in this._widgetFactoriesForFileType) {
        each(this._widgetFactoriesForFileType[ft.name], n => {
          factories.add(n);
        });
      }
    });