@@ -38,35 +38,23 @@ if (typeof global.SIMD === 'object' && global.SIMD !== null) {
38
38
39
39
const SIMD = global . SIMD ; // Pacify eslint.
40
40
41
- if ( typeof SIMD . Bool16x8 === 'function' )
42
- simdFormatters . set ( SIMD . Bool16x8 , make ( SIMD . Bool16x8 . extractLane , 8 ) ) ;
43
-
44
- if ( typeof SIMD . Bool32x4 === 'function' )
45
- simdFormatters . set ( SIMD . Bool32x4 , make ( SIMD . Bool32x4 . extractLane , 4 ) ) ;
46
-
47
- if ( typeof SIMD . Bool8x16 === 'function' )
48
- simdFormatters . set ( SIMD . Bool8x16 , make ( SIMD . Bool8x16 . extractLane , 16 ) ) ;
49
-
50
- if ( typeof SIMD . Float32x4 === 'function' )
51
- simdFormatters . set ( SIMD . Float32x4 , make ( SIMD . Float32x4 . extractLane , 4 ) ) ;
52
-
53
- if ( typeof SIMD . Int16x8 === 'function' )
54
- simdFormatters . set ( SIMD . Int16x8 , make ( SIMD . Int16x8 . extractLane , 8 ) ) ;
55
-
56
- if ( typeof SIMD . Int32x4 === 'function' )
57
- simdFormatters . set ( SIMD . Int32x4 , make ( SIMD . Int32x4 . extractLane , 4 ) ) ;
58
-
59
- if ( typeof SIMD . Int8x16 === 'function' )
60
- simdFormatters . set ( SIMD . Int8x16 , make ( SIMD . Int8x16 . extractLane , 16 ) ) ;
61
-
62
- if ( typeof SIMD . Uint16x8 === 'function' )
63
- simdFormatters . set ( SIMD . Uint16x8 , make ( SIMD . Uint16x8 . extractLane , 8 ) ) ;
64
-
65
- if ( typeof SIMD . Uint32x4 === 'function' )
66
- simdFormatters . set ( SIMD . Uint32x4 , make ( SIMD . Uint32x4 . extractLane , 4 ) ) ;
41
+ const countPerType = {
42
+ Bool16x8 : 8 ,
43
+ Bool32x4 : 4 ,
44
+ Bool8x16 : 16 ,
45
+ Float32x4 : 4 ,
46
+ Int16x8 : 8 ,
47
+ Int32x4 : 4 ,
48
+ Int8x16 : 16 ,
49
+ Uint16x8 : 8 ,
50
+ Uint32x4 : 4 ,
51
+ Uint8x16 : 16
52
+ } ;
67
53
68
- if ( typeof SIMD . Uint8x16 === 'function' )
69
- simdFormatters . set ( SIMD . Uint8x16 , make ( SIMD . Uint8x16 . extractLane , 16 ) ) ;
54
+ for ( const key in countPerType ) {
55
+ const type = SIMD [ key ] ;
56
+ simdFormatters . set ( type , make ( type . extractLane , countPerType [ key ] ) ) ;
57
+ }
70
58
}
71
59
72
60
function tryStringify ( arg ) {
0 commit comments