Commit 8c04f90d authored by Tristan Cavelier's avatar Tristan Cavelier

generateUuid method moved to storage.js

parent 5821e278
var jio = function(spec) { var jio = function(spec) {
var generateUuid = function () {
var S4 = function () {
var i, string = Math.floor(
Math.random() * 0x10000 /* 65536 */
).toString(16);
for (i = string.length; i < 4; i += 1) {
string = '0'+string;
}
return string;
};
return S4() + S4() + "-" +
S4() + "-" +
S4() + "-" +
S4() + "-" +
S4() + S4() + S4();
};
...@@ -14,6 +14,28 @@ var storage = function(spec, my) { ...@@ -14,6 +14,28 @@ var storage = function(spec, my) {
} }
}); });
/**
* Generate a new uuid
* @method generateUuid
* @return {string} The new uuid
*/
that.generateUuid = function () {
var S4 = function () {
var i, string = Math.floor(
Math.random() * 0x10000 /* 65536 */
).toString(16);
for (i = string.length; i < 4; i += 1) {
string = '0'+string;
}
return string;
};
return S4() + S4() + "-" +
S4() + "-" +
S4() + "-" +
S4() + "-" +
S4() + S4() + S4();
};
/** /**
* Generates a hash code of a string * Generates a hash code of a string
* @method hashCode * @method hashCode
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment