wearefractal/glob-stream — pull request #33 by UltCombo (2015-01-01 02:49:53+00:00)
Title: Create Minimatch instances for each negative glob only once

This optimizes use cases such as `['a', 'b', '!b']`, where a new Minimatch instance for `'!b'` would be created for each previous positive glob.

Now the Minimatch instances for negative globs are created beforehand, thus positive globs can use the same negative matcher instances. That is, for `['a', 'b', '!b']` both `'a'` and `'b'` globs will use the same Minimatch instance for `'!b'` instead of instantiating their own.

Also, as far as I can see, `gs.createStream` is internal (no docs or tests), so I took the liberty of adapting it a bit as I needed the complete `opt` object to pass to the Minimatch constructor in `gs.create`.

Should also note that, theoretically, this would instantiate Minimatch instances that would never be used when considering leading negative globs (e.g. `['!b', 'b']`), but that is a complete misuse and IIRC Minimatch produces their underlying regex lazily, so this shouldn't be a problem.