3 * @copyright 2013 Arunjit Singh <opensrc@ajsd.in>. All Rights Reserved.
4 * @license MIT; see LICENCE.
5 * [https://github.com/ajsd/angular-uuid.git]
12 angular.module('uuid', []).service('uuid4', function() {
13 /**! http://stackoverflow.com/a/2117523/377392 */
14 var fmt = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
15 this.generate = function() {
16 return fmt.replace(/[xy]/g, function(c) {
17 var r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8);
18 return v.toString(16);