-
Notifications
You must be signed in to change notification settings - Fork 0
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
Chore/sof 6463 #45
Chore/sof 6463 #45
Conversation
* @param {Array<{path: string}|{regex: RegExp}>} filterObjects - Filter conditions | ||
* @return {boolean} | ||
*/ | ||
function isMultiPathSupported(pathObject, multiPathSeparator, filterObjects) { |
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.
Maybe use npm https://www.npmjs.com/package/path
src/utils/filter.js
Outdated
*/ | ||
function isPathSupported(pathObject, filterObjects) { | ||
return ( | ||
lodash.find(filterObjects, (filterObj) => { |
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.
Nit, but: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some could also work
src/utils/filter.js
Outdated
*/ | ||
function isMultiPathSupported(pathObject, multiPathSeparator, filterObjects) { | ||
const expandedPaths = pathObject.path.split(multiPathSeparator).map((p) => ({ path: p })); | ||
return lodash.every(expandedPaths, (obj) => isPathSupported(obj, filterObjects)); |
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.
Could be done without lodash (few lines but the same with JS only):
for (const expandedPath of expandedPaths) {
if(!isPathSupported(expandedPath, filterObjects) return false;
}
retrun true;
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.
I used the following now, avoiding lodash and explicit for loops:
return expandedPaths.every((expandedPath) => isPathSupported(expandedPath, filterObjects));
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.
Looks good
This PR concerns: