Skip to content

Commit 098451f

Browse files
Planeshifterkgryte
andauthored
fix: widen mode option type in ndarray/sub2ind to accept a single mode
PR-URL: #12628 Co-authored-by: Athan Reines <kgryte@gmail.com> Reviewed-by: Athan Reines <kgryte@gmail.com> Signed-off-by: Athan Reines <kgryte@gmail.com>
1 parent cbca832 commit 098451f

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

lib/node_modules/@stdlib/ndarray/sub2ind/docs/types/index.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@
1919
// TypeScript Version: 4.1
2020

2121
/// <reference types="@stdlib/types"/>
22-
/// <reference types="node"/>
2322

2423
import { ArrayLike } from '@stdlib/types/array';
25-
import { Order } from '@stdlib/types/ndarray';
24+
import { Mode, Order } from '@stdlib/types/ndarray';
2625

2726
/**
2827
* Interface defining function options.
@@ -31,10 +30,10 @@ interface Options {
3130
/**
3231
* Specifies how to handle subscripts which exceed array dimensions (default: ['throw']).
3332
*/
34-
mode?: Array<string>;
33+
mode?: Mode | Array<Mode>;
3534

3635
/**
37-
* specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major').
36+
* Specifies whether an array is row-major (C-style) or column-major (Fortran-style) (default: 'row-major').
3837
*/
3938
order?: Order;
4039
}
@@ -57,9 +56,10 @@ interface Options {
5756
* @param args - subscripts followed by an optional options object
5857
* @throws first argument must be an array-like object containing nonnegative integers
5958
* @throws subscripts must be integer valued
59+
* @throws options argument must be an object
6060
* @throws must provide valid options
6161
* @throws must provide subscripts which do not exceed array dimensions
62-
* @throws number of subscripts much match the number of dimensions
62+
* @throws number of subscripts must match the number of dimensions
6363
* @returns linear index
6464
*
6565
* @example

lib/node_modules/@stdlib/ndarray/sub2ind/docs/types/test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import subd2ind = require( './index' );
2424
// The function returns a number...
2525
{
2626
const shape = [ 3, 3, 3 ];
27+
subd2ind( shape, 1, 2, 2, { 'mode': 'throw' } ); // $ExpectType number
2728
subd2ind( shape, 1, 2, 2, { 'mode': [ 'throw' ] } ); // $ExpectType number
2829
subd2ind( shape, 1, 2, 2, { 'order': 'row-major' } ); // $ExpectType number
2930
}
@@ -65,7 +66,7 @@ import subd2ind = require( './index' );
6566
subd2ind( shape, 1, 2, 2, { 'order': ( x: number ): number => x } ); // $ExpectError
6667
}
6768

68-
// The compiler throws an error if the function is provided a `mode` option which is not an array of strings...
69+
// The compiler throws an error if the function is provided a `mode` option which is not a recognized mode or array of recognized modes...
6970
{
7071
const shape = [ 3, 3, 3 ];
7172
subd2ind( shape, 1, 2, 2, { 'mode': 'abc' } ); // $ExpectError

0 commit comments

Comments
 (0)