Skip to content

Commit bb5198b

Browse files
committed
Add additional array data type types
1 parent 10b80a5 commit bb5198b

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

lib/node_modules/@stdlib/types/index.d.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,26 @@ declare module '@stdlib/types/array' {
4444
*/
4545
type RealDataType = 'float64' | 'float32' | 'int32' | 'int16' | 'int8' | 'uint32' | 'uint16' | 'uint8' | 'uint8c'; // tslint:disable-line:max-line-length
4646

47+
/**
48+
* Data type for floating-point typed arrays.
49+
*/
50+
type FloatDataType = 'float64' | 'float32';
51+
52+
/**
53+
* Data type for integer typed arrays.
54+
*/
55+
type IntegerDataType = 'int32' | 'int16' | 'int8' | 'uint32' | 'uint16' | 'uint8' | 'uint8c'; // tslint:disable-line:max-line-length
56+
57+
/**
58+
* Data type for signed integer typed arrays.
59+
*/
60+
type SignedIntegerDataType = 'int32' | 'int16' | 'int8';
61+
62+
/**
63+
* Data type for unsigned integer typed arrays.
64+
*/
65+
type UnsignedIntegerDataType = 'uint32' | 'uint16' | 'uint8' | 'uint8c';
66+
4767
/**
4868
* Data type for complex number typed arrays.
4969
*/
@@ -153,6 +173,22 @@ declare module '@stdlib/types/array' {
153173
*/
154174
type IntegerTypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array; // tslint:disable-line:max-line-length
155175

176+
/**
177+
* A signed integer typed array.
178+
*
179+
* @example
180+
* const x: SignedIntegerTypedArray = new Int32Array( 10 );
181+
*/
182+
type SignedIntegerTypedArray = Int8Array | Int16Array | Int32Array;
183+
184+
/**
185+
* An unsigned integer typed array.
186+
*
187+
* @example
188+
* const x: UnsignedIntegerTypedArray = new Uint32Array( 10 );
189+
*/
190+
type UnsignedIntegerTypedArray = Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array; // tslint:disable-line:max-line-length
191+
156192
/**
157193
* A floating-point typed array.
158194
*

lib/node_modules/@stdlib/types/test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,21 @@ function cmplx128Array(): array.Complex128Array {
274274
if ( v5.length !== 10 ) {
275275
throw new Error( 'something went wrong' );
276276
}
277+
278+
const v6: array.IntegerTypedArray = new Int32Array( 10 );
279+
if ( v6[ 0 ] !== 0 ) {
280+
throw new Error( 'something went wrong' );
281+
}
282+
283+
const v7: array.SignedIntegerTypedArray = new Int32Array( 10 );
284+
if ( v7[ 0 ] !== 0 ) {
285+
throw new Error( 'something went wrong' );
286+
}
287+
288+
const v8: array.UnsignedIntegerTypedArray = new Uint32Array( 10 );
289+
if ( v8[ 0 ] !== 0 ) {
290+
throw new Error( 'something went wrong' );
291+
}
277292
}
278293

279294
// The compiler should not throw an error when using iterator or iterable types...

0 commit comments

Comments
 (0)