Find out if a path can be a parent of a file you are looking for.
$ npm install glob-possible-parent
This library can be used with a glob matching library (micromatch, minimatch, etc.) to create a matcher that will match not only the given pattern, but also any parent directories. This can be used to optimize glob implementation, and prevent unnecessary disk access, by immediately ruling out directories which can't contain any matching files.
var gpp = ;var micromatch = ; // you can use any matcher implementation here// 1. use gpp() to transform the original pattern into an array of patterns which can be passed to the matching library// 2. create a RegExp from each pattern// 3. join all created RegExpsvar gppRegExp = '^(?:\\/$|(?:' ++ '))$';console; // => trueconsole; // => trueconsole; // => trueconsole; // => false
Copyright (c) 2016 Martin Kolárik. Released under the MIT license.