summaryrefslogtreecommitdiff
path: root/src/util.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.js')
-rw-r--r--src/util.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/util.js b/src/util.js
index 9f52551..4e23d9d 100644
--- a/src/util.js
+++ b/src/util.js
@@ -8,3 +8,9 @@ export function create(obj, proto=Object.prototype) {
return Object.create(proto, props);
};
+
+
+export function random_choice(collection, r) {
+ const idx = Math.floor(collection.length * r);
+ return collection[idx];
+}