Skip to content

Commit b4fe0bc

Browse files
committed
Add overloads
1 parent b93ff4b commit b4fe0bc

File tree

2 files changed

+267
-4
lines changed

2 files changed

+267
-4
lines changed

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

Lines changed: 242 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,243 @@
1818

1919
// TypeScript Version: 2.0
2020

21+
/// <reference types="@stdlib/types"/>
22+
23+
import { DataType } from '@stdlib/types/array';
24+
25+
/**
26+
* Table mapping data types to the next larger data type of the same kind.
27+
*/
28+
interface Table {
29+
/**
30+
* Mapping of a data type to the next larger data type of the same kind.
31+
*/
32+
[key: string]: DataType | number;
33+
}
34+
35+
/**
36+
* Returns the next larger array data type of the same kind.
37+
*
38+
* ## Notes
39+
*
40+
* - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`.
41+
*
42+
* @param dtype - array data type
43+
* @returns next larger data type
44+
*
45+
* @example
46+
* var dt = nextDataType( 'float64' );
47+
* // returns -1
48+
*/
49+
declare function nextDataType( dtype: 'float64' ): number;
50+
51+
/**
52+
* Returns the next larger array data type of the same kind.
53+
*
54+
* ## Notes
55+
*
56+
* - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`.
57+
*
58+
* @param dtype - array data type
59+
* @returns next larger data type
60+
*
61+
* @example
62+
* var dt = nextDataType( 'float32' );
63+
* // returns 'float64'
64+
*/
65+
declare function nextDataType( dtype: 'float32' ): 'float64';
66+
67+
/**
68+
* Returns the next larger array data type of the same kind.
69+
*
70+
* ## Notes
71+
*
72+
* - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`.
73+
*
74+
* @param dtype - array data type
75+
* @returns next larger data type
76+
*
77+
* @example
78+
* var dt = nextDataType( 'int32' );
79+
* // returns -1
80+
*/
81+
declare function nextDataType( dtype: 'int32' ): number; // tslint:disable-line:unified-signatures
82+
83+
/**
84+
* Returns the next larger array data type of the same kind.
85+
*
86+
* ## Notes
87+
*
88+
* - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`.
89+
*
90+
* @param dtype - array data type
91+
* @returns next larger data type
92+
*
93+
* @example
94+
* var dt = nextDataType( 'int16' );
95+
* // returns 'int32'
96+
*/
97+
declare function nextDataType( dtype: 'int16' ): 'int32';
98+
99+
/**
100+
* Returns the next larger array data type of the same kind.
101+
*
102+
* ## Notes
103+
*
104+
* - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`.
105+
*
106+
* @param dtype - array data type
107+
* @returns next larger data type
108+
*
109+
* @example
110+
* var dt = nextDataType( 'int8' );
111+
* // returns 'int16'
112+
*/
113+
declare function nextDataType( dtype: 'int8' ): 'int16';
114+
115+
/**
116+
* Returns the next larger array data type of the same kind.
117+
*
118+
* ## Notes
119+
*
120+
* - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`.
121+
*
122+
* @param dtype - array data type
123+
* @returns next larger data type
124+
*
125+
* @example
126+
* var dt = nextDataType( 'uint32' );
127+
* // returns -1
128+
*/
129+
declare function nextDataType( dtype: 'uint32' ): number; // tslint:disable-line:unified-signatures
130+
131+
/**
132+
* Returns the next larger array data type of the same kind.
133+
*
134+
* ## Notes
135+
*
136+
* - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`.
137+
*
138+
* @param dtype - array data type
139+
* @returns next larger data type
140+
*
141+
* @example
142+
* var dt = nextDataType( 'uint16' );
143+
* // returns 'uint32'
144+
*/
145+
declare function nextDataType( dtype: 'uint16' ): 'uint32';
146+
147+
/**
148+
* Returns the next larger array data type of the same kind.
149+
*
150+
* ## Notes
151+
*
152+
* - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`.
153+
*
154+
* @param dtype - array data type
155+
* @returns next larger data type
156+
*
157+
* @example
158+
* var dt = nextDataType( 'uint8' );
159+
* // returns 'uint16'
160+
*/
161+
declare function nextDataType( dtype: 'uint8' ): 'uint16';
162+
163+
/**
164+
* Returns the next larger array data type of the same kind.
165+
*
166+
* ## Notes
167+
*
168+
* - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`.
169+
*
170+
* @param dtype - array data type
171+
* @returns next larger data type
172+
*
173+
* @example
174+
* var dt = nextDataType( 'uint8c' );
175+
* // returns 'uint16'
176+
*/
177+
declare function nextDataType( dtype: 'uint8c' ): 'uint16'; // tslint:disable-line:unified-signatures
178+
179+
/**
180+
* Returns the next larger array data type of the same kind.
181+
*
182+
* ## Notes
183+
*
184+
* - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`.
185+
*
186+
* @param dtype - array data type
187+
* @returns next larger data type
188+
*
189+
* @example
190+
* var dt = nextDataType( 'generic' );
191+
* // returns -1
192+
*/
193+
declare function nextDataType( dtype: 'generic' ): number; // tslint:disable-line:unified-signatures
194+
195+
/**
196+
* Returns the next larger array data type of the same kind.
197+
*
198+
* ## Notes
199+
*
200+
* - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`.
201+
*
202+
* @param dtype - array data type
203+
* @returns next larger data type
204+
*
205+
* @example
206+
* var dt = nextDataType( 'complex128' );
207+
* // returns -1
208+
*/
209+
declare function nextDataType( dtype: 'complex128' ): number; // tslint:disable-line:unified-signatures
210+
211+
/**
212+
* Returns the next larger array data type of the same kind.
213+
*
214+
* ## Notes
215+
*
216+
* - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`.
217+
*
218+
* @param dtype - array data type
219+
* @returns next larger data type
220+
*
221+
* @example
222+
* var dt = nextDataType( 'complex64' );
223+
* // returns 'complex128'
224+
*/
225+
declare function nextDataType( dtype: 'complex64' ): 'complex128';
226+
227+
/**
228+
* Returns the next larger array data type of the same kind.
229+
*
230+
* ## Notes
231+
*
232+
* - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`.
233+
*
234+
* @param dtype - array data type
235+
* @returns next larger data type
236+
*
237+
* @example
238+
* var dt = nextDataType( 'complex64' );
239+
* // returns 'complex128'
240+
*/
241+
declare function nextDataType( dtype: DataType ): DataType | number;
242+
243+
/**
244+
* Returns the next larger array data type of the same kind.
245+
*
246+
* ## Notes
247+
* - If provided an unrecognized data type, the function returns `null`.
248+
*
249+
* @param dtype - array data type
250+
* @returns next larger data type
251+
*
252+
* @example
253+
* var dt = nextDataType( 'float' );
254+
* // returns null
255+
*/
256+
declare function nextDataType( dtype: string ): null;
257+
21258
/**
22259
* Returns the next larger array data type of the same kind.
23260
*
@@ -31,10 +268,14 @@
31268
* @returns next larger data type(s) or null
32269
*
33270
* @example
271+
* var table = nextDataType();
272+
* // returns {...}
273+
*
274+
* @example
34275
* var dt = nextDataType( 'float32' );
35276
* // returns 'float64'
36277
*/
37-
declare function nextDataType( dtype?: string ): Object | Array<string> | null;
278+
declare function nextDataType( dtype?: DataType ): Table;
38279

39280

40281
// EXPORTS //

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

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,34 @@
1818

1919
import nextDataType = require( './index' );
2020

21+
2122
// TESTS //
2223

23-
// The function returns a string array, object, or null..
24+
// The function returns a table when not provided an input argument..
2425
{
25-
nextDataType(); // $ExpectType Object | string[] | null
26-
nextDataType( 'float32' ); // $ExpectType Object | string[] | null
26+
nextDataType(); // $ExpectType Table
27+
}
28+
29+
// The function returns the next larger data type or null when provided an input argument...
30+
{
31+
nextDataType( 'complex128' ); // $ExpectType number
32+
nextDataType( 'complex64' ); // $ExpectType "complex128"
33+
34+
nextDataType( 'float64' ); // $ExpectType number
35+
nextDataType( 'float32' ); // $ExpectType "float64"
36+
37+
nextDataType( 'int32' ); // $ExpectType number
38+
nextDataType( 'int16' ); // $ExpectType "int32"
39+
nextDataType( 'int8' ); // $ExpectType "int16"
40+
41+
nextDataType( 'uint32' ); // $ExpectType number
42+
nextDataType( 'uint16' ); // $ExpectType "uint32"
43+
nextDataType( 'uint8' ); // $ExpectType "uint16"
44+
nextDataType( 'uint8c' ); // $ExpectType "uint16"
45+
46+
nextDataType( 'generic' ); // $ExpectType number
47+
48+
nextDataType( 'float' ); // $ExpectType null
2749
}
2850

2951
// The compiler throws an error if the function is provided a first argument which is not a string...

0 commit comments

Comments
 (0)