JSPM

glob-intersection

0.1.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 57
  • Score
    100M100P100Q53926F
  • License MIT

Find the intersection of two glob patterns

Package Exports

  • glob-intersection

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (glob-intersection) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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!