Nit: unless you're specifically trying to distinguish null from undefined, our standard style is just `if (matchRanges || ...`

(OTOH, startingSpecial is a number and in cases like that IMHO it's clearer to write it out explicitly, e.g. `startingSpecial === 0`)