make reverse option then use it

This commit is contained in:
Loren Norman 2024-12-09 15:45:17 -05:00
parent 4bdf149c4c
commit 9a38b7c739
2 changed files with 7 additions and 5 deletions

View file

@ -26,10 +26,7 @@ export default {
START: { options: makeOptions({ upTo: 60 }) },
END: {
options: makeOptions({ upTo: 60 }),
value: "59"
}
END: { options: makeOptions({ upTo: 60, reverse: true }) }
}
}]
],

View file

@ -1,4 +1,4 @@
import { filter, identity, map, range } from 'lodash-es'
import { filter, identity, map, range, reverse } from 'lodash-es'
const makeFactorsOf = target => {
@ -20,6 +20,7 @@ const stringifyOptions = (options) => {
* @param {number} [options.upTo]
* @param {number} [options.from]
* @param {number} [options.step]
* @param {boolean} [options.reverse]
* @param {Function} [options.valueFunc]
* @returns {Array}
*/
@ -41,6 +42,10 @@ export const makeOptions = (options = {}) => {
throw new Error(`No valid options sent to makeOptions: ${options}`)
}
if(options.reverse) {
optionValues = reverse(optionValues)
}
const
valueFunc = options.valueFunc || identity,
mappedValues = map(optionValues, labelValue =>