UUID Generation #1

Closed
genejones opened this Issue Oct 29, 2013 · 1 comment

Comments

Projects
None yet
2 participants

I noticed you have a custom function generateUUID. Why not use node-uuid instead?

Math.random sometimes causes collisions, and node-uuid avoids them while taking advantage of the Node-JS crypto API to be more secure. It also supports timestamp based UUIDs, which might be more applicable to a scheduling library.

See the below, starting at line 169 in https://github.com/rschmukler/agenda/blob/master/lib/agenda.js

function generateUUID() {
   'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
     var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
     return v.toString(16);
    });
}
Collaborator

rschmukler commented Oct 29, 2013

Haha actually, I don't even use that function. I thought I'd want it but ended up deciding against it. Thanks for the good eye though. I fixed/removed this is 0.1.1.

rschmukler closed this Oct 29, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment