-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove uses of lodash/isRegExp #5180
Conversation
I'm curious, is there a specific goal in mind? I was for the others because I usually prefer natives if it is easy, but this case is less obvious because of the realm issues, and manually writing |
I think all of lo-dash can actually be removed (only |
Current coverage is 89.22% (diff: 100%)@@ master #5180 diff @@
==========================================
Files 203 203
Lines 9835 9839 +4
Methods 1071 1073 +2
Messages 0 0
Branches 2620 2620
==========================================
+ Hits 8775 8779 +4
Misses 1060 1060
Partials 0 0
|
Underscore uses: // Is the given value a regular expression?
_.isRegExp = function(obj) {
return !!(obj && obj.test && obj.exec && (obj.ignoreCase || obj.ignoreCase === false));
}; I think checking for |
After thinking about it some more, I think the |
@@ -65,7 +64,7 @@ export function regexify(val: any): RegExp { | |||
return new RegExp(regex.source.slice(1, -1), "i"); | |||
} | |||
|
|||
if (isRegExp(val)) { | |||
if (_isRegExp(val)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If think if we use a function there, we could use the lodash function.
I'll leave this change for last. It'll be clearer that keeping |
Continuing the gradual reduction in lodash use. This is not exactly like lodash's implementation. In Node it defers to
util.isRegExp
, which is cross-realm safe. In Browsers it does aObject.prototype.toString.call(value) === '[object RegExp]'
. I'm fine with switching to thetoString
approach.