1818
1919// TypeScript Version: 2.0
2020
21+ /// <reference types="@stdlib/types"/>
22+
23+ import { DataType } from '@stdlib/types/array' ;
24+
2125/**
2226* Interface describing a promotion table.
2327*/
2428interface Table {
25- // Table properties:
26- [ key : string ] : string | number ;
29+ /**
30+ * Data type promotion rules.
31+ */
32+ [ key : string ] : DataType | number ;
2733}
2834
35+ /**
36+ * Promotion rule.
37+ */
38+ type PromotionRule = DataType | number ;
39+
2940/**
3041* Returns the array data type with the smallest size and closest "kind" to which array data types can be safely cast.
3142*
3243* @param dtype1 - array data type
3344* @param dtype2 - array data type
34- * @returns promotion rule(s) or null
45+ * @returns promotion rule
3546*
3647* @example
3748* var dt = promotionRules( 'float32', 'uint32' );
@@ -41,11 +52,34 @@ interface Table {
4152* var dt = promotionRules( 'float32', 'foo' );
4253* // returns null
4354*/
44- declare function promotionRules ( dtype1 : string , dtype2 : string ) : number | string | null ; // tslint-disable-line max-line-length
55+ declare function promotionRules ( dtype1 : DataType , dtype2 : DataType ) : PromotionRule ; // tslint:disable-line:max-line-length
56+
57+ /**
58+ * Returns the array data type with the smallest size and closest "kind" to which array data types can be safely cast.
59+ *
60+ * @param dtype1 - array data type
61+ * @param dtype2 - array data type
62+ * @returns promotion rule
63+ *
64+ * @example
65+ * var dt = promotionRules( 'float32', 'foo' );
66+ * // returns null
67+ *
68+ * @example
69+ * var dt = promotionRules( 'bar', 'float32' );
70+ * // returns null
71+ *
72+ * @example
73+ * var dt = promotionRules( 'bar', 'foo' );
74+ * // returns null
75+ */
76+ declare function promotionRules ( dtype1 : string , dtype2 : string ) : null ;
4577
4678/**
4779* Returns a type promotion table displaying array data types with the smallest size and closest "kind" to which array data types can be safely cast.
4880*
81+ * @param dtype1 - array data type
82+ * @param dtype2 - array data type
4983* @returns promotion rule table
5084*
5185* @example
0 commit comments