UNPKG

@mikezimm/fps-core-v7

Version:

Library of reusable core interfaces, types and constants migrated from fps-library-v2

32 lines 1.86 kB
/** * Originally copied from Compliance web part 2023-03-28 * * @param suggestions * @param lowerCaseSuggestions - true will also convert the suggestions to suggestionsLC ( so buttons would show in lc ) * @returns */ export function convertSugsLC(suggestions, lowerCaseSuggestions, addSuggsToFinds) { suggestions.map(suggestion => { if (addSuggsToFinds === true) { suggestion.finds = [...suggestion.finds, ...suggestion.suggestions]; } suggestion.findsLC = suggestion.finds.map(str => { return str.toLowerCase(); }); if (suggestion.exclusions) suggestion.exclusionsLC = suggestion.exclusions.map(str => { return str.toLowerCase(); }); if (lowerCaseSuggestions === true) suggestion.suggestionsLC = suggestion.suggestions.map(str => { return str.toLowerCase(); }); // Added this for https://github.com/mikezimm/Compliance/issues/169 to clean up any duplicates const finds = suggestion.finds.filter((element, index) => { return suggestion.finds.indexOf(element) === index; }); suggestion.finds = finds; const singleSuggs = suggestion.suggestions.filter((element, index) => { return suggestion.suggestions.indexOf(element) === index; }); suggestion.suggestions = singleSuggs; // 2024-09-22: Added this to pass typing const suggestionFindsLC = suggestion.findsLC; const findsLC = suggestion.findsLC.filter((element, index) => { return suggestionFindsLC.indexOf(element) === index; }); suggestion.findsLC = findsLC; const suggestionsLC = suggestionFindsLC.filter((element, index) => { return suggestionFindsLC.indexOf(element) === index; }); suggestion.suggestionsLC = suggestionsLC; }); return suggestions; } //# sourceMappingURL=convertSugsLC.js.map