Merge branch 'master' of https://github.com/pioardi/node-pool
[poolifier.git] / lib / util.js
CommitLineData
a32e02ba 1/**
2 * Contains utility functions
3 * @author Alessandro Pio Ardizio
4 * @since 0.0.1
5 */
6
7const uuid = require('uuid/v4')
8/**
9 * Return an id to be associated to a node.
10 */
11module.exports.generateID = () => {
12 return uuid()
13}
bf962cba 14
15module.exports.randomWorker = (collection) => {
16 const keys = Array.from(collection.keys())
17 return keys[Math.floor(Math.random() * keys.length)]
18}