alice-renderer
Advanced tools
Comparing version 1.3.0 to 1.3.1
{ | ||
"name": "alice-renderer", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "Replies renderer for Yandex Alice skills", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -19,16 +19,10 @@ /** | ||
const select = arr => { | ||
if (config.disableRandom) return arr[0]; | ||
const key = hasUserId() && getKey(arr); | ||
return key | ||
? selectNextElement(arr, key) | ||
: selectRandomElement(arr); | ||
: getRandomElement(arr); | ||
}; | ||
/** | ||
* Like getRandomElement, but returns first item if disableRandom = true | ||
*/ | ||
const selectRandomElement = arr => { | ||
return config.disableRandom ? arr[0] : getRandomElement(arr); | ||
}; | ||
/** | ||
* Returns not-repeated array element. | ||
@@ -43,3 +37,3 @@ * For strings tries to select element with non-repeated words with prev element. | ||
const mostDifferentIndexes = getMostDifferentIndexes(excludedIndexes, allowedIndexes, arr); | ||
const index = selectRandomElement(mostDifferentIndexes); | ||
const index = getRandomElement(mostDifferentIndexes); | ||
savedIndexes.push(index); | ||
@@ -93,3 +87,5 @@ setValue(key, savedIndexes); | ||
// For array of strings build shorter key than JSON.stringify | ||
return isStrings(arr) ? buildKeyFromStrings(arr) : JSON.stringify(arr); | ||
return isStrings(arr) | ||
? buildKeyFromStrings(arr) | ||
: JSON.stringify(arr); | ||
} catch(e) { | ||
@@ -96,0 +92,0 @@ // in case of error, return empty key to fallback on getRandomElement() |
57730
823