File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change 10
10
*/
11
11
12
12
import Storage from './Storage' ;
13
- const uuidv4 = require ( 'uuid/v4' ) ;
13
+ let uuidv4 = null ;
14
+ if ( process . env . PARSE_BUILD === 'weapp' ) {
15
+ uuidv4 = require ( './uuid.weapp' ) ;
16
+ } else {
17
+ uuidv4 = require ( 'uuid/v4' ) ;
18
+ }
14
19
15
20
let iidCache = null ;
16
21
Original file line number Diff line number Diff line change
1
+ function uuid ( ) {
2
+ const s = [ ] ;
3
+ const hexDigits = '0123456789abcdef' ;
4
+
5
+ for ( let i = 0 ; i < 36 ; i ++ ) {
6
+ s [ i ] = hexDigits . substr ( Math . floor ( Math . random ( ) * 0x10 ) , 1 ) ;
7
+ }
8
+
9
+ s [ 14 ] = '4' ; // bits 12-15 of the time_hi_and_version field to 0010
10
+ s [ 19 ] = hexDigits . substr ( ( s [ 19 ] & 0x3 ) | 0x8 , 1 ) ; // bits 6-7 of the clock_seq_hi_and_reserved to 01
11
+ s [ 8 ] = s [ 13 ] = s [ 18 ] = s [ 23 ] = '-' ;
12
+
13
+ const uuid = s . join ( '' ) ;
14
+ return uuid ;
15
+ }
16
+
17
+ module . exports = uuid ;
You can’t perform that action at this time.
0 commit comments