Skip to content

Commit

Permalink
Use phosphorjs to generate the UUID instead of our own code.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasongrout committed Nov 7, 2017
1 parent 711c85a commit 8fa2eec
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions packages/base/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import {
toByteArray, fromByteArray
} from 'base64-js';

import {
UUID
} from '@phosphor/coreutils';

import _isEqual = require('lodash/isEqual');
import isPlainObject = require('lodash/isPlainObject');

Expand Down Expand Up @@ -40,19 +44,13 @@ let assign = (Object as any).assign || function(t) {
};

/**
* Generate a UUID
*
* http://www.ietf.org/rfc/rfc4122.txt
*/
export
function uuid(): string {
let s = [];
const hexDigits = '0123456789ABCDEF';
for (let i = 0; i < 32; i++) {
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
}
s[12] = '4'; // bits 12-15 of the time_hi_and_version field to 0010
s[16] = hexDigits.substr((s[16] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01

return s.join('');
return UUID.uuid4();
}

/**
Expand Down

0 comments on commit 8fa2eec

Please # to comment.