stephenlb / angularjs-chat

AngularJS Chat - Enable chat messaging experiences in your iOS, Android and Web apps.
https://stephenlb.github.io/angularjs-chat/
MIT License
73 stars 64 forks source link

Understanding uuid() #3

Closed IAmAnubhavSaini closed 2 years ago

IAmAnubhavSaini commented 8 years ago

Hi Stephen, could you please explain the significance of c == 'x' ? r : (r & 0x3 | 0x8); in case of c != 'x'?

Also, why have you used 4 and y?

stephenlb commented 7 years ago

I donno good question! This is just a ternary that increases histogram spread reducing the likelihood of generating a collision.

stephenlb commented 7 years ago

It is best to not use uuid() method and instead set your own user IDs based on your DB. But UUID is a good placeholder as a temporary User ID.

stephenlb commented 7 years ago

let me know if this helps!