diff options
Diffstat (limited to 'node_modules/montage/core/uuid.js')
-rwxr-xr-x | node_modules/montage/core/uuid.js | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/node_modules/montage/core/uuid.js b/node_modules/montage/core/uuid.js new file mode 100755 index 00000000..d2642107 --- /dev/null +++ b/node_modules/montage/core/uuid.js | |||
@@ -0,0 +1,74 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | /* <notice> | ||
7 | Code from node-uuid: https://github.com/broofa/node-uuid/raw/master/uuid.js<br/> | ||
8 | MIT license https://github.com/broofa/node-uuid/blob/master/LICENSE.md<br/> | ||
9 | </notice> */ | ||
10 | |||
11 | /** | ||
12 | @module montage/core/uuid | ||
13 | @requires montage/core/core | ||
14 | */ | ||
15 | /** | ||
16 | @class module:montage/core/uuid.Uuid | ||
17 | @extends module:montage/core/core.Montage | ||
18 | */ | ||
19 | var Montage = require("montage").Montage, | ||
20 | CHARS = '0123456789ABCDEF'.split(''), | ||
21 | FORMAT = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.split(''), | ||
22 | |||
23 | Uuid = exports.Uuid = Montage.create(Montage,/** @lends module:montage/core/uuid.Uuid# */ { | ||
24 | |||
25 | /** | ||
26 | Returns a univerally unique ID (UUID). | ||
27 | @function | ||
28 | @param {Property} argument | ||
29 | @returns {String} The UUID. | ||
30 | */ | ||
31 | generate: { | ||
32 | enumerable: false, | ||
33 | value: function generate(argument) { | ||
34 | var c = CHARS, id = FORMAT, r; | ||
35 | |||
36 | id[0] = c[(r = Math.random() * 0x100000000) & 0xf]; | ||
37 | id[1] = c[(r >>>= 4) & 0xf]; | ||
38 | id[2] = c[(r >>>= 4) & 0xf]; | ||
39 | id[3] = c[(r >>>= 4) & 0xf]; | ||
40 | id[4] = c[(r >>>= 4) & 0xf]; | ||
41 | id[5] = c[(r >>>= 4) & 0xf]; | ||
42 | id[6] = c[(r >>>= 4) & 0xf]; | ||
43 | id[7] = c[(r >>>= 4) & 0xf]; | ||
44 | |||
45 | id[9] = c[(r = Math.random() * 0x100000000) & 0xf]; | ||
46 | id[10] = c[(r >>>= 4) & 0xf]; | ||
47 | id[11] = c[(r >>>= 4) & 0xf]; | ||
48 | id[12] = c[(r >>>= 4) & 0xf]; | ||
49 | id[15] = c[(r >>>= 4) & 0xf]; | ||
50 | id[16] = c[(r >>>= 4) & 0xf]; | ||
51 | id[17] = c[(r >>>= 4) & 0xf]; | ||
52 | |||
53 | id[19] = c[(r = Math.random() * 0x100000000) & 0x3 | 0x8]; | ||
54 | id[20] = c[(r >>>= 4) & 0xf]; | ||
55 | id[21] = c[(r >>>= 4) & 0xf]; | ||
56 | id[22] = c[(r >>>= 4) & 0xf]; | ||
57 | id[24] = c[(r >>>= 4) & 0xf]; | ||
58 | id[25] = c[(r >>>= 4) & 0xf]; | ||
59 | id[26] = c[(r >>>= 4) & 0xf]; | ||
60 | id[27] = c[(r >>>= 4) & 0xf]; | ||
61 | |||
62 | id[28] = c[(r = Math.random() * 0x100000000) & 0xf]; | ||
63 | id[29] = c[(r >>>= 4) & 0xf]; | ||
64 | id[30] = c[(r >>>= 4) & 0xf]; | ||
65 | id[31] = c[(r >>>= 4) & 0xf]; | ||
66 | id[32] = c[(r >>>= 4) & 0xf]; | ||
67 | id[33] = c[(r >>>= 4) & 0xf]; | ||
68 | id[34] = c[(r >>>= 4) & 0xf]; | ||
69 | id[35] = c[(r >>>= 4) & 0xf]; | ||
70 | |||
71 | return id.join(''); | ||
72 | } | ||
73 | } | ||
74 | }); | ||