You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Presumably this was decided because there is a cost to the JS runtime compiling the regex upfront which doesn't need to happen if it's contained in the function, this would only happen when the function is called?
Would it make more sense to have a singleton API e.g
Global RegExps are stateful through the .lastIndex property. Exporting a function that gives consumers a fresh RegExp means they don't have to worry about this.
I noticed you've decided to use a factory pattern rather just a plain export. eg.
Presumably this was decided because there is a cost to the JS runtime compiling the regex upfront which doesn't need to happen if it's contained in the function, this would only happen when the function is called?
Would it make more sense to have a singleton API e.g
Or is the cost for compiling the regex only paid the first time the factory is called and subsequent calls are negligible?
The text was updated successfully, but these errors were encountered: