Skip to content

Commit fb02af2

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

File tree

2 files changed

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

2 files changed

+16
-16
lines changed

lib/node_modules/@stdlib/strided/base/unary-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.
@@ -38,7 +38,7 @@ import { Collection } from '@stdlib/types/object';
3838
* // Call into native add-on...
3939
* }
4040
*/
41-
type AddonFcn = ( N: number, dtypeX: number, x: Collection, strideX: number, dtypeY: number, y: Collection, strideY: number ) => any; // tslint:disable-line:max-line-length
41+
type AddonFcn<T, U, V> = ( N: number, dtypeX: number, x: Collection<T>, strideX: number, dtypeY: number, y: Collection<U>, strideY: number ) => V;
4242

4343
/**
4444
* Fallback function.
@@ -56,7 +56,7 @@ type AddonFcn = ( N: number, dtypeX: number, x: Collection, strideX: number, dty
5656
* // Fallback JavaScript implementation...
5757
* }
5858
*/
59-
type FallbackFcn = ( N: number, dtypeX: any, x: Collection, strideX: number, dtypeY: any, y: Collection, strideY: number ) => any; // tslint:disable-line:max-line-length
59+
type FallbackFcn<T, U, V> = ( N: number, dtypeX: any, x: Collection<T>, strideX: number, dtypeY: any, y: Collection<U>, strideY: number ) => V;
6060

6161
/**
6262
* Fallback function supporting alternative indexing semantics.
@@ -76,7 +76,7 @@ type FallbackFcn = ( N: number, dtypeX: any, x: Collection, strideX: number, dty
7676
* // Fallback JavaScript implementation...
7777
* }
7878
*/
79-
type FallbackFcnWithOffsets = ( N: number, dtypeX: any, x: Collection, strideX: number, offsetX: number, dtypeY: any, y: Collection, strideY: number, offsetY: number ) => any; // tslint:disable-line:max-line-length
79+
type FallbackFcnWithOffsets<T, U, V> = ( N: number, dtypeX: any, x: Collection<T>, strideX: number, offsetX: number, dtypeY: any, y: Collection<U>, strideY: number, offsetY: number ) => V;
8080

8181
/**
8282
* Dispatches to a native add-on.
@@ -90,7 +90,7 @@ type FallbackFcnWithOffsets = ( N: number, dtypeX: any, x: Collection, strideX:
9090
* @param strideY - `y` stride length
9191
* @returns `y`
9292
*/
93-
type Dispatcher = ( N: number, dtypeX: any, x: Collection, strideX: number, dtypeY: any, y: Collection, strideY: number ) => Collection; // tslint:disable-line:max-line-length
93+
type Dispatcher<T, U> = ( N: number, dtypeX: any, x: Collection<T>, strideX: number, dtypeY: any, y: Collection<U>, strideY: number ) => Collection<U>;
9494

9595
/**
9696
* Dispatches to a native add-on.
@@ -106,7 +106,7 @@ type Dispatcher = ( N: number, dtypeX: any, x: Collection, strideX: number, dtyp
106106
* @param offsetY - starting `y` index
107107
* @returns `y`
108108
*/
109-
type DispatcherWithOffsets = ( N: number, dtypeX: any, x: Collection, strideX: number, offsetX: number, dtypeY: any, y: Collection, strideY: number, offsetY: number ) => Collection; // tslint:disable-line:max-line-length
109+
type DispatcherWithOffsets<T, U> = ( N: number, dtypeX: any, x: Collection<T>, strideX: number, offsetX: number, dtypeY: any, y: Collection<U>, strideY: number, offsetY: number ) => Collection<U>;
110110

111111
/**
112112
* Interface for creating a native add-on dispatcher.
@@ -136,7 +136,7 @@ interface Dispatch {
136136
* // Invoke the dispatch function with strided array arguments:
137137
* f( 2, 'generic', [ 1, 2 ], 1, 'generic', [ 0, 0 ], 1 );
138138
*/
139-
( addon: AddonFcn, fallback: FallbackFcn ): Dispatcher;
139+
<T = unknown, U = unknown, V = unknown>( addon: AddonFcn<T, U, V>, fallback: FallbackFcn<T, U, V> ): Dispatcher<T, U>;
140140

141141
/**
142142
* Returns a function which dispatches to a native add-on applying a unary function to an input strided array using alternative indexing semantics.
@@ -162,7 +162,7 @@ interface Dispatch {
162162
* // Invoke the dispatch function with strided array arguments:
163163
* f( 2, 'generic', [ 1, 2 ], 1, 0, 'generic', [ 0, 0 ], 1, 0 );
164164
*/
165-
ndarray( addon: AddonFcn, fallback: FallbackFcnWithOffsets ): DispatcherWithOffsets; // tslint:disable-line:max-line-length
165+
ndarray<T = unknown, U = unknown, V = unknown>( addon: AddonFcn<T, U, V>, fallback: FallbackFcnWithOffsets<T, U, V> ): DispatcherWithOffsets<T, U>;
166166
}
167167

168168
/**

lib/node_modules/@stdlib/strided/base/unary-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

@@ -35,7 +35,7 @@ import dispatch = require( './index' );
3535
* @param y - output array
3636
* @param strideY - `y` stride length
3737
*/
38-
function addon( N: number, dtypeX: number, x: Collection, strideX: number, dtypeY: number, y: Collection, strideY: number ): void { // tslint:disable-line:max-line-length
38+
function addon( N: number, dtypeX: number, x: Collection<number>, strideX: number, dtypeY: number, y: Collection<number>, strideY: number ): void {
3939
let i;
4040
if ( dtypeX !== dtypeY ) {
4141
throw new Error( 'beep' );
@@ -56,7 +56,7 @@ function addon( N: number, dtypeX: number, x: Collection, strideX: number, dtype
5656
* @param y - output array
5757
* @param strideY - `y` stride length
5858
*/
59-
function fallback( N: number, dtypeX: any, x: Collection, strideX: number, dtypeY: any, y: Collection, strideY: number ): void { // tslint:disable-line:max-line-length
59+
function fallback( N: number, dtypeX: any, x: Collection<number>, strideX: number, dtypeY: any, y: Collection<number>, strideY: number ): void {
6060
let i;
6161
if ( dtypeX !== dtypeY ) {
6262
throw new Error( 'beep' );
@@ -79,7 +79,7 @@ function fallback( N: number, dtypeX: any, x: Collection, strideX: number, dtype
7979
* @param strideY - `y` stride length
8080
* @param offsetY - starting `y` index
8181
*/
82-
function fallbackWithOffsets( N: number, dtypeX: any, x: Collection, strideX: number, offsetX: number, dtypeY: any, y: Collection, strideY: number, offsetY: number ): void { // tslint:disable-line:max-line-length
82+
function fallbackWithOffsets( N: number, dtypeX: any, x: Collection<number>, strideX: number, offsetX: number, dtypeY: any, y: Collection<number>, strideY: number, offsetY: number ): void {
8383
let i;
8484
if ( dtypeX !== dtypeY ) {
8585
throw new Error( 'beep' );
@@ -94,7 +94,7 @@ function fallbackWithOffsets( N: number, dtypeX: any, x: Collection, strideX: nu
9494

9595
// The function returns a dispatch function...
9696
{
97-
dispatch( addon, fallback ); // $ExpectType Dispatcher
97+
dispatch( addon, fallback ); // $ExpectType Dispatcher<number, number>
9898
}
9999

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

131131
const f = dispatch( addon, fallback );
132132

133-
f( x.length, 'float64', x, 1, 'float64', y, 1 ); // $ExpectType Collection
133+
f( x.length, 'float64', x, 1, 'float64', y, 1 ); // $ExpectType Collection<number>
134134
}
135135

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

215215
// Attached to the main export is an `ndarray` method which returns a dispatch function...
216216
{
217-
dispatch.ndarray( addon, fallbackWithOffsets ); // $ExpectType DispatcherWithOffsets
217+
dispatch.ndarray( addon, fallbackWithOffsets ); // $ExpectType DispatcherWithOffsets<number, number>
218218
}
219219

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

251251
const f = dispatch.ndarray( addon, fallbackWithOffsets );
252252

253-
f( x.length, 'float64', x, 1, 0, 'float64', y, 1, 0 ); // $ExpectType Collection
253+
f( x.length, 'float64', x, 1, 0, 'float64', y, 1, 0 ); // $ExpectType Collection<number>
254254
}
255255

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

0 commit comments

Comments
 (0)