Depending on how strict your requirements are, I often just use: Date.now.toString(36) + "-" + (Math.random() * 0x10000000).toString(36)
Date.now is unique every ms and Math.random has a keyspace of 2^32, so collisions are statistically impossible in most practical applications. On Mon, Aug 6, 2012 at 1:01 PM, Rick Waldron <[email protected]> wrote: > > On Monday, August 6, 2012 at 1:38 PM, Martin Cooper wrote: > > On Mon, Aug 6, 2012 at 10:28 AM, Ted Young <[email protected]> wrote: > > Hey y'all, > > So, I have a need for global unique id's. Googling about, I've found the > following implementations that seem decent: > > https://github.com/broofa/node-uuid > > > FWIW, this is the package that npm uses. > > +1 > > I've been using Robert Keiffer's impl in projects since before it was even > on npm—I consider it a "go to" > > Rick > > > -- > Martin Cooper > > > https://gist.github.com/1308368 > > Not really sure why I would pick one over the other (besides file size), or > if there are any js-specific issues I should be aware of. Any advice? > > Cheers, > > Ted > > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en > > > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en > > > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
