Numeric ids for generateGuid: timestamp + random
This commit is contained in:
@ -471,18 +471,21 @@ var digestMopidyImages = exports.digestMopidyImages = function digestMopidyImage
|
|||||||
};
|
};
|
||||||
|
|
||||||
var generateGuid = exports.generateGuid = function generateGuid() {
|
var generateGuid = exports.generateGuid = function generateGuid() {
|
||||||
var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'xxxxxxxxxxxx';
|
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'numeric';
|
||||||
|
|
||||||
// numeric
|
// numeric
|
||||||
return new Date().valueOf() + Math.random();
|
if (type == 'numeric') {
|
||||||
|
var date = new Date().valueOf().toString();
|
||||||
// alpha-numeric
|
var random_number = Math.floor(Math.random() * 100).toString();
|
||||||
/*
|
return parseInt(date + random_number);
|
||||||
return format.replace(/[xy]/g, function(c){
|
} else {
|
||||||
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
|
var format = 'xxxxxxxxxx';
|
||||||
return v.toString(16);
|
return format.replace(/[xy]/g, function (c) {
|
||||||
});
|
var r = Math.random() * 16 | 0,
|
||||||
*/
|
v = c == 'x' ? r : r & 0x3 | 0x8;
|
||||||
|
return v.toString(16);
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var getCurrentPusherConnection = exports.getCurrentPusherConnection = function getCurrentPusherConnection(connections, connectionid) {
|
var getCurrentPusherConnection = exports.getCurrentPusherConnection = function getCurrentPusherConnection(connections, connectionid) {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -204,17 +204,19 @@ export let digestMopidyImages = function(mopidy, images){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export let generateGuid = function(format = 'xxxxxxxxxxxx'){
|
export let generateGuid = function(type = 'numeric'){
|
||||||
// numeric
|
// numeric
|
||||||
return new Date().valueOf() + Math.random();
|
if (type == 'numeric'){
|
||||||
|
var date = new Date().valueOf().toString();
|
||||||
// alpha-numeric
|
var random_number = Math.floor((Math.random() * 100)).toString();
|
||||||
/*
|
return parseInt(date+random_number);
|
||||||
return format.replace(/[xy]/g, function(c){
|
} else {
|
||||||
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
|
var format = 'xxxxxxxxxx';
|
||||||
return v.toString(16);
|
return format.replace(/[xy]/g, function(c){
|
||||||
});
|
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
|
||||||
*/
|
return v.toString(16);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export let getCurrentPusherConnection = function(connections, connectionid){
|
export let getCurrentPusherConnection = function(connections, connectionid){
|
||||||
|
|||||||
Reference in New Issue
Block a user