All files / services util.ts

100% Statements 8/8
83.33% Branches 5/6
100% Functions 2/2
100% Lines 8/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 203x               9x 9x 9x   9x 279x 279x 279x        
export default new class Util {
 
  /***
   * Generates a uuid
   * RFC4122 version 4 complient
   * https://stackoverflow.com/a/8809472/7529287
   */
  generateUUID(): string {
    var d = new Date().getTime();
    Eif (typeof performance !== 'undefined' && typeof performance.now === 'function'){
        d += performance.now();
    }
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
        var r = (d + Math.random() * 16) % 16 | 0;
        d = Math.floor(d / 16);
        return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
    });
  }
 
}