Skip to content

Commit 4d8fae2

Browse files
committed
Add overloads
1 parent b4fe0bc commit 4d8fae2

2 files changed

Lines changed: 47 additions & 3 deletions

File tree

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

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

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

23-
import { DataType } from '@stdlib/types/array';
23+
import { RealDataType, ComplexDataType, DataType } from '@stdlib/types/array';
24+
import { ComplexLike } from '@stdlib/types/object';
2425

2526
/**
2627
* Returns the minimum array data type of the closest "kind" necessary for storing a provided scalar value.
@@ -40,7 +41,43 @@ import { DataType } from '@stdlib/types/array';
4041
* var dt = minDataType( 3 );
4142
* // returns 'uint8'
4243
*/
43-
declare function minDataType( value: any ): DataType;
44+
declare function minDataType( value: number ): RealDataType;
45+
46+
/**
47+
* Returns the minimum array data type of the closest "kind" necessary for storing a provided scalar value.
48+
*
49+
* ## Notes
50+
*
51+
* - The function does *not* provide precision guarantees for non-integer-valued real numbers. In other words, the function returns the smallest possible floating-point (i.e., inexact) data type for storing numbers having decimals.
52+
*
53+
* @param value - scalar value
54+
* @returns array data type
55+
*
56+
* @example
57+
* var z = {
58+
* 're': 3.141592653589793,
59+
* 'im': 1.0
60+
* };
61+
* var dt = minDataType( z );
62+
* // returns 'complex64'
63+
*/
64+
declare function minDataType( value: ComplexLike ): ComplexDataType;
65+
66+
/**
67+
* Returns the minimum array data type of the closest "kind" necessary for storing a provided scalar value.
68+
*
69+
* ## Notes
70+
*
71+
* - The function does *not* provide precision guarantees for non-integer-valued real numbers. In other words, the function returns the smallest possible floating-point (i.e., inexact) data type for storing numbers having decimals.
72+
*
73+
* @param value - scalar value
74+
* @returns array data type
75+
*
76+
* @example
77+
* var dt = minDataType( 'beep' );
78+
* // returns 'generic'
79+
*/
80+
declare function minDataType( value: any ): 'generic';
4481

4582

4683
// EXPORTS //

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ import minDataType = require( './index' );
2323

2424
// The function returns a data type..
2525
{
26-
minDataType( 2.13 ); // $ExpectType DataType
26+
const z = {
27+
're': 1.0,
28+
'im': 2.0
29+
};
30+
31+
minDataType( 2.13 ); // $ExpectType RealDataType
32+
minDataType( z ); // $ExpectType ComplexDataType
33+
minDataType( 'beep' ); // $ExpectType "generic"
2734
}
2835

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

0 commit comments

Comments
 (0)