diff options
author | Florrie <towerofnix@gmail.com> | 2017-08-11 19:40:31 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2017-08-11 19:40:31 -0300 |
commit | 4222e4f96eef533cfd4357fe64743ba740ee4065 (patch) | |
tree | 9a818e05b9d8fc0a62adca8453f0a590dfffdb2f | |
parent | e61800db022691cb0024dd7690fa8823daaf8ede (diff) |
Throw errors when a bad sort/loop mode is given
-rw-r--r-- | src/pickers.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/pickers.js b/src/pickers.js index 190532c..f44a675 100644 --- a/src/pickers.js +++ b/src/pickers.js @@ -28,6 +28,20 @@ function makePicker(grouplike, sort, loop) { // // Both of those options could probably be handled via the 'loop' option. + if (![ + 'order', 'ordered', 'shuffle', 'shuffled', 'shuffle-groups', + 'shuffled-groups' + ].includes(sort)) { + throw new Error(`Invalid sort mode: ${sort}`) + } + + if (![ + 'loop', 'no-loop', 'no', 'loop-same-order', 'loop-regenerate', + 'pick-random' + ].includes(loop)) { + throw new Error(`Invalid loop mode: ${loop}`) + } + const topLevel = {items: []} let generateTopLevel = () => { |