aboutsummaryrefslogtreecommitdiff
path: root/js/components/core
diff options
context:
space:
mode:
authorPierre Frisch2011-12-22 07:25:50 -0800
committerValerio Virgillito2012-01-27 11:18:17 -0800
commitb89a7ee8b956c96a1dcee995ea840feddc5d4b27 (patch)
tree0f3136ab0ecdbbbed6a83576581af0a53124d6f1 /js/components/core
parent2401f05d1f4b94d45e4568b81fc73e67b969d980 (diff)
downloadninja-b89a7ee8b956c96a1dcee995ea840feddc5d4b27.tar.gz
First commit of Ninja to ninja-internal
Signed-off-by: Valerio Virgillito <rmwh84@motorola.com>
Diffstat (limited to 'js/components/core')
-rw-r--r--js/components/core/class-uuid.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/js/components/core/class-uuid.js b/js/components/core/class-uuid.js
new file mode 100644
index 00000000..31175a4a
--- /dev/null
+++ b/js/components/core/class-uuid.js
@@ -0,0 +1,45 @@
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 components/core/class-uuid
13 @requires montage/core/core
14*/
15/**
16 @class components/core/class-uuid.ClassUuid
17 @extends module:montage/core/core.Montage
18 */
19var Montage = require("montage/core/core").Montage,
20 CHARS = '0123456789ABCDEF'.split(''),
21 FORMAT = 'xxxxx'.split(''),
22
23 ClassUuid = exports.ClassUuid = Montage.create(Montage,/** @lends module:montage/core/class-uuid.ClassUuid# */ {
24
25/**
26 Returns a univerally unique ID (UUID).
27 @function
28 @param {Property} argument TODO
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
42 return id.join('');
43 }
44 }
45 });