/*
@function (public) getRootFromPattern {string} [Get root from a pattern] @param pattern {string} @param callback
778773
function getRootFromPattern(pattern, callback) {
  isDirectory(pattern, function (error, data) {
    if (!data) {
      if (glob.hasMagic(pattern)) {
        callback(null, pattern.substring(0, pattern.indexOf("*")));
      } else {
        callback(null, path.dirname(pattern));
      }
    } else {
      callback(null, pattern);
    }
  });
}
294052
function search(root, test, skip, callback) {
  var index = -1
  var children = root.children
  var length = children.length
  var depth = null
  var start = null
  var end = null
  var nodes
  var clean
  var child

  while (++index < length) {
    child = children[index]

    if (closing(child, depth)) {
      end = index
      break
    }

    if (opening(child, depth, test)) {
      start = index
      depth = child.depth
    }
  }

  if (start !== null) {
    if (end === null) {
      end = length
    }

    if (skip) {
      while (end > start) {
        child = children[end - 1]

        if (!definition(child)) {
          break
        }

        end--
      }
    }

    nodes = callback(
      children[start],
      children.slice(start + 1, end),
      children[end],
      {
        parent: root,
        start: start,
        end: children[end] ? end : null
      }
    )

    clean = []
    index = -1
    length = nodes && nodes.length

    // Ensure no empty nodes are inserted.  This could be the case if `end` is
    // in `nodes` but no `end` node exists.
    while (++index < length) {
      if (nodes[index]) {
        clean.push(nodes[index])
      }
    }

    if (nodes) {
      splice.apply(children, [start, end - start + 1].concat(clean))
    }
  }
}
1138738
function getOrCompile (patternStr) {
    var tree, fn;
    if (!patterns.hasOwnProperty(patternStr)) {
      tree = parse(patternStr);
      if (!normalized.hasOwnProperty(tree.pattern)) {
        fn = compile(tree);
        fn.pattern = tree.pattern;
        normalized[tree.pattern] = fn;
      }
      patterns[patternStr] = normalized[tree.pattern];
    }
    return patterns[patternStr];
  }
764616
public function find($type, $pattern = false, $callback = null)
    {
        if (!isset($this->{$type})) {
            return [];
        }
        $components = to_array($this->{$type}, false);
        $result = [];
        foreach ($components as $name => $node) {
            if (empty($pattern) || preg_match($pattern, $name)) {
                if (is_callable($callback)) {
                    $node = exec_function_array($callback, [$node, $this]);
                }
                $result[$name] = $node;
            }
        }
        return $result;
    }
112778
private void visitObjectPattern(Node pattern) {
    JSType patternType = getJSType(pattern);
    validator.expectObject(pattern, patternType, "cannot destructure 'null' or 'undefined'");
    for (Node child : pattern.children()) {
      DestructuredTarget target = DestructuredTarget.createTarget(typeRegistry, patternType, child);

      if (target.hasComputedProperty()) {
        Node computedProperty = target.getComputedProperty();
        validator.expectIndexMatch(
            computedProperty, patternType, getJSType(computedProperty.getFirstChild()));
      } else if (target.hasStringKey()) {
        Node stringKey = target.getStringKey();
        if (!stringKey.isQuotedString()) {
          if (patternType.isDict()) {
            report(stringKey, TypeValidator.ILLEGAL_PROPERTY_ACCESS, "unquoted", "dict");
          }
          // check for missing properties given `const {a} = obj;` but not `const {'a': a} = obj;`
          checkPropertyAccessForDestructuring(
              pattern, patternType, stringKey, getJSType(target.getNode()));
        } else if (patternType.isStruct()) {
          // check that we are not accessing a struct with a quoted string
          report(stringKey, TypeValidator.ILLEGAL_PROPERTY_ACCESS, "quoted", "struct");
        }
      }
    }
    ensureTyped(pattern);
  }
230671
function _getRoot(transform) {
  return function() {
    var parent = transform.parent;
    return parent === undefined ? transform : parent.root;
  }
}
530005
function (value, pattern) {
        try {
            checkSubtree(value, pattern);
            return true;
        } catch (e) {
            if (e instanceof Match.Error)
                return false;
            // Rethrow other errors.
            throw e;
        }
    }
148182
function(pattern) {
        const mapBounds = this._map.getBounds().pad(0.1);
        return this._paths.map(path => {
            const directionPoints = this._getDirectionPoints(path, pattern)
                // filter out invisible points
                .filter(point => mapBounds.contains(point.latLng));
            return L.featureGroup(this._buildSymbols(path, pattern.symbolFactory, directionPoints));
        });
    }
793877
function _getValueFromPair(string, pattern) {
         var value = string.match(pattern);

         if (!value) {
           throw new Error("Could not find pattern " + pattern + " in string: " + string);
         }

         return value[0].split("=")[1];
       }
82027
function(pattern, callback) {
    glob(pattern, opts, function(err, globbedFiles) {
      if (isArray(globbedFiles) && globbedFiles.length && !err) {
        callback(null, globbedFiles);
      }
      else {
        console.error('The glob pattern ' + JSON.stringify(pattern) + ' did not match any files!');
        callback(null, []);
      }
    });
  }
1135233
function (callback, ctx) {
            var depth, node;
            for (depth = 0, node = this; node !== null; node = node.parent(), depth++)
                ctx = callback(depth, node, ctx);
            return ctx;
        }
178735
function delegateRenderBy(DecorateViewModel $parentView, $rootPassedToNext = null)
    {
        if ($rootPassedToNext === null)
            // first segment of list do not pass nextRoot
            $rootPassedToNext = $parentView;

        $this->myRoot   = $rootPassedToNext;
        $this->nextRoot = $parentView;


        if (null ===  $callback = $this->delegateRenderBy )
            return;

        // DO_LEAST_PHPVER_SUPPORT 5.4 closure bindto
        if ($callback instanceof \Closure && version_compare(phpversion(), '5.4.0') > 0) {
            $callback = \Closure::bind(
                $callback
                , $this->_view
                , get_class($this)
            );
        }

        call_user_func($callback, $parentView, $parentView->parent(), $this);
    }
1058727
protected Pattern[] queryDetectionPattern(final Pattern... pattern) {
        if (pattern == null) {
            throw new IllegalArgumentException();
        } // end of if

        // ---

        if (this.queryDetection == null) {
            return pattern;
        } // end of if

        // ---

        final Pattern[] patterns = 
            new Pattern[this.queryDetection.length + pattern.length];

        System.arraycopy(this.queryDetection, 0, 
                         patterns, 0, 
                         this.queryDetection.length);

        int i = this.queryDetection.length;

        for (final Pattern p : pattern) {
            patterns[i++] = p;
        } // end of for

        return patterns;
    }
806666
function getRootPath (p) {
  p = path.normalize(path.resolve(p)).split(path.sep)
  if (p.length > 0) return p[0]
  return null
}
165518
function getPatterns() {
        if (isPatternsDirty) {
          patterns.sort(function (a, b) {
            if (a.start.length > b.start.length) {
              return -1;
            }

            if (a.start.length < b.start.length) {
              return 1;
            }

            return 0;
          });

          isPatternsDirty = false;
        }

        return patterns;
      }
234997
function(root) {
          var pindex = 0, // avoid array alloc for every invocation
            ret = [],
            tp;
          while (tp = parts[pindex++]) {
            ret = ret.concat(getStepQueryFunc(tp)(root));
          }
          return ret;
        }
1031722
function getRootNode(node) {
  if (!Node.Type.isFunction(node, 'nthRoot')) {
    throw Error('Expected nthRoot');
  }

  return node.args.length === 2 ? node.args[1] : Node.Creator.constant(2);
}