glob-object
glob-object copied to clipboard
skipped patterns when multiple negations exists
The example from this filter-object issue shows that some of the patterns are being skipped when there are multiple negation patterns.
This line just needs to be updated to patterns.splice(1, i--); so the i is "fixed" after the splicing happens.
@kilianc I'll try to get to this, but if you can do a PR first, we'd appreciate it. Thanks!
@doowb patterns.splice(1, i--); would result in an infinite loop. I think it's a bad idea to alter the index in a for loop :/
Not in this case, because patterns.splice(1, i) is removing an item, then the i++ in the for loop effectively skips the next item in the patterns array. Adding the i-- just makes up for making the patterns array shorter.
I tried it locally and it returned the expected results with your example. I just didn't have the time tonight to update the tests for this use case.