|
18 | 18 |
|
19 | 19 | // TypeScript Version: 2.0 |
20 | 20 |
|
| 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 | + |
21 | 258 | /** |
22 | 259 | * Returns the next larger array data type of the same kind. |
23 | 260 | * |
|
31 | 268 | * @returns next larger data type(s) or null |
32 | 269 | * |
33 | 270 | * @example |
| 271 | +* var table = nextDataType(); |
| 272 | +* // returns {...} |
| 273 | +* |
| 274 | +* @example |
34 | 275 | * var dt = nextDataType( 'float32' ); |
35 | 276 | * // returns 'float64' |
36 | 277 | */ |
37 | | -declare function nextDataType( dtype?: string ): Object | Array<string> | null; |
| 278 | +declare function nextDataType( dtype?: DataType ): Table; |
38 | 279 |
|
39 | 280 |
|
40 | 281 | // EXPORTS // |
|
0 commit comments