Use integer as userId instead of String

This commit is contained in:
Kevin Jahns
2017-07-13 00:37:35 +02:00
parent cd3f4a72d6
commit 3c317828d1
14 changed files with 89 additions and 658 deletions

View File

@@ -1,3 +1,5 @@
/* global crypto */
/*
EventHandler is an helper class for constructing custom types.
@@ -818,8 +820,10 @@ export default function Utils (Y) {
}
Y.utils.createSmallLookupBuffer = createSmallLookupBuffer
// Generates a unique id, for use as a user id.
// Thx to @jed for this script https://gist.github.com/jed/982883
function generateGuid(a){return a?(a^Math.random()*16>>a/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,generateGuid)} // eslint-disable-line
Y.utils.generateGuid = generateGuid
function generateUserId () {
let arr = new Uint32Array(1)
crypto.getRandomValues(arr)
return arr[0]
}
Y.utils.generateUserId = generateUserId
}