How to use the @lumino/algorithm.ArrayExt.fill 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 / menu.ts View on Github external
function computeCollapsed(items: ReadonlyArray): boolean[] {
    // Allocate the return array and fill it with `false`.
    let result = new Array(items.length);
    ArrayExt.fill(result, false);

    // Collapse the leading separators.
    let k1 = 0;
    let n = items.length;
    for (; k1 < n; ++k1) {
      let item = items[k1];
      if (!item.isVisible) {
        continue;
      }
      if (item.type !== 'separator') {
        break;
      }
      result[k1] = true;
    }

    // Hide the trailing separators.
github jupyterlab / lumino / packages / widgets / src / commandpalette.ts View on Github external
function createResults(scores: IScore[]): SearchResult[] {
    // Set up an array to track which scores have been visited.
    let visited = new Array(scores.length);
    ArrayExt.fill(visited, false);

    // Set up the search results array.
    let results: SearchResult[] = [];

    // Iterate over each score in the array.
    for (let i = 0, n = scores.length; i < n; ++i) {
      // Ignore a score which has already been processed.
      if (visited[i]) {
        continue;
      }

      // Extract the current item and indices.
      let { item, categoryIndices } = scores[i];

      // Extract the category for the current item.
      let category = item.category;
github jupyterlab / lumino / packages / messaging / src / index.ts View on Github external
function clearData(handler: IMessageHandler): void {
    // Lookup the hooks for the handler.
    let hooks = messageHooks.get(handler);

    // Clear all messsage hooks for the handler.
    if (hooks && hooks.length > 0) {
      ArrayExt.fill(hooks, null);
      scheduleCleanup(hooks);
    }

    // Clear all posted messages for the handler.
    each(messageQueue, posted => {
      if (posted.handler === handler) {
        posted.handler = null;
        posted.msg = null;
      }
    });
  }