From b89a7ee8b956c96a1dcee995ea840feddc5d4b27 Mon Sep 17 00:00:00 2001 From: Pierre Frisch Date: Thu, 22 Dec 2011 07:25:50 -0800 Subject: First commit of Ninja to ninja-internal Signed-off-by: Valerio Virgillito --- js/components/core/class-uuid.js | 45 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 js/components/core/class-uuid.js (limited to 'js/components/core/class-uuid.js') 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 @@ +/* + This file contains proprietary software owned by Motorola Mobility, Inc.
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ +/* + Code from node-uuid: https://github.com/broofa/node-uuid/raw/master/uuid.js
+ MIT license https://github.com/broofa/node-uuid/blob/master/LICENSE.md
+
*/ + +/** + @module components/core/class-uuid + @requires montage/core/core +*/ +/** + @class components/core/class-uuid.ClassUuid + @extends module:montage/core/core.Montage + */ +var Montage = require("montage/core/core").Montage, + CHARS = '0123456789ABCDEF'.split(''), + FORMAT = 'xxxxx'.split(''), + + ClassUuid = exports.ClassUuid = Montage.create(Montage,/** @lends module:montage/core/class-uuid.ClassUuid# */ { + +/** + Returns a univerally unique ID (UUID). + @function + @param {Property} argument TODO + @returns {String} The UUID. + */ + generate: { + enumerable: false, + value: function generate(argument) { + var c = CHARS, id = FORMAT, r; + + id[0] = c[(r = Math.random() * 0x100000000) & 0xf]; + id[1] = c[(r >>>= 4) & 0xf]; + id[2] = c[(r >>>= 4) & 0xf]; + id[3] = c[(r >>>= 4) & 0xf]; + id[4] = c[(r >>>= 4) & 0xf]; + + return id.join(''); + } + } + }); -- cgit v1.2.3