Added an emitter to the dynamic pool , example splitted and improved
[poolifier.git] / lib / util.js
index 70a50744d684ef562eeae9ca9a5902feb5c27f72..bac53ec46c75c78cbe9d7b8b31a60fd6d8d2bd64 100644 (file)
@@ -11,3 +11,8 @@ const uuid = require('uuid/v4')
 module.exports.generateID = () => {
   return uuid()
 }
+
+module.exports.randomWorker = (collection) => {
+  const keys = Array.from(collection.keys())
+  return keys[Math.floor(Math.random() * keys.length)]
+}