Uh oh!
There was an error while loading. Please reload this page.
Improved solution to issue #179 (invalid options throwing errors in joinRegExp) - #180
Conversation
…rors in joinRegExp)
This slightly more robust solution ignores options that are not strings
or regular expressions in the passed patterns array.
The prior solution still accepted non-string, non-regexp options (e.g.
[], {}, true, etc.).
Credit goes to @soundslocke for the fix.There was a problem hiding this comment.
Is it necessary to check again for isUndefined? Wouldn't just patterns[i] && patterns[i].source be enough?
mattrobenolt
commented
Jan 11, 2014
|
johnbacon
commented
Jan 11, 2014
I have no problem moving to a normal for loop and away from The changes will be pushed again soon. |
```unshift``` is significantly slower than ```push```. Shift towards using ```push``` and remove a redundant conditional.
Likely [benefits](http://stackoverflow.com/questions/6261953/do-modern-javascript-jiters-need-array-length-caching-in-loops) the performance of older browsers that lack smart caching. Thanks again to @soundslocke for the heads up.
mattrobenolt
commented
Jan 12, 2014
This looks sensible to me. Thanks for the contribution! 👍 I'll cut a new release today. |
Improved solution to issue #179 (invalid options throwing errors in joinRegExp)
This slightly more robust solution ignores options that are not strings
or regular expressions in the passed patterns array.
The prior solution still accepted non-string, non-regexp options (e.g.
[], {}, true, etc.).
Credit goes to @soundslocke for the fix.