Skip to content

Commit

Permalink
#52 new util uniqueID
Browse files Browse the repository at this point in the history
  • Loading branch information
tracend committed Jul 21, 2013
1 parent d373029 commit 100ecf0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ var utils = {
// remove all special characters & spaces
safeString: function( string ){
return string.replace(/[^a-zA-Z0-9]/g,'');
},

// - Creates a unique id for identification purposes
uniqueID : function (separator) {

var delim = separator || "-";

function S4() {
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
}

return (S4() + S4() + delim + S4() + delim + S4() + delim + S4() + delim + S4() + S4() + S4());
}

};

0 comments on commit 100ecf0

Please sign in to comment.