UNPKG

371 BJavaScriptView Raw
1"use strict";
2
3const crypto = require('crypto');
4
5/**
6 * Helper method that generates a new user id.
7 *
8 * This method uses current timestamp and random number generator to come up
9 * with unique ids.
10 *
11 * @return {string}
12 */
13module.exports = function ()
14{
15 return `${crypto.randomBytes(4)
16 .toString('hex')}.${(Date.now() + Math.random())
17 .toString(26)}`;
18}