Commit 9d0cd3e9 authored by Miguel de la Cruz's avatar Miguel de la Cruz Committed by Miguel de la Cruz

[MM-14881] Replace flatMap with a reducer (#809)

parent 727a285f
......@@ -108,8 +108,12 @@ export function getSuggestionsSplitBy(term: string, splitStr: string): Array<str
}
export function getSuggestionsSplitByMultiple(term: string, splitStrs: Array<string>): Array<string> {
// $FlowFixMe - Array.flatMap is not yet implemented in Flow
return [...new Set(splitStrs.flatMap((splitStr) => getSuggestionsSplitBy(term, splitStr)))];
const suggestions = splitStrs.reduce((acc, val) => {
getSuggestionsSplitBy(term, val).forEach((suggestion) => acc.add(suggestion));
return acc;
}, new Set());
return [...suggestions];
}
export function filterProfilesMatchingTerm(users: Array<UserProfile>, term: string): Array<UserProfile> {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment