Skip to content

Commit 43f385a

Browse files
committed
Add overloads
1 parent 3a608ea commit 43f385a

File tree

2 files changed

+165
-6
lines changed

2 files changed

+165
-6
lines changed

lib/node_modules/@stdlib/array/dtype/docs/types/index.d.ts

Lines changed: 150 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,155 @@
2020

2121
/// <reference types="@stdlib/types"/>
2222

23-
import { RealOrComplexTypedArray } from '@stdlib/types/array';
23+
import { RealOrComplexTypedArray, Complex128Array, Complex64Array, DataType } from '@stdlib/types/array';
24+
25+
/**
26+
* Returns the data type of an array.
27+
*
28+
* @param value - input value
29+
* @returns data type
30+
*
31+
* @example
32+
* var dt = dtype( new Float64Array( [ 1, 2, 3 ] ) );
33+
* // returns 'float64'
34+
*/
35+
declare function dtype( value: Float64Array ): 'float64';
36+
37+
/**
38+
* Returns the data type of an array.
39+
*
40+
* @param value - input value
41+
* @returns data type
42+
*
43+
* @example
44+
* var dt = dtype( new Float32Array( [ 1, 2, 3 ] ) );
45+
* // returns 'float32'
46+
*/
47+
declare function dtype( value: Float32Array ): 'float32';
48+
49+
/**
50+
* Returns the data type of an array.
51+
*
52+
* @param value - input value
53+
* @returns data type
54+
*
55+
* @example
56+
* var Complex128Array = require( `@stdlib/array/complex128` );
57+
*
58+
* var dt = dtype( new Complex128Array( [ 1, 2, 3, 4 ] ) );
59+
* // returns 'complex128'
60+
*/
61+
declare function dtype( value: Complex128Array ): 'complex128';
62+
63+
/**
64+
* Returns the data type of an array.
65+
*
66+
* @param value - input value
67+
* @returns data type
68+
*
69+
* @example
70+
* var Complex64Array = require( `@stdlib/array/complex64` );
71+
*
72+
* var dt = dtype( new Complex64Array( [ 1, 2, 3, 4 ] ) );
73+
* // returns 'complex64'
74+
*/
75+
declare function dtype( value: Complex64Array ): 'complex64';
76+
77+
/**
78+
* Returns the data type of an array.
79+
*
80+
* @param value - input value
81+
* @returns data type
82+
*
83+
* @example
84+
* var dt = dtype( new Int32Array( [ 1, 2, 3 ] ) );
85+
* // returns 'int32'
86+
*/
87+
declare function dtype( value: Int32Array ): 'int32';
88+
89+
/**
90+
* Returns the data type of an array.
91+
*
92+
* @param value - input value
93+
* @returns data type
94+
*
95+
* @example
96+
* var dt = dtype( new Int16Array( [ 1, 2, 3 ] ) );
97+
* // returns 'int16'
98+
*/
99+
declare function dtype( value: Int16Array ): 'int16';
100+
101+
/**
102+
* Returns the data type of an array.
103+
*
104+
* @param value - input value
105+
* @returns data type
106+
*
107+
* @example
108+
* var dt = dtype( new Int8Array( [ 1, 2, 3 ] ) );
109+
* // returns 'int8'
110+
*/
111+
declare function dtype( value: Int8Array ): 'int8';
112+
113+
/**
114+
* Returns the data type of an array.
115+
*
116+
* @param value - input value
117+
* @returns data type
118+
*
119+
* @example
120+
* var dt = dtype( new Uint32Array( [ 1, 2, 3 ] ) );
121+
* // returns 'uint32'
122+
*/
123+
declare function dtype( value: Uint32Array ): 'uint32';
124+
125+
/**
126+
* Returns the data type of an array.
127+
*
128+
* @param value - input value
129+
* @returns data type
130+
*
131+
* @example
132+
* var dt = dtype( new Uint16Array( [ 1, 2, 3 ] ) );
133+
* // returns 'uint16'
134+
*/
135+
declare function dtype( value: Uint16Array ): 'uint16';
136+
137+
/**
138+
* Returns the data type of an array.
139+
*
140+
* @param value - input value
141+
* @returns data type
142+
*
143+
* @example
144+
* var dt = dtype( new Uint8Array( [ 1, 2, 3 ] ) );
145+
* // returns 'uint8'
146+
*/
147+
declare function dtype( value: Uint8Array ): 'uint8';
148+
149+
/**
150+
* Returns the data type of an array.
151+
*
152+
* @param value - input value
153+
* @returns data type
154+
*
155+
* @example
156+
* var dt = dtype( new Uint8ClampedArray( [ 1, 2, 3 ] ) );
157+
* // returns 'uint8c'
158+
*/
159+
declare function dtype( value: Uint8ClampedArray ): 'uint8c';
160+
161+
/**
162+
* Returns the data type of an array.
163+
*
164+
* @param value - input value
165+
* @returns data type
166+
*
167+
* @example
168+
* var dt = dtype( [ 1, 2, 3 ] );
169+
* // returns 'generic'
170+
*/
171+
declare function dtype( value: Array<any> ): 'generic';
24172

25173
/**
26174
* Returns the data type of an array.
@@ -39,7 +187,7 @@ import { RealOrComplexTypedArray } from '@stdlib/types/array';
39187
* var dt = dtype( 'beep' );
40188
* // returns null
41189
*/
42-
declare function dtype( value: Array<any> | RealOrComplexTypedArray ): string | null; // tslint-disable-line max-line-length
190+
declare function dtype( value: Array<any> | RealOrComplexTypedArray ): DataType | null; // tslint:disable-line:max-line-length
43191

44192

45193
// EXPORTS //

lib/node_modules/@stdlib/array/dtype/docs/types/test.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,27 @@
1616
* limitations under the License.
1717
*/
1818

19+
import Complex128Array = require( '@stdlib/array/complex128' );
20+
import Complex64Array = require( '@stdlib/array/complex64' );
1921
import dtype = require( './index' );
2022

2123

2224
// TESTS //
2325

24-
// The function returns a string or null..
26+
// The function returns a data type or null..
2527
{
26-
const x = new Float64Array( 10 );
27-
28-
dtype( x ); // $ExpectType string | null
28+
dtype( new Float64Array( 10 ) ); // $ExpectType "float64"
29+
dtype( new Float32Array( 10 ) ); // $ExpectType "float32"
30+
dtype( new Complex128Array( 10 ) ); // $ExpectType "complex128"
31+
dtype( new Complex64Array( 10 ) ); // $ExpectType "complex64"
32+
dtype( new Int32Array( 10 ) ); // $ExpectType "int32"
33+
dtype( new Int16Array( 10 ) ); // $ExpectType "int16"
34+
dtype( new Int8Array( 10 ) ); // $ExpectType "int8"
35+
dtype( new Uint32Array( 10 ) ); // $ExpectType "uint32"
36+
dtype( new Uint16Array( 10 ) ); // $ExpectType "uint16"
37+
dtype( new Uint8Array( 10 ) ); // $ExpectType "uint8"
38+
dtype( new Uint8ClampedArray( 10 ) ); // $ExpectType "uint8c"
39+
dtype( [] ); // $ExpectType "generic"
2940
}
3041

3142
// The compiler throws an error if the function is provided an unsupported number of arguments...

0 commit comments

Comments
 (0)