2020
2121/// <reference types="@stdlib/types"/>
2222
23- import { Complex128Array , Complex64Array , NumericDataType } from '@stdlib/types/array' ;
24-
25- /**
26- * Generates a linearly spaced numeric array whose elements increment by 1 starting from one.
27- *
28- * @param n - number of elements
29- * @param dtype - data type
30- * @returns linearly spaced numeric array
31- *
32- * @example
33- * var arr = oneTo( 2, 'float64' );
34- * // returns <Float64Array>[ 1.0, 2.0 ]
35- */
36- declare function oneTo ( n : number , dtype : 'float64' ) : Float64Array ;
37-
38- /**
39- * Generates a linearly spaced numeric array whose elements increment by 1 starting from one.
40- *
41- * @param n - number of elements
42- * @param dtype - data type
43- * @returns linearly spaced numeric array
44- *
45- * @example
46- * var arr = oneTo( 2, 'float32' );
47- * // returns <Float32Array>[ 1.0, 2.0 ]
48- */
49- declare function oneTo ( n : number , dtype : 'float32' ) : Float32Array ;
50-
51- /**
52- * Generates a linearly spaced numeric array whose elements increment by 1 starting from one.
53- *
54- * ## Notes
55- *
56- * - Each element has an imaginary component equal to `0`.
57- *
58- * @param n - number of elements
59- * @param dtype - data type
60- * @returns linearly spaced numeric array
61- *
62- * @example
63- * var arr = oneTo( 2, 'complex128' );
64- * // returns <Complex128Array>
65- */
66- declare function oneTo ( n : number , dtype : 'complex128' ) : Complex128Array ;
67-
68- /**
69- * Generates a linearly spaced numeric array whose elements increment by 1 starting from one.
70- *
71- * ## Notes
72- *
73- * - Each element has an imaginary component equal to `0`.
74- *
75- * @param n - number of elements
76- * @param dtype - data type
77- * @returns linearly spaced numeric array
78- *
79- * @example
80- * var arr = oneTo( 2, 'complex64' );
81- * // returns <Complex64Array>
82- */
83- declare function oneTo ( n : number , dtype : 'complex64' ) : Complex64Array ;
84-
85- /**
86- * Generates a linearly spaced numeric array whose elements increment by 1 starting from one.
87- *
88- * @param n - number of elements
89- * @param dtype - data type
90- * @returns linearly spaced numeric array
91- *
92- * @example
93- * var arr = oneTo( 2, 'int32' );
94- * // returns <Int32Array>[ 1, 2 ]
95- */
96- declare function oneTo ( n : number , dtype : 'int32' ) : Int32Array ;
97-
98- /**
99- * Generates a linearly spaced numeric array whose elements increment by 1 starting from one.
100- *
101- * @param n - number of elements
102- * @param dtype - data type
103- * @returns linearly spaced numeric array
104- *
105- * @example
106- * var arr = oneTo( 2, 'int16' );
107- * // returns <Int16Array>[ 1, 2 ]
108- */
109- declare function oneTo ( n : number , dtype : 'int16' ) : Int16Array ;
110-
111- /**
112- * Generates a linearly spaced numeric array whose elements increment by 1 starting from one.
113- *
114- * @param n - number of elements
115- * @param dtype - data type
116- * @returns linearly spaced numeric array
117- *
118- * @example
119- * var arr = oneTo( 2, 'int8' );
120- * // returns <Int8Array>[ 1, 2 ]
121- */
122- declare function oneTo ( n : number , dtype : 'int8' ) : Int8Array ;
123-
124- /**
125- * Generates a linearly spaced numeric array whose elements increment by 1 starting from one.
126- *
127- * @param n - number of elements
128- * @param dtype - data type
129- * @returns linearly spaced numeric array
130- *
131- * @example
132- * var arr = oneTo( 2, 'uint32' );
133- * // returns <Uint32Array>[ 1, 2 ]
134- */
135- declare function oneTo ( n : number , dtype : 'uint32' ) : Uint32Array ;
136-
137- /**
138- * Generates a linearly spaced numeric array whose elements increment by 1 starting from one.
139- *
140- * @param n - number of elements
141- * @param dtype - data type
142- * @returns linearly spaced numeric array
143- *
144- * @example
145- * var arr = oneTo( 2, 'uint16' );
146- * // returns <Uint16Array>[ 1, 2 ]
147- */
148- declare function oneTo ( n : number , dtype : 'uint16' ) : Uint16Array ;
149-
150- /**
151- * Generates a linearly spaced numeric array whose elements increment by 1 starting from one.
152- *
153- * @param n - number of elements
154- * @param dtype - data type
155- * @returns linearly spaced numeric array
156- *
157- * @example
158- * var arr = oneTo( 2, 'uint8' );
159- * // returns <Uint8Array>[ 1, 2 ]
160- */
161- declare function oneTo ( n : number , dtype : 'uint8' ) : Uint8Array ;
162-
163- /**
164- * Generates a linearly spaced numeric array whose elements increment by 1 starting from one.
165- *
166- * @param n - number of elements
167- * @param dtype - data type
168- * @returns linearly spaced numeric array
169- *
170- * @example
171- * var arr = oneTo( 2, 'uint8c' );
172- * // returns <Uint8ClampedArray>[ 1, 2 ]
173- */
174- declare function oneTo ( n : number , dtype : 'uint8c' ) : Uint8ClampedArray ;
175-
176- /**
177- * Generates a linearly spaced numeric array whose elements increment by 1 starting from one.
178- *
179- * @param n - number of elements
180- * @param dtype - data type
181- * @returns linearly spaced numeric array
182- *
183- * @example
184- * var arr = oneTo( 2, 'generic' );
185- * // returns [ 1, 2 ]
186- */
187- declare function oneTo ( n : number , dtype : 'generic' ) : Array < number > ;
23+ import { NumericAndGenericDataTypeMap } from '@stdlib/types/array' ;
18824
18925/**
19026* Generates a linearly spaced numeric array whose elements increment by 1 starting from one.
@@ -201,7 +37,7 @@ declare function oneTo( n: number, dtype: 'generic' ): Array<number>;
20137* var arr = oneTo( 2, 'float32' );
20238* // returns <Float32Array>[ 1.0, 2.0 ]
20339*/
204- declare function oneTo ( n : number , dtype ?: NumericDataType ) : Float64Array ;
40+ declare function oneTo < T extends keyof NumericAndGenericDataTypeMap < number > = 'float64' > ( n : number , dtype ?: T ) : NumericAndGenericDataTypeMap < number > [ T ] ;
20541
20642
20743// EXPORTS //
0 commit comments