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 --- node_modules/montage/core/uuid.js | 74 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100755 node_modules/montage/core/uuid.js (limited to 'node_modules/montage/core/uuid.js') 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 @@ +/* + 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 montage/core/uuid + @requires montage/core/core +*/ +/** + @class module:montage/core/uuid.Uuid + @extends module:montage/core/core.Montage + */ +var Montage = require("montage").Montage, + CHARS = '0123456789ABCDEF'.split(''), + FORMAT = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.split(''), + + Uuid = exports.Uuid = Montage.create(Montage,/** @lends module:montage/core/uuid.Uuid# */ { + +/** + Returns a univerally unique ID (UUID). + @function + @param {Property} argument + @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]; + id[5] = c[(r >>>= 4) & 0xf]; + id[6] = c[(r >>>= 4) & 0xf]; + id[7] = c[(r >>>= 4) & 0xf]; + + id[9] = c[(r = Math.random() * 0x100000000) & 0xf]; + id[10] = c[(r >>>= 4) & 0xf]; + id[11] = c[(r >>>= 4) & 0xf]; + id[12] = c[(r >>>= 4) & 0xf]; + id[15] = c[(r >>>= 4) & 0xf]; + id[16] = c[(r >>>= 4) & 0xf]; + id[17] = c[(r >>>= 4) & 0xf]; + + id[19] = c[(r = Math.random() * 0x100000000) & 0x3 | 0x8]; + id[20] = c[(r >>>= 4) & 0xf]; + id[21] = c[(r >>>= 4) & 0xf]; + id[22] = c[(r >>>= 4) & 0xf]; + id[24] = c[(r >>>= 4) & 0xf]; + id[25] = c[(r >>>= 4) & 0xf]; + id[26] = c[(r >>>= 4) & 0xf]; + id[27] = c[(r >>>= 4) & 0xf]; + + id[28] = c[(r = Math.random() * 0x100000000) & 0xf]; + id[29] = c[(r >>>= 4) & 0xf]; + id[30] = c[(r >>>= 4) & 0xf]; + id[31] = c[(r >>>= 4) & 0xf]; + id[32] = c[(r >>>= 4) & 0xf]; + id[33] = c[(r >>>= 4) & 0xf]; + id[34] = c[(r >>>= 4) & 0xf]; + id[35] = c[(r >>>= 4) & 0xf]; + + return id.join(''); + } + } + }); -- cgit v1.2.3