Repository navigation
Conversation
…n include nodejs native function
| /* eslint-enable no-control-regex */ | ||
| // $1 matches the valid-range char if captured, or '' otherwise | ||
| // So this removes all invalid UTF-8 | ||
| return _(output.replace(validUtf8, '$1').split(/[\r\n]+/)) |
There was a problem hiding this comment.
Here, we just remove the lodash wrapper. This was never necessary for the code to work.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1240 +/- ##
==========================================
- Coverage 96.09% 96.08% -0.02%
==========================================
Files 29 29
Lines 2201 2195 -6
==========================================
- Hits 2115 2109 -6
Misses 86 86 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| if (!mod.tags) mod.tags = []; | ||
| mod.tags.push(name); | ||
|
|
||
| let excludeTagMatches = _.intersection(options.excludeTags, mod.tags); |
There was a problem hiding this comment.
The lodash code uses the intersection. In our case, due to we have only two sets, with a filder and include, we can easily find the common parts
| } | ||
|
|
||
| if (context.module && context.module.envVar) { | ||
| _.forEach(context.module.envVar, (val, key) => { |
There was a problem hiding this comment.
this could also be a for loop. Nothing tricky, we just iterate over the values of the object, and we assigned them to the options.env object.
| } | ||
|
|
||
| isObjectMatch(obj) { | ||
| return _.some(obj, (value, key) => { |
There was a problem hiding this comment.
Because there is no check if it is actually an object or not from the .some function, first we set a default value {} which will return false in that case. Its the same as if we had an if statement before the .some, which would check whether is an object or not and continue or return a false value accordingly.
Summary
The majority of lodash functions, can be replaced from the Node.js native ones. Here is a reference which helped me with the lodash replacement process, and it can also help with the review process https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore
On this PR, we remove lodash from the dependencies of the CITGM, this means:
~1.4mbLodash is a good candidate to be removed from the citgm dependencies as:
lookup.jsonfile, so there is no need for testing it implicitly (by using it on citgm)const modulesTap = _.map(modules, generateTest).join('\n');--- converts - to --->modules.map(generateTest).join('\n');Its commit, has the class of the functions that it replaces e.g one commit replaces the
_.fliterwith thearray.filter, the other the_.mapwith thearray.mapetc.In addition, I'll add below comments, on each change that is not so obvious.
Last but not least, all the tests pass, without needing any adjustment, this is expected.
Checklist
npm testpasseshere