Skip to content

Pathgather/glob-intersection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm build dependencies devDependencies

glob-intersection

Find the intersection of two glob patterns

intersect = require("glob-intersection")

intersect("**/*.{js,coffee}", "/hello/world/*.??")
# => "/hello/world/*.js"

intersect("hello", "world")
# => false

intersect("{a,b,c,x,d}", "{x,y,z,c,w}")
# => "{c,x}"

intersect("*a*b*", "*x*y*")
# => "*{a*{b*x*y,x*{b*y,y*b}},x*{a*{b*y,y*b},y*a*b}}*"
# braces(_) => '["*a*b*x*y*","*x*a*b*y*","*a*x*b*y*","*x*y*a*b*","*x*a*y*b*","*a*x*y*b*"]'

Caveats

Full compatability with Bash or other globbing libraries was not a design goal. In a lot of ways this library is more permissive. For example, * will match dotfiles and ** will simply match any character, so a pattern like **cd will intersect with /abcd while the glob match itself would fail.

Please see the tests for more examples.

Supported glob features:

  1. * matches any number of non / character
  2. ** matches any number of characters
  3. ? maches exactly one non / character
  4. {a,b} matches either a or b and brackets can be nested

Any and all issue reports are appreciated!

About

Find the intersection of two glob patterns

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages