Skip to content

Commit 50bafc3

Browse files
committed
fix: update import path for Collection type definition and refactor to use generics
Ref: bde4671
1 parent b544a52 commit 50bafc3

File tree

2 files changed

+16
-16
lines changed
  • lib/node_modules/@stdlib/strided/base/nullary-addon-dispatch/docs/types

2 files changed

+16
-16
lines changed

lib/node_modules/@stdlib/strided/base/nullary-addon-dispatch/docs/types/index.d.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
/// <reference types="@stdlib/types"/>
2222

23-
import { Collection } from '@stdlib/types/object';
23+
import { Collection } from '@stdlib/types/array';
2424

2525
/**
2626
* Add-on function.
@@ -35,7 +35,7 @@ import { Collection } from '@stdlib/types/object';
3535
* // Call into native add-on...
3636
* }
3737
*/
38-
type AddonFcn = ( N: number, dtypeX: number, x: Collection, strideX: number ) => any; // tslint:disable-line:max-line-length
38+
type AddonFcn<T, U> = ( N: number, dtypeX: number, x: Collection<T>, strideX: number ) => U;
3939

4040
/**
4141
* Fallback function.
@@ -50,7 +50,7 @@ type AddonFcn = ( N: number, dtypeX: number, x: Collection, strideX: number ) =>
5050
* // Fallback JavaScript implementation...
5151
* }
5252
*/
53-
type FallbackFcn = ( N: number, dtypeX: any, x: Collection, strideX: number ) => any; // tslint:disable-line:max-line-length
53+
type FallbackFcn<T, U> = ( N: number, dtypeX: any, x: Collection<T>, strideX: number ) => U;
5454

5555
/**
5656
* Fallback function supporting alternative indexing semantics.
@@ -66,7 +66,7 @@ type FallbackFcn = ( N: number, dtypeX: any, x: Collection, strideX: number ) =>
6666
* // Fallback JavaScript implementation...
6767
* }
6868
*/
69-
type FallbackFcnWithOffsets = ( N: number, dtypeX: any, x: Collection, strideX: number, offsetX: number ) => any; // tslint:disable-line:max-line-length
69+
type FallbackFcnWithOffsets<T, U> = ( N: number, dtypeX: any, x: Collection<T>, strideX: number, offsetX: number ) => U;
7070

7171
/**
7272
* Dispatches to a native add-on.
@@ -77,7 +77,7 @@ type FallbackFcnWithOffsets = ( N: number, dtypeX: any, x: Collection, strideX:
7777
* @param strideX - `x` stride length
7878
* @returns `x`
7979
*/
80-
type Dispatcher = ( N: number, dtypeX: any, x: Collection, strideX: number ) => Collection; // tslint:disable-line:max-line-length
80+
type Dispatcher<T> = ( N: number, dtypeX: any, x: Collection<T>, strideX: number ) => Collection<T>;
8181

8282
/**
8383
* Dispatches to a native add-on.
@@ -89,7 +89,7 @@ type Dispatcher = ( N: number, dtypeX: any, x: Collection, strideX: number ) =>
8989
* @param offsetX - starting `x` index
9090
* @returns `x`
9191
*/
92-
type DispatcherWithOffsets = ( N: number, dtypeX: any, x: Collection, strideX: number, offsetX: number ) => Collection; // tslint:disable-line:max-line-length
92+
type DispatcherWithOffsets<T> = ( N: number, dtypeX: any, x: Collection<T>, strideX: number, offsetX: number ) => Collection<T>;
9393

9494
/**
9595
* Interface for creating a native add-on dispatcher.
@@ -119,7 +119,7 @@ interface Dispatch {
119119
* // Invoke the dispatch function with strided array arguments:
120120
* f( 2, 'generic', [ 1, 2 ], 1 );
121121
*/
122-
( addon: AddonFcn, fallback: FallbackFcn ): Dispatcher;
122+
<T = unknown, U = unknown>( addon: AddonFcn<T, U>, fallback: FallbackFcn<T, U> ): Dispatcher<T>;
123123

124124
/**
125125
* Returns a function which dispatches to a native add-on applying a nullary function using alternative indexing semantics.
@@ -145,7 +145,7 @@ interface Dispatch {
145145
* // Invoke the dispatch function with strided array arguments:
146146
* f( 2, 'generic', [ 1, 2 ], 1, 0 );
147147
*/
148-
ndarray( addon: AddonFcn, fallback: FallbackFcnWithOffsets ): DispatcherWithOffsets; // tslint:disable-line:max-line-length
148+
ndarray<T = unknown, U = unknown>( addon: AddonFcn<T, U>, fallback: FallbackFcnWithOffsets<T, U> ): DispatcherWithOffsets<T>;
149149
}
150150

151151
/**

lib/node_modules/@stdlib/strided/base/nullary-addon-dispatch/docs/types/test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
/// <reference types="@stdlib/types"/>
2020

21-
import { Collection } from '@stdlib/types/object';
21+
import { Collection } from '@stdlib/types/array';
2222
import dispatch = require( './index' );
2323

2424

@@ -32,7 +32,7 @@ import dispatch = require( './index' );
3232
* @param x - output array
3333
* @param strideX - `x` stride length
3434
*/
35-
function addon( N: number, dtypeX: number, x: Collection, strideX: number ): void { // tslint:disable-line:max-line-length
35+
function addon( N: number, dtypeX: number, x: Collection<number>, strideX: number ): void {
3636
let i;
3737
if ( dtypeX !== dtypeX ) {
3838
throw new Error( 'beep' );
@@ -50,7 +50,7 @@ function addon( N: number, dtypeX: number, x: Collection, strideX: number ): voi
5050
* @param x - output array
5151
* @param strideX - `x` stride length
5252
*/
53-
function fallback( N: number, dtypeX: any, x: Collection, strideX: number ): void { // tslint:disable-line:max-line-length
53+
function fallback( N: number, dtypeX: any, x: Collection<number>, strideX: number ): void {
5454
let i;
5555
if ( dtypeX !== dtypeX ) {
5656
throw new Error( 'beep' );
@@ -69,7 +69,7 @@ function fallback( N: number, dtypeX: any, x: Collection, strideX: number ): voi
6969
* @param strideX - `x` stride length
7070
* @param offsetX - starting `x` index
7171
*/
72-
function fallbackWithOffsets( N: number, dtypeX: any, x: Collection, strideX: number, offsetX: number ): void { // tslint:disable-line:max-line-length
72+
function fallbackWithOffsets( N: number, dtypeX: any, x: Collection<number>, strideX: number, offsetX: number ): void {
7373
let i;
7474
if ( dtypeX !== dtypeX ) {
7575
throw new Error( 'beep' );
@@ -84,7 +84,7 @@ function fallbackWithOffsets( N: number, dtypeX: any, x: Collection, strideX: nu
8484

8585
// The function returns a dispatch function...
8686
{
87-
dispatch( addon, fallback ); // $ExpectType Dispatcher
87+
dispatch( addon, fallback ); // $ExpectType Dispatcher<number>
8888
}
8989

9090
// The compiler throws an error if not provided a first argument which is an add-on function...
@@ -119,7 +119,7 @@ function fallbackWithOffsets( N: number, dtypeX: any, x: Collection, strideX: nu
119119

120120
const f = dispatch( addon, fallback );
121121

122-
f( x.length, 'float64', x, 1 ); // $ExpectType Collection
122+
f( x.length, 'float64', x, 1 ); // $ExpectType Collection<number>
123123
}
124124

125125
// The compiler throws an error if the returned function is not provided a first argument which is a number...
@@ -169,7 +169,7 @@ function fallbackWithOffsets( N: number, dtypeX: any, x: Collection, strideX: nu
169169

170170
// Attached to the main export is an `ndarray` method which returns a dispatch function...
171171
{
172-
dispatch.ndarray( addon, fallbackWithOffsets ); // $ExpectType DispatcherWithOffsets
172+
dispatch.ndarray( addon, fallbackWithOffsets ); // $ExpectType DispatcherWithOffsets<number>
173173
}
174174

175175
// The compiler throws an error if the `ndarray` method is not provided a first argument which is an add-on function...
@@ -204,7 +204,7 @@ function fallbackWithOffsets( N: number, dtypeX: any, x: Collection, strideX: nu
204204

205205
const f = dispatch.ndarray( addon, fallbackWithOffsets );
206206

207-
f( x.length, 'float64', x, 1, 0 ); // $ExpectType Collection
207+
f( x.length, 'float64', x, 1, 0 ); // $ExpectType Collection<number>
208208
}
209209

210210
// The compiler throws an error if the returned function is not provided a first argument which is a number...

0 commit comments

Comments
 (0)