File tree Expand file tree Collapse file tree 4 files changed +32
-5
lines changed Expand file tree Collapse file tree 4 files changed +32
-5
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "trailingComma": "es5",
3+ "tabWidth": 2,
4+ "semi": true,
5+ "singleQuote": true
6+ }
Original file line number Diff line number Diff line change 66## 1.3.1 <small >- Jun 19, 2020</small >
77
88- Fixes issue with iOS 9 ([ #15 ] ( https://github.com/jchook/uuid-random/issues/15 ) )
9+ - Fixes issue with ` test() ` case-sensitivity ([ #17 ] ( https://github.com/jchook/uuid-random/issues/17 ) )
10+ - Improves tests
911- Improves benchmarks
1012
1113
Original file line number Diff line number Diff line change 3131 // Test for uuid
3232 uuid . test = function ( uuid ) {
3333 if ( typeof uuid === 'string' ) {
34- return / ^ [ 0 - 9 a - f ] { 8 } - [ 0 - 9 a - f ] { 4 } - 4 [ 0 - 9 a - f ] { 3 } - [ 8 9 a b ] [ 0 - 9 a - f ] { 3 } - [ 0 - 9 a - f ] { 12 } $ / . test ( uuid ) ;
34+ return / ^ [ 0 - 9 a - f ] { 8 } - [ 0 - 9 a - f ] { 4 } - 4 [ 0 - 9 a - f ] { 3 } - [ 8 9 a b ] [ 0 - 9 a - f ] { 3 } - [ 0 - 9 a - f ] { 12 } $ / i . test ( uuid ) ;
3535 }
3636 return false ;
3737 } ;
Original file line number Diff line number Diff line change @@ -3,13 +3,32 @@ var uuid = require('./index');
33
44// Check format
55var i ;
6- for ( i = 0 ; i < 10000 ; i ++ ) {
7- assert ( / ^ [ 0 - 9 a - f ] { 8 } - [ 0 - 9 a - f ] { 4 } - [ 0 - 9 a - f ] { 4 } - [ 0 - 9 a - f ] { 4 } - [ 0 - 9 a - f ] { 12 } $ / . test ( uuid ( ) ) ) ;
6+ for ( i = 0 ; i < 10000 ; i ++ ) {
7+ assert ( uuid . test ( uuid ( ) ) ) ;
8+ }
9+
10+ // Check the test function on known-[in]valid UUIDs
11+ const healthyUuids = [ '6514db12-0a68-4108-a8c9-3ddc6f489a26' ] ;
12+ const invalidUuids = [
13+ '920b70bf-168a-458d-c1ac-50e488e5976f' ,
14+ '633ca20d-1e9e-7b81-b725-82a595ce3515' ,
15+ 'knuth' ,
16+ undefined ,
17+ null ,
18+ [ ] ,
19+ 42 ,
20+ ] ;
21+ for ( const healthyUuid of healthyUuids ) {
22+ assert ( uuid . test ( healthyUuid ) === true ) ;
23+ assert ( uuid . test ( healthyUuid . toUpperCase ( ) ) === true ) ;
24+ }
25+ for ( const invalidUuid of invalidUuids ) {
26+ assert ( uuid . test ( invalidUuid ) === false ) ;
827}
928
1029// Clear the buffer and change the randomBytes function to return 0s
1130uuid . clearBuffer ( ) ;
12- uuid . randomBytes = function ( length ) {
13- return ( new Array ( length ) ) . fill ( 0 , 0 , length ) ;
31+ uuid . randomBytes = function ( length ) {
32+ return new Array ( length ) . fill ( 0 , 0 , length ) ;
1433} ;
1534assert ( uuid ( ) === '00000000-0000-4000-8000-000000000000' ) ;
You can’t perform that action at this time.
0 commit comments