getManagedItem = (managedPath, path) => {
	let i = managedPath.length;
	let slashes = 1;
	let startingPosition = true;
	loop: while (i < path.length) {
		switch (path.charCodeAt(i)) {
			case 47: // slash
			case 92: // backslash
				if (--slashes === 0) break loop;
				startingPosition = true;
				break;
			case 46: // .
				// hidden files are disallowed as managed items
				// it's probably .yarn-integrity or .cache
				if (startingPosition) return null;
				break;
			case 64: // @
				if (!startingPosition) return null;
				slashes++;
				break;
			default:
				startingPosition = false;
				break;
		}
		i++;
	}
	if (i === path.length) slashes--;
	// return null when path is incomplete
	if (slashes !== 0) return null;
	// if (path.slice(i + 1, i + 13) === "node_modules")
	if (
		path.length >= i + 13 &&
		path.charCodeAt(i + 1) === 110 &&
		path.charCodeAt(i + 2) === 111 &&
		path.charCodeAt(i + 3) === 100 &&
		path.charCodeAt(i + 4) === 101 &&
		path.charCodeAt(i + 5) === 95 &&
		path.charCodeAt(i + 6) === 109 &&
		path.charCodeAt(i + 7) === 111 &&
		path.charCodeAt(i + 8) === 100 &&
		path.charCodeAt(i + 9) === 117 &&
		path.charCodeAt(i + 10) === 108 &&
		path.charCodeAt(i + 11) === 101 &&
		path.charCodeAt(i + 12) === 115
	) {
		// if this is the end of the path
		if (path.length === i + 13) {
			// return the node_modules directory
			// it's special
			return path;
		}
		const c = path.charCodeAt(i + 13);
		// if next symbol is slash or backslash
		if (c === 47 || c === 92) {
			// Managed subpath
			return getManagedItem(path.slice(0, i + 14), path);
		}
	}
	return path.slice(0, i);
}
Finding file or directory to manage
@param {string} managedPath path that is managing by {@link FileSystemInfo}
@param {string} path path to file or directory
@returns {string|null} managed item
@example
getManagedItem(
  '/Users/user/my-project/node_modules/',
  '/Users/user/my-project/node_modules/package/index.js'
) === '/Users/user/my-project/node_modules/package'
getManagedItem(
  '/Users/user/my-project/node_modules/',
  '/Users/user/my-project/node_modules/package1/node_modules/package2'
) === '/Users/user/my-project/node_modules/package1/node_modules/package2'
getManagedItem(
  '/Users/user/my-project/node_modules/',
  '/Users/user/my-project/node_modules/.bin/script.js'
) === null // hidden files are disallowed as managed items
getManagedItem(
  '/Users/user/my-project/node_modules/',
  '/Users/user/my-project/node_modules/package'
) === '/Users/user/my-project/node_modules/package'