Skip to content
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

Merged
merged 11 commits into from
Jun 10, 2023
Merged

Chore/sof 6463 #45

merged 11 commits into from
Jun 10, 2023

Conversation

azech-hqs
Copy link
Contributor

This PR concerns:

  • isolation & refactoring of filter functions
  • isolation of other utility functions

@azech-hqs azech-hqs changed the base branch from main to chore/SOF-6505 May 29, 2023 12:15
* @param {Array<{path: string}|{regex: RegExp}>} filterObjects - Filter conditions
* @return {boolean}
*/
function isMultiPathSupported(pathObject, multiPathSeparator, filterObjects) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*/
function isPathSupported(pathObject, filterObjects) {
return (
lodash.find(filterObjects, (filterObj) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*/
function isMultiPathSupported(pathObject, multiPathSeparator, filterObjects) {
const expandedPaths = pathObject.path.split(multiPathSeparator).map((p) => ({ path: p }));
return lodash.every(expandedPaths, (obj) => isPathSupported(obj, filterObjects));
Copy link
Contributor

@unsigned6 unsigned6 Jun 1, 2023

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;    

Copy link
Contributor Author

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));

Copy link
Contributor

@unsigned6 unsigned6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

Base automatically changed from chore/SOF-6505 to main June 1, 2023 09:31
@azech-hqs azech-hqs merged commit 31accf1 into main Jun 10, 2023
@azech-hqs azech-hqs deleted the chore/SOF-6463 branch June 10, 2023 10:50
k0stik pushed a commit that referenced this pull request Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants