Multi selection combos working
This commit is contained in:
@@ -11,3 +11,27 @@ export function normalizeFilteredText(string) {
|
||||
export function filterMatches(text, potentialMatch) {
|
||||
return normalizeFilteredText(text).includes(normalizeFilteredText(potentialMatch))
|
||||
}
|
||||
|
||||
export function toSentence(array, options = {}) {
|
||||
const defaultConnectors = {
|
||||
words_connector: ", ",
|
||||
two_words_connector: " and ",
|
||||
last_word_connector: ", and "
|
||||
}
|
||||
|
||||
const connectors = { ...defaultConnectors, ...options }
|
||||
|
||||
if (array.length === 0) {
|
||||
return ""
|
||||
}
|
||||
|
||||
if (array.length === 1) {
|
||||
return array[0]
|
||||
}
|
||||
|
||||
if (array.length === 2) {
|
||||
return array.join(connectors.two_words_connector)
|
||||
}
|
||||
|
||||
return array.slice(0, -1).join(connectors.words_connector) + connectors.last_word_connector + array[array.length - 1]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user