Skip to content

Commit e04650b

Browse files
committed
fix: apply suggestions from code review
1 parent 8877621 commit e04650b

2 files changed

Lines changed: 9 additions & 44 deletions

File tree

lib/node_modules/@stdlib/blas/ext/base/gzero-to/docs/types/index.d.ts

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,15 @@
2222

2323
import { Collection, AccessorArrayLike } from '@stdlib/types/array';
2424

25+
/**
26+
* Input array.
27+
*/
28+
type InputArray<T> = Collection<T> | AccessorArrayLike<T>;
29+
2530
/**
2631
* Interface describing `gzeroTo`.
2732
*/
2833
interface Routine {
29-
/**
30-
* Fills a strided array with linearly spaced numeric elements which increment by `1` starting from zero.
31-
*
32-
* @param N - number of indexed elements
33-
* @param x - input array
34-
* @param strideX - stride length
35-
* @returns input array
36-
*
37-
* @example
38-
* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
39-
*
40-
* var x = [ 0.0, 0.0, 0.0, 0.0 ];
41-
*
42-
* gzeroTo( x.length, toAccessorArray( x ), 1 );
43-
* // x => [ 0.0, 1.0, 2.0, 3.0 ]
44-
*/
45-
<T = unknown>( N: number, x: AccessorArrayLike<T>, strideX: number ): AccessorArrayLike<T>;
46-
4734
/**
4835
* Fills a strided array with linearly spaced numeric elements which increment by `1` starting from zero.
4936
*
@@ -58,26 +45,7 @@ interface Routine {
5845
* gzeroTo( x.length, x, 1 );
5946
* // x => [ 0.0, 1.0, 2.0, 3.0 ]
6047
*/
61-
<T = unknown>( N: number, x: Collection<T>, strideX: number ): Collection<T>;
62-
63-
/**
64-
* Fills a strided array with linearly spaced numeric elements which increment by `1` starting from zero using alternative indexing semantics.
65-
*
66-
* @param N - number of indexed elements
67-
* @param x - input array
68-
* @param strideX - stride length
69-
* @param offsetX - starting index
70-
* @returns input array
71-
*
72-
* @example
73-
* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
74-
*
75-
* var x = [ 0.0, 0.0, 0.0, 0.0 ];
76-
*
77-
* gzeroTo.ndarray( x.length, toAccessorArray( x ), 1, 0 );
78-
* // x => [ 0.0, 1.0, 2.0, 3.0 ]
79-
*/
80-
ndarray<T = unknown>( N: number, x: AccessorArrayLike<T>, strideX: number, offsetX: number ): AccessorArrayLike<T>;
48+
<T = unknown, U extends InputArray<T> = InputArray<T>>( N: number, x: U, strideX: number ): U;
8149

8250
/**
8351
* Fills a strided array with linearly spaced numeric elements which increment by `1` starting from zero using alternative indexing semantics.
@@ -94,7 +62,7 @@ interface Routine {
9462
* gzeroTo.ndarray( x.length, x, 1, 0 );
9563
* // x => [ 0.0, 1.0, 2.0, 3.0 ]
9664
*/
97-
ndarray<T = unknown>( N: number, x: Collection<T>, strideX: number, offsetX: number ): Collection<T>;
65+
ndarray<T = unknown, U extends InputArray<T> = InputArray<T>>( N: number, x: U, strideX: number, offsetX: number ): U;
9866
}
9967

10068
/**

lib/node_modules/@stdlib/blas/ext/base/gzero-to/docs/types/test.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
* limitations under the License.
1717
*/
1818

19-
import AccessorArray = require( '@stdlib/array/base/accessor' );
2019
import gzeroTo = require( './index' );
2120

2221

@@ -26,8 +25,7 @@ import gzeroTo = require( './index' );
2625
{
2726
const x = new Float64Array( 10 );
2827

29-
gzeroTo( x.length, x, 1 ); // $ExpectType Collection<number>
30-
gzeroTo( x.length, new AccessorArray( x ), 1 ); // $ExpectType AccessorArrayLike<number>
28+
gzeroTo( x.length, x, 1 ); // $ExpectType Float64Array
3129
}
3230

3331
// The compiler throws an error if the function is provided a first argument which is not a number...
@@ -84,8 +82,7 @@ import gzeroTo = require( './index' );
8482
{
8583
const x = new Float64Array( 10 );
8684

87-
gzeroTo.ndarray( x.length, x, 1, 0 ); // $ExpectType Collection<number>
88-
gzeroTo.ndarray( x.length, new AccessorArray( x ), 1, 0 ); // $ExpectType AccessorArrayLike<number>
85+
gzeroTo.ndarray( x.length, x, 1, 0 ); // $ExpectType Float64Array
8986
}
9087

9188
// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number...

0 commit comments

Comments
 (0)