diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-06-19 19:50:38 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-06-20 10:01:03 -0300 |
commit | e254ad385d33739d3e6b4a04d79325e2bca840b8 (patch) | |
tree | 59b777282e761b1bf010a76bd29877cc37dde533 /src | |
parent | 00e933a0c0a6d85459576e7536f586b07cb51377 (diff) |
sugar: pick
Diffstat (limited to 'src')
-rw-r--r-- | src/util/sugar.js | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/util/sugar.js b/src/util/sugar.js index 3fa3fb46..3c5c2e9a 100644 --- a/src/util/sugar.js +++ b/src/util/sugar.js @@ -60,6 +60,11 @@ export function repeat(times, array) { return out; } +// Gets a random item from an array. +export function pick(array) { + return array[Math.floor(Math.random() * array.length)]; +} + // Gets the item at an index relative to another index. export function atOffset(array, index, offset, { wrap = false, |