1
- import { DtypeString } from '../types'
2
- import { ValueError } from '../errors'
1
+ import { DtypeString } from '../types' ;
2
+ import { ValueError } from '../errors' ;
3
3
4
- export type NestedArrayData = TypedArray | NDNestedArrayData
4
+ export type NestedArrayData = TypedArray | NDNestedArrayData ;
5
5
export type NDNestedArrayData =
6
6
| TypedArray [ ]
7
7
| TypedArray [ ] [ ]
8
8
| TypedArray [ ] [ ] [ ]
9
9
| TypedArray [ ] [ ] [ ] [ ]
10
10
| TypedArray [ ] [ ] [ ] [ ] [ ]
11
- | TypedArray [ ] [ ] [ ] [ ] [ ] [ ]
11
+ | TypedArray [ ] [ ] [ ] [ ] [ ] [ ] ;
12
12
13
13
export type TypedArray =
14
14
| Uint8Array
@@ -18,7 +18,7 @@ export type TypedArray =
18
18
| Uint32Array
19
19
| Int32Array
20
20
| Float32Array
21
- | Float64Array
21
+ | Float64Array ;
22
22
23
23
// ArrayLike<any> & {
24
24
// BYTES_PER_ELEMENT: number;
@@ -29,13 +29,13 @@ export type TypedArray =
29
29
// constructor: TypedArrayConstructor<TypedArray>;
30
30
// };
31
31
export type TypedArrayConstructor < TypedArray > = {
32
- new ( ) : TypedArray
32
+ new ( ) : TypedArray ;
33
33
// tslint:disable-next-line: unified-signatures
34
- new ( size : number ) : TypedArray
34
+ new ( size : number ) : TypedArray ;
35
35
// tslint:disable-next-line: unified-signatures
36
- new ( buffer : ArrayBuffer ) : TypedArray
37
- BYTES_PER_ELEMENT : number
38
- }
36
+ new ( buffer : ArrayBuffer ) : TypedArray ;
37
+ BYTES_PER_ELEMENT : number ;
38
+ } ;
39
39
40
40
export const DTYPE_TYPEDARRAY_MAPPING : { [ A in DtypeString ] : TypedArrayConstructor < TypedArray > } = {
41
41
'<b' : Int8Array ,
@@ -49,19 +49,19 @@ export const DTYPE_TYPEDARRAY_MAPPING: { [A in DtypeString]: TypedArrayConstruct
49
49
50
50
'<f4' : Float32Array ,
51
51
'<f8' : Float64Array
52
- }
52
+ } ;
53
53
54
54
export function getTypedArrayDtypeString ( t : TypedArray ) : DtypeString {
55
55
// Favour the types below instead of small and big B
56
- if ( t instanceof Uint8Array ) return '<u1'
57
- if ( t instanceof Int8Array ) return '<i1'
58
- if ( t instanceof Uint16Array ) return '<u2'
59
- if ( t instanceof Int16Array ) return '<i2'
60
- if ( t instanceof Uint32Array ) return '<u4'
61
- if ( t instanceof Int32Array ) return '<i4'
56
+ if ( t instanceof Uint8Array ) return '<u1' ;
57
+ if ( t instanceof Int8Array ) return '<i1' ;
58
+ if ( t instanceof Uint16Array ) return '<u2' ;
59
+ if ( t instanceof Int16Array ) return '<i2' ;
60
+ if ( t instanceof Uint32Array ) return '<u4' ;
61
+ if ( t instanceof Int32Array ) return '<i4' ;
62
62
63
- if ( t instanceof Float32Array ) return '<f4'
64
- if ( t instanceof Float64Array ) return '<f8'
63
+ if ( t instanceof Float32Array ) return '<f4' ;
64
+ if ( t instanceof Float64Array ) return '<f8' ;
65
65
66
- throw new ValueError ( 'Mapping for TypedArray to Dtypestring not known' )
66
+ throw new ValueError ( 'Mapping for TypedArray to Dtypestring not known' ) ;
67
67
}
0 commit comments