2014-05-23 18:14:06 +00:00
|
|
|
function guid() {
|
|
|
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
|
|
|
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
|
|
|
|
return v.toString(16);
|
|
|
|
}).toUpperCase();
|
|
|
|
}
|
2013-05-31 01:38:44 +00:00
|
|
|
|
2014-05-23 18:14:06 +00:00
|
|
|
function nop() {}
|
2013-05-31 01:38:44 +00:00
|
|
|
|
2014-05-23 18:14:06 +00:00
|
|
|
/**
|
|
|
|
* Convert a Uint8Array to a regular array
|
|
|
|
*/
|
|
|
|
function u8toArray(u8) {
|
|
|
|
var array = [];
|
|
|
|
var len = u8.length;
|
|
|
|
for(var i = 0; i < len; i++) {
|
|
|
|
array[i] = u8[i];
|
2013-11-08 20:33:44 +00:00
|
|
|
}
|
2014-05-23 18:14:06 +00:00
|
|
|
return array;
|
|
|
|
}
|
2013-05-31 01:38:44 +00:00
|
|
|
|
2014-05-23 18:14:06 +00:00
|
|
|
module.exports = {
|
|
|
|
guid: guid,
|
|
|
|
u8toArray: u8toArray,
|
|
|
|
nop: nop
|
|
|
|
};
|