-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Faster, more readable, less nested and more consistent function #1454
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1454 +/- ##
==========================================
- Coverage 99.92% 99.92% -0.01%
==========================================
Files 95 95
Lines 1268 1265 -3
==========================================
- Hits 1267 1264 -3
Misses 1 1
Continue to review full report at Codecov.
|
@profnandaa It was my pleasure to contribute to a library that is so vastly used! 😍 |
@siddharthborderwala -- see if you can address the code coverage drop issue... |
@profnandaa I generated the report locally and checked it, turns out the coverage issue is because of Line 89 in src/lib/isTaxID.js, apparently it is not getting hit according to the coverage report. |
I see, thanks! I think we will have this addressed in an open related PR. |
Sounds okay. After updating this code, I ran |
@profnandaa Could you please label this pull request as hacktoberfest-accepted , I would appreciate that a lot, thanks! |
@siddharthborderwala -- thanks. Sure, the whole repo is opted into hacktoberfest, so this should count after landing even without the tag; let me know if it works. |
@profnandaa I have updated the assertString utility function in src/lib/util/assertString.js.



The new function is more readable and has less nesting. It has less if/else nesting and also has a consistent error message (previously some error messages have "... received a [invalidType]" and some of them have "... received [invalidType]", now it is always "... received a [invalidType]").
I measured performances of the current function and the new function, it's a small margin but the new function is faster by 0.006 to 0.01 milliseconds on an average.