/*\
|*| Gets the depth of a path.
\
543863
function getPathDepth(p) {
  var parts = p.split(path.sep);
  // On *nix-based OS's, the root is '/'
  if(!parts[0]) {
    parts.unshift();
  }

  return p.split(path.sep).length;
}
933344
function(path) {
      return path.lastIndexOf('.') != -1 ? 
        path.slice(path.lastIndexOf('.') + 1, path.length) :
          null
    }
1164107
function docShouldHaveTrailingNewline(path) {
  const node = path.getValue();
  const parent = path.getParentNode();
  const parentParent = path.getParentNode(1);

  if (!parent) {
    return false;
  }

  if (
    (parentParent && ["call", "new", "echo"].includes(parentParent.kind)) ||
    parent.kind === "parameter"
  ) {
    const lastIndex = parentParent.arguments.length - 1;
    const index = parentParent.arguments.indexOf(parent);

    return index !== lastIndex;
  }

  if (parentParent && parentParent.kind === "for") {
    const initIndex = parentParent.init.indexOf(parent);

    if (initIndex !== -1) {
      return initIndex !== parentParent.init.length - 1;
    }

    const testIndex = parentParent.test.indexOf(parent);

    if (testIndex !== -1) {
      return testIndex !== parentParent.test.length - 1;
    }

    const incrementIndex = parentParent.increment.indexOf(parent);

    if (incrementIndex !== -1) {
      return incrementIndex !== parentParent.increment.length - 1;
    }
  }

  if (parent.kind === "bin") {
    if (parentParent && parentParent.kind === "bin") {
      return true;
    }

    return parent.left === node;
  }

  if (parent.kind === "case" && parent.test === node) {
    return true;
  }

  if (parent.kind === "staticvariable") {
    const lastIndex = parentParent.variables.length - 1;
    const index = parentParent.variables.indexOf(parent);

    return index !== lastIndex;
  }

  if (parent.kind === "entry") {
    if (parent.key === node) {
      return true;
    }

    const lastIndex = parentParent.items.length - 1;
    const index = parentParent.items.indexOf(parent);

    return index !== lastIndex;
  }

  if (["call", "new"].includes(parent.kind)) {
    const lastIndex = parent.arguments.length - 1;
    const index = parent.arguments.indexOf(node);

    return index !== lastIndex;
  }

  if (parent.kind === "echo") {
    const lastIndex = parent.expressions.length - 1;
    const index = parent.expressions.indexOf(node);

    return index !== lastIndex;
  }

  if (parent.kind === "array") {
    const lastIndex = parent.items.length - 1;
    const index = parent.items.indexOf(node);

    return index !== lastIndex;
  }

  return false;
}
217048
private int depth() {
        int i = 0;
        for (TreeString p = this; p != null; p = p.parent) {
            i++;
        }
        return i;
    }
481863
def depth(self):
        
        cat = self._xChart.cat
        if cat is None:
            return 0
        if cat.multiLvlStrRef is None:
            return 1
        return len(cat.lvls)
456965
public static int getAbsoluteLevel(@NotNull String path) {
    if (StringUtils.isEmpty(path) || StringUtils.equals(path, "/")) {
      return -1;
    }
    return StringUtils.countMatches(path, "/") - 1;
  }
153885
function getValueByPath(o, path) {
        for (var i = 0, len = path.length; o !== undefined && i < len; i++) {
            o = o[path[i]];
        }
        return o;
    }
1192824
function deepFromEntries(parent, parentKey, path, value) {
  const key = path.shift()
  const current = isNaN(key) ? {} : []

  // TODO: Refactor that function to reduce code.
  if (!parent) {
    if (path.length === 0) {
      current[key] = value

      return current
    }

    current[key] = deepFromEntries(current[key], key, path, value)

    return current
  }

  if (isPlainObject(parent) || isArray(parent)) {
    if (path.length === 0) {
      parent[key] = value

      return parent
    }

    parent[key] = deepFromEntries(parent[key], key, path, value)

    return parent
  }

  if (path.length === 0) {
    current[key] = value

    return current
  }

  current[key] = deepFromEntries(parent[key], key, path, value)

  return current
}
1246441
def _walk_depth(
        self,
        fs,  # type: FS
        path,  # type: Text
        namespaces=None,  # type: Optional[Collection[Text]]
    ):
        # type: (...) -> Iterator[Tuple[Text, Optional[Info]]]
        
        # No recursion!

        _combine = combine
        _scan = self._scan
        _calculate_depth = self._calculate_depth
        _check_open_dir = self._check_open_dir
        _check_scan_dir = self._check_scan_dir
        _check_file = self.check_file
        depth = _calculate_depth(path)

        stack = [
            (path, _scan(fs, path, namespaces=namespaces), None)
        ]  # type: List[Tuple[Text, Iterator[Info], Optional[Tuple[Text, Info]]]]

        push = stack.append

        while stack:
            dir_path, iter_files, parent = stack[-1]
            info = next(iter_files, None)
            if info is None:
                if parent is not None:
                    yield parent
                yield dir_path, None
                del stack[-1]
            elif info.is_dir:
                _depth = _calculate_depth(dir_path) - depth + 1
                if _check_open_dir(fs, dir_path, info):
                    if _check_scan_dir(fs, dir_path, info, _depth):
                        _path = _combine(dir_path, info.name)
                        push(
                            (
                                _path,
                                _scan(fs, _path, namespaces=namespaces),
                                (dir_path, info),
                            )
                        )
                    else:
                        yield dir_path, info
            else:
                if _check_file(fs, info):
                    yield dir_path, info
709319
function relative(path){
  var startX = 0
  var startY = 0
  var x = 0
  var y = 0

  return path.map(function(seg){
    seg = seg.slice()
    var type = seg[0]
    var command = type.toLowerCase()

    // is absolute
    if (type != command) {
      seg[0] = command
      switch (type) {
        case 'A':
          seg[6] -= x
          seg[7] -= y
          break
        case 'V':
          seg[1] -= y
          break
        case 'H':
          seg[1] -= x
          break
        default:
          for (var i = 1; i < seg.length;) {
            seg[i++] -= x
            seg[i++] -= y
          }
      }
    }

    // update cursor state
    switch (command) {
      case 'z':
        x = startX
        y = startY
        break
      case 'h':
        x += seg[1]
        break
      case 'v':
        y += seg[1]
        break
      case 'm':
        x += seg[1]
        y += seg[2]
        startX += seg[1]
        startY += seg[2]
        break
      default:
        x += seg[seg.length - 2]
        y += seg[seg.length - 1]
    }

    return seg
  })
}
620799
function getPath(parent, unresolved) {
	let parentVisited = false;

	return Object.keys(unresolved).filter((module) => {
		if (module === parent) {
			parentVisited = true;
		}
		return parentVisited && unresolved[module];
	});
}
672849
function(root, path) {
				if (path.indexOf(this.SEPARATOR) === 0) {
					root = this.rootNode;
					path = path.substring(1);
				} else {
					if (!root) {
						if (!this.currentDirectory) {
							/* no node to resolve the path in terms of */
							return null;
						}
						root = this.currentDirectory;
					}
				}
				var segments = path.substring(0, path.lastIndexOf(this.SEPARATOR)).split(this.SEPARATOR);
				var result = root;
				for (var i = 0; i < segments.length; i++) {
					if (segments[i].length > 0) {
						result = this.getChild(result, segments[i]);
						if (!result || !result.Directory) {
							/* non-existent directory */
							return null;
						}
					}
				}

				/*
				 * If the full path represents a directory then initiate the
				 * retrieval of its full node info and children.
				 */
				var lastSegment = path.substring(path.lastIndexOf(this.SEPARATOR) + 1);
				var child = this.getChild(result, lastSegment);
				if (child) {
					this._retrieveNode(child);
				}

				if (!result.Children) {
					this._retrieveNode(result);
				}
				return result;
			}
502921
def walklevel(path, depth = -1, **kwargs):
        
        # if depth is negative, just walk
        if depth < 0:
            for root, dirs, files in os.walk(path, **kwargs):
                yield root, dirs, files

        # path.count works because is a file has a "/" it will show up in the list
        # as a ":"
        path    = path.rstrip(os.path.sep)
        num_sep = path.count(os.path.sep)
        for root, dirs, files in os.walk(path, **kwargs):
            yield root, dirs, files
            num_sep_this = root.count(os.path.sep)
            if num_sep + depth <= num_sep_this:
                del dirs[:]
804892
def depth(self, *args):
            
            if len(args):
                self._depth = args[0]
            else:
                return self._depth
1111083
function(obj, d) {
	var k;
	
	d = typeof d === 'undefined' ? 0 : d;
	d += 1;
	for (k in obj) {
		if (obj.hasOwnProperty(k) && _.isObject(obj[k])) {
			return depth(obj[k], d);
		}
	}
	return (d);	
}
1128754
def find(max_depth=3):
        """"""
        i = 0
        for c, d, f in walk_up(os.getcwd()):
            i += 1

            if i < max_depth:
                if 'Pipfile':
                    p = os.path.join(c, 'Pipfile')
                    if os.path.isfile(p):
                        return p
        raise RuntimeError('No Pipfile found!')
1113011
function findPath(path, directories) {
  var cwd = directories[0];

  if (!cwd) {
    return null;
  }

  return findup(path, {cwd: cwd}) || findPath(path, slice.call(directories, 1));
}