path.matchesGlob(path, pattern)


稳定性: 1 - 实验性的

¥Stability: 1 - Experimental

  • path <string> 用于 glob 匹配的路径。

    ¥path <string> The path to glob-match against.

  • pattern <string> 用于检查路径的 glob。

    ¥pattern <string> The glob to check the path against.

  • 返回:<boolean> path 是否与 pattern 匹配。

    ¥Returns: <boolean> Whether or not the path matched the pattern.

path.matchesGlob() 方法确定 path 是否与 pattern 匹配。

¥The path.matchesGlob() method determines if path matches the pattern.

例如:

¥For example:

path.matchesGlob('/foo/bar', '/foo/*'); // true
path.matchesGlob('/foo/bar*', 'foo/bird'); // false 

如果 pathpattern 不是字符串,则抛出 TypeError

¥A TypeError is thrown if path or pattern are not strings.