How to use the taskcluster-lib-scopes.scopeCompare function in taskcluster-lib-scopes

To help you get started, we’ve selected a few taskcluster-lib-scopes 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 taskcluster / taskcluster / services / auth / src / scopesetbuilder.js View on Github external
if (!this.A) { return this.B; }
    if (!this.B) { return this.A; }

    // Get values for easy reference
    const a = this.A.value;
    const b = this.B.value;

    if (a === b) {
      // If we have the same value in both we shall return and advance both A and B
      this.value = a;
      this.A = this.A.next();
      this.B = this.B.next();
    } else {
      // Otherwise, we take the first one according to scopeCompare, and advance
      // the matching child node
      const z = scopeCompare(a, b);
      if (z < 0) {
        this.value = a;
        this.A = this.A.next();
      } else {
        this.value = b;
        this.B = this.B.next();
      }
    }

    // If the value selected ends with kleene, we advanced both children until
    // they are null or we have value that doesn't start with said prefix.
    if (this.value.endsWith('*')) {
      const prefix = this.value.slice(0, -1);
      while (this.A && this.A.value.startsWith(prefix)) {
        this.A = this.A.next();
      }