File tree 5 files changed +3278
-1
lines changed
5 files changed +3278
-1
lines changed Original file line number Diff line number Diff line change
1
+ {
2
+ "presets" : [" pundits" ]
3
+ }
Original file line number Diff line number Diff line change 4
4
"description" : " Simple UUID generation" ,
5
5
"main" : " index.js" ,
6
6
"scripts" : {
7
- "test" : " mocha test"
7
+ "test" : " mocha test" ,
8
+ "build" : " babel src -d build --source-maps inline"
8
9
},
9
10
"repository" : {
10
11
"type" : " git" ,
21
22
},
22
23
"homepage" : " https://github.com/TylerGarlick/simple-uuid" ,
23
24
"devDependencies" : {
25
+ "ava" : " ^0.19.1" ,
26
+ "babel-cli" : " ^6.24.1" ,
27
+ "babel-polyfill" : " ^6.23.0" ,
28
+ "babel-preset-pundits" : " ^2.0.3" ,
29
+ "babel-register" : " ^6.24.1" ,
24
30
"chai" : " ^1.10.0" ,
25
31
"lodash" : " ^2.4.1" ,
26
32
"mocha" : " ^2.1.0"
33
+ },
34
+ "ava" : {
35
+ "files" : [
36
+ " test/**/*.test.js"
37
+ ],
38
+ "source" : [
39
+ " **/*.{js,jsx}" ,
40
+ " !dist/**/*"
41
+ ],
42
+ "concurrency" : 5 ,
43
+ "failFast" : true ,
44
+ "failWithoutAssertions" : false ,
45
+ "tap" : true ,
46
+ "powerAssert" : false ,
47
+ "require" : [
48
+ " babel-register"
49
+ ],
50
+ "babel" : " inherit"
27
51
}
28
52
}
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Generate a UUID
3
+ * @returns {string }
4
+ */
5
+ export default ( ) => {
6
+ const lut = [ ] ;
7
+ for ( let i = 0 ; i < 256 ; i ++ ) {
8
+ lut [ i ] = ( i < 16 ? '0' : '' ) + ( i ) . toString ( 16 ) ;
9
+ }
10
+
11
+ const d0 = Math . random ( ) * 0xffffffff | 0 ;
12
+ const d1 = Math . random ( ) * 0xffffffff | 0 ;
13
+ const d2 = Math . random ( ) * 0xffffffff | 0 ;
14
+ const d3 = Math . random ( ) * 0xffffffff | 0 ;
15
+
16
+ return lut [ d0 & 0xff ] + lut [ d0 >> 8 & 0xff ] + lut [ d0 >> 16 & 0xff ] + lut [ d0 >> 24 & 0xff ] + '-' +
17
+ lut [ d1 & 0xff ] + lut [ d1 >> 8 & 0xff ] + '-' + lut [ d1 >> 16 & 0x0f | 0x40 ] + lut [ d1 >> 24 & 0xff ] + '-' +
18
+ lut [ d2 & 0x3f | 0x80 ] + lut [ d2 >> 8 & 0xff ] + '-' + lut [ d2 >> 16 & 0xff ] + lut [ d2 >> 24 & 0xff ] +
19
+ lut [ d3 & 0xff ] + lut [ d3 >> 8 & 0xff ] + lut [ d3 >> 16 & 0xff ] + lut [ d3 >> 24 & 0xff ] ;
20
+ } ;
Original file line number Diff line number Diff line change
1
+ import Test from 'ava' ;
2
+
3
+ Test ( 'generates' , t => {
4
+ t . truthy ( true ) ;
5
+ } ) ;
You can’t perform that action at this time.
0 commit comments