Skip to content

Commit 3cb6fe5

Browse files
committed
fix: update import path for Collection type definition and infer thisArg type
Ref: bde4671
1 parent cff1be6 commit 3cb6fe5

File tree

2 files changed

+29
-30
lines changed

2 files changed

+29
-30
lines changed

lib/node_modules/@stdlib/strided/dispatch-by/docs/types/index.d.ts

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,22 @@
2222

2323
/// <reference types="@stdlib/types"/>
2424

25-
import { ArrayLike } from '@stdlib/types/array';
26-
import { Collection } from '@stdlib/types/object';
25+
import { ArrayLike, Collection } from '@stdlib/types/array';
2726

2827
/**
2928
* Returns the accessed value.
3029
*
3130
* @returns accessed value
3231
*/
33-
type NullaryCallback = () => any;
32+
type NullaryCallback<T> = ( this: T ) => any;
3433

3534
/**
3635
* Returns the accessed value.
3736
*
3837
* @param values - array element value
3938
* @returns accessed value
4039
*/
41-
type UnaryCallback = ( values: any ) => any;
40+
type UnaryCallback<T> = ( this: T, values: any ) => any;
4241

4342
/**
4443
* Returns the accessed value.
@@ -47,7 +46,7 @@ type UnaryCallback = ( values: any ) => any;
4746
* @param idx - iteration index
4847
* @returns accessed value
4948
*/
50-
type BinaryCallback = ( values: any, idx: number ) => any;
49+
type BinaryCallback<T> = ( this: T, values: any, idx: number ) => any;
5150

5251
/**
5352
* Returns the accessed value.
@@ -57,7 +56,7 @@ type BinaryCallback = ( values: any, idx: number ) => any;
5756
* @param indices - strided indices (offset + idx*stride)
5857
* @returns accessed value
5958
*/
60-
type TernaryCallback = ( values: any, idx: number, indices: Array<number> ) => any; // tslint-disable-line max-line-length
59+
type TernaryCallback<T> = ( this: T, values: any, idx: number, indices: Array<number> ) => any;
6160

6261
/**
6362
* Returns the accessed value.
@@ -68,7 +67,7 @@ type TernaryCallback = ( values: any, idx: number, indices: Array<number> ) => a
6867
* @param arrays - input and output arrays
6968
* @returns accessed value
7069
*/
71-
type QuaternaryCallback = ( values: any, idx: number, indices: Array<number>, arrays: Array<Collection> ) => any; // tslint-disable-line max-line-length
70+
type QuaternaryCallback<T> = ( this: T, values: any, idx: number, indices: Array<number>, arrays: Array<Collection> ) => any;
7271

7372
/**
7473
* Returns the accessed value.
@@ -79,7 +78,7 @@ type QuaternaryCallback = ( values: any, idx: number, indices: Array<number>, ar
7978
* @param arrays - input and output arrays
8079
* @returns accessed value
8180
*/
82-
type Callback = NullaryCallback | UnaryCallback | BinaryCallback | TernaryCallback | QuaternaryCallback; // tslint-disable-line max-line-length
81+
type Callback<T> = NullaryCallback<T> | UnaryCallback<T> | BinaryCallback<T> | TernaryCallback<T> | QuaternaryCallback<T>;
8382

8483
/**
8584
* Strided array function.
@@ -130,7 +129,7 @@ type Callback = NullaryCallback | UnaryCallback | BinaryCallback | TernaryCallba
130129
* }
131130
* }
132131
*/
133-
type StridedArrayFcnNoData = ( arrays: Array<ArrayLike<any>>, shape: Array<number>, strides: Array<number>, clbk: Callback, thisArg?: any ) => void; // tslint:disable-line:max-line-length
132+
type StridedArrayFcnNoData<T> = ( arrays: Array<Collection>, shape: Array<number>, strides: Array<number>, clbk: Callback<T>, thisArg?: ThisParameterType<Callback<T>> ) => void;
134133

135134
/**
136135
* Strided array function.
@@ -182,7 +181,7 @@ type StridedArrayFcnNoData = ( arrays: Array<ArrayLike<any>>, shape: Array<numbe
182181
* }
183182
* }
184183
*/
185-
type StridedArrayFcnWithData = ( arrays: Array<ArrayLike<any>>, shape: Array<number>, strides: Array<number>, data: any, clbk: Callback, thisArg?: any ) => void; // tslint:disable-line:max-line-length
184+
type StridedArrayFcnWithData<T> = ( arrays: Array<Collection>, shape: Array<number>, strides: Array<number>, data: any, clbk: Callback<T>, thisArg?: ThisParameterType<Callback<T>> ) => void;
186185

187186
/**
188187
* Strided array function.
@@ -194,7 +193,7 @@ type StridedArrayFcnWithData = ( arrays: Array<ArrayLike<any>>, shape: Array<num
194193
* @param clbk - callback function
195194
* @param thisArg - execution context
196195
*/
197-
type StridedArrayFcn = StridedArrayFcnNoData | StridedArrayFcnWithData;
196+
type StridedArrayFcn<T> = StridedArrayFcnNoData<T> | StridedArrayFcnWithData<T>;
198197

199198
/**
200199
* Strided array function using alternative indexing semantics.
@@ -238,7 +237,7 @@ type StridedArrayFcn = StridedArrayFcnNoData | StridedArrayFcnWithData;
238237
* }
239238
* }
240239
*/
241-
type StridedArrayFcnWithOffsetsNoData = ( arrays: Array<ArrayLike<any>>, shape: Array<number>, strides: Array<number>, offsets: Array<number>, clbk: Callback, thisArg?: any ) => void; // tslint:disable-line:max-line-length
240+
type StridedArrayFcnWithOffsetsNoData<T> = ( arrays: Array<Collection>, shape: Array<number>, strides: Array<number>, offsets: Array<number>, clbk: Callback<T>, thisArg?: ThisParameterType<Callback<T>> ) => void;
242241

243242
/**
244243
* Strided array function using alternative indexing semantics.
@@ -283,7 +282,7 @@ type StridedArrayFcnWithOffsetsNoData = ( arrays: Array<ArrayLike<any>>, shape:
283282
* }
284283
* }
285284
*/
286-
type StridedArrayFcnWithOffsetsData = ( arrays: Array<ArrayLike<any>>, shape: Array<number>, strides: Array<number>, offsets: Array<number>, data: any, clbk: Callback, thisArg?: any ) => void; // tslint:disable-line:max-line-length
285+
type StridedArrayFcnWithOffsetsData<T> = ( arrays: Array<Collection>, shape: Array<number>, strides: Array<number>, offsets: Array<number>, data: any, clbk: Callback<T>, thisArg?: ThisParameterType<Callback<T>> ) => void;
287286

288287
/**
289288
* Strided array function.
@@ -296,7 +295,7 @@ type StridedArrayFcnWithOffsetsData = ( arrays: Array<ArrayLike<any>>, shape: Ar
296295
* @param clbk - callback function
297296
* @param thisArg - execution context
298297
*/
299-
type StridedArrayFcnWithOffsets = StridedArrayFcnWithOffsetsNoData | StridedArrayFcnWithOffsetsData; // tslint:disable-line:max-line-length
298+
type StridedArrayFcnWithOffsets<T> = StridedArrayFcnWithOffsetsNoData<T> | StridedArrayFcnWithOffsetsData<T>;
300299

301300
/**
302301
* Interface describing a strided array function dispatcher.
@@ -342,7 +341,7 @@ interface Dispatcher {
342341
* strided( x.length, 'float64', x, 1, noop );
343342
* // x => <Float64Array>[ 3.14, 3.14, 3.14, 3.14, 3.14 ]
344343
*/
345-
( N: number, dtypeX: any, x: ArrayLike<any>, strideX: number, clbk: Callback, thisArg?: any ): ArrayLike<any> | void; // tslint:disable-line:max-line-length
344+
<T>( N: number, dtypeX: any, x: Collection, strideX: number, clbk: Callback<T>, thisArg?: ThisParameterType<Callback<T>> ): ArrayLike<any> | void;
346345

347346
/**
348347
* Invokes a strided array function based on the provided array data type(s) using alternative indexing semantics.
@@ -387,7 +386,7 @@ interface Dispatcher {
387386
* strided( x.length, 'float64', x, 1, 0, noop );
388387
* // x => <Float64Array>[ 3.14, 3.14, 3.14, 3.14, 3.14 ]
389388
*/
390-
( N: number, dtypeX: any, x: ArrayLike<any>, strideX: number, offsetX: number, clbk: Callback, thisArg?: any ): ArrayLike<any> | void; // tslint:disable-line:max-line-length unified-signatures
389+
<T>( N: number, dtypeX: any, x: Collection, strideX: number, offsetX: number, clbk: Callback<T>, thisArg?: ThisParameterType<Callback<T>> ): ArrayLike<any> | void; // tslint:disable-line:unified-signatures
391390

392391
/**
393392
* Invokes a strided array function based on the provided array data types.
@@ -430,7 +429,7 @@ interface Dispatcher {
430429
* strided( x.length, 'float64', x, 1, 'float64', y, 1, identity );
431430
* // y => <Float64Array>[ 1.0, 2.0, 3.0 ]
432431
*/
433-
( N: number, dtypeX: any, x: ArrayLike<any>, strideX: number, dtypeY: any, y: ArrayLike<any>, strideY: number, clbk: Callback, thisArg?: any ): ArrayLike<any> | void; // tslint:disable-line:max-line-length
432+
<T>( N: number, dtypeX: any, x: Collection, strideX: number, dtypeY: any, y: Collection, strideY: number, clbk: Callback<T>, thisArg?: ThisParameterType<Callback<T>> ): ArrayLike<any> | void;
434433

435434
/**
436435
* Invokes a strided array function based on the provided array data types using alternative indexing semantics.
@@ -477,7 +476,7 @@ interface Dispatcher {
477476
* strided( x.length, 'float64', x, 1, 0, 'float64', y, 1, 0, identity );
478477
* // y => <Float64Array>[ 1.0, 2.0, 3.0 ]
479478
*/
480-
( N: number, dtypeX: any, x: ArrayLike<any>, strideX: number, offsetX: number, dtypeY: any, y: ArrayLike<any>, strideY: number, offsetY: number, clbk: Callback, thisArg?: any ): ArrayLike<any> | void; // tslint:disable-line:max-line-length
479+
<T>( N: number, dtypeX: any, x: Collection, strideX: number, offsetX: number, dtypeY: any, y: Collection, strideY: number, offsetY: number, clbk: Callback<T>, thisArg?: ThisParameterType<Callback<T>> ): ArrayLike<any> | void;
481480

482481
/**
483482
* Invokes a strided array function based on the provided array data types.
@@ -530,7 +529,7 @@ interface Dispatcher {
530529
* strided( x.length, 'float64', x, 1, 'float64', y, 1, 'float64', z, 1, identity );
531530
* // z => <Float64Array>[ 2.0, 4.0, 6.0 ]
532531
*/
533-
( N: number, dtypeX: any, x: ArrayLike<any>, strideX: number, dtypeY: any, y: ArrayLike<any>, strideY: number, dtypeZ: any, z: ArrayLike<any>, strideZ: number, clbk: Callback, thisArg?: any ): ArrayLike<any> | void; // tslint:disable-line:max-line-length
532+
<T>( N: number, dtypeX: any, x: Collection, strideX: number, dtypeY: any, y: Collection, strideY: number, dtypeZ: any, z: Collection, strideZ: number, clbk: Callback<T>, thisArg?: ThisParameterType<Callback<T>> ): ArrayLike<any> | void;
534533

535534
/**
536535
* Invokes a strided array function based on the provided array data types using alternative indexing semantics.
@@ -588,7 +587,7 @@ interface Dispatcher {
588587
* strided( x.length, 'float64', x, 1, 0, 'float64', y, 1, 0, 'float64', z, 1, 0, identity );
589588
* // z => <Float64Array>[ 2.0, 4.0, 6.0 ]
590589
*/
591-
( N: number, dtypeX: any, x: ArrayLike<any>, strideX: number, offsetX: number, dtypeY: any, y: ArrayLike<any>, strideY: number, offsetY: number, dtypeZ: any, z: ArrayLike<any>, strideZ: number, offsetZ: number, clbk: Callback, thisArg?: any ): ArrayLike<any> | void; // tslint:disable-line:max-line-length
590+
<T>( N: number, dtypeX: any, x: Collection, strideX: number, offsetX: number, dtypeY: any, y: Collection, strideY: number, offsetY: number, dtypeZ: any, z: Collection, strideZ: number, offsetZ: number, clbk: Callback<T>, thisArg?: ThisParameterType<Callback<T>> ): ArrayLike<any> | void;
592591

593592
/**
594593
* Invokes a strided array function based on the provided array data types.
@@ -645,7 +644,7 @@ interface Dispatcher {
645644
* strided( x.length, 'float64', x, 1, 'float64', y, 1, 'float64', z, 1, 'float64', w, 1, identity );
646645
* // w => <Float64Array>[ 3.0, 6.0, 9.0 ]
647646
*/
648-
( N: number, dtypeX: any, x: ArrayLike<any>, strideX: number, dtypeY: any, y: ArrayLike<any>, strideY: number, dtypeZ: any, z: ArrayLike<any>, strideZ: number, dtypeW: any, w: ArrayLike<any>, strideW: number, clbk: Callback, thisArg?: any ): ArrayLike<any> | void; // tslint:disable-line:max-line-length
647+
<T>( N: number, dtypeX: any, x: Collection, strideX: number, dtypeY: any, y: Collection, strideY: number, dtypeZ: any, z: Collection, strideZ: number, dtypeW: any, w: Collection, strideW: number, clbk: Callback<T>, thisArg?: ThisParameterType<Callback<T>> ): ArrayLike<any> | void;
649648

650649
/**
651650
* Invokes a strided array function based on the provided array data types using alternative indexing semantics.
@@ -708,7 +707,7 @@ interface Dispatcher {
708707
* strided( x.length, 'float64', x, 1, 0, 'float64', y, 1, 0, 'float64', z, 1, 0, 'float64', w, 1, 0, identity );
709708
* // w => <Float64Array>[ 3.0, 6.0, 9.0 ]
710709
*/
711-
( N: number, dtypeX: any, x: ArrayLike<any>, strideX: number, offsetX: number, dtypeY: any, y: ArrayLike<any>, strideY: number, offsetY: number, dtypeZ: any, z: ArrayLike<any>, strideZ: number, offsetZ: number, dtypeW: any, w: ArrayLike<any>, strideW: number, offsetW: number, clbk: Callback, thisArg?: any ): ArrayLike<any> | void; // tslint:disable-line:max-line-length
710+
<T>( N: number, dtypeX: any, x: Collection, strideX: number, offsetX: number, dtypeY: any, y: Collection, strideY: number, offsetY: number, dtypeZ: any, z: Collection, strideZ: number, offsetZ: number, dtypeW: any, w: Collection, strideW: number, offsetW: number, clbk: Callback<T>, thisArg?: ThisParameterType<Callback<T>> ): ArrayLike<any> | void;
712711

713712
/**
714713
* Invokes a strided array function based on the provided array data types.
@@ -770,7 +769,7 @@ interface Dispatcher {
770769
* strided( x.length, 'float64', x, 1, 'float64', y, 1, 'float64', z, 1, 'float64', w, 1, 'float64', u, 1, 'float64', v, 1, identity );
771770
* // v => <Float64Array>[ 4.0, 8.0, 12.0 ]
772771
*/
773-
( N: number, dtypeX: any, x: ArrayLike<any>, strideX: number, dtypeY: any, y: ArrayLike<any>, strideY: number, dtypeZ: any, z: ArrayLike<any>, strideZ: number, dtypeW: any, w: ArrayLike<any>, strideW: number, dtypeU: any, u: ArrayLike<any>, strideU: number, clbk: Callback, thisArg?: any ): ArrayLike<any> | void; // tslint:disable-line:max-line-length unified-signatures
772+
<T>( N: number, dtypeX: any, x: Collection, strideX: number, dtypeY: any, y: Collection, strideY: number, dtypeZ: any, z: Collection, strideZ: number, dtypeW: any, w: Collection, strideW: number, dtypeU: any, u: Collection, strideU: number, clbk: Callback<T>, thisArg?: ThisParameterType<Callback<T>> ): ArrayLike<any> | void; // tslint:disable-line:unified-signatures
774773

775774
/**
776775
* Invokes a strided array function based on the provided array data types using alternative indexing semantics.
@@ -835,7 +834,7 @@ interface Dispatcher {
835834
* strided( x.length, 'float64', x, 1, 0, 'float64', y, 1, 0, 'float64', z, 1, 0, 'float64', w, 1, 0, 'float64', u, 1, 0, 'float64', v, 1, 0, identity );
836835
* // v => <Float64Array>[ 4.0, 8.0, 12.0 ]
837836
*/
838-
( N: number, dtypeX: any, x: ArrayLike<any>, strideX: number, offsetX: number, dtypeY: any, y: ArrayLike<any>, strideY: number, offsetY: number, dtypeZ: any, z: ArrayLike<any>, strideZ: number, offsetZ: number, dtypeW: any, w: ArrayLike<any>, strideW: number, offsetW: number, dtypeU: any, u: ArrayLike<any>, strideU: number, offsetU: number, clbk: Callback, thisArg?: any ): ArrayLike<any> | void; // tslint:disable-line:max-line-length unified-signatures
837+
<T>( N: number, dtypeX: any, x: Collection, strideX: number, offsetX: number, dtypeY: any, y: Collection, strideY: number, offsetY: number, dtypeZ: any, z: Collection, strideZ: number, offsetZ: number, dtypeW: any, w: Collection, strideW: number, offsetW: number, dtypeU: any, u: Collection, strideU: number, offsetU: number, clbk: Callback<T>, thisArg?: ThisParameterType<Callback<T>> ): ArrayLike<any> | void; // tslint:disable-line:unified-signatures
839838

840839
/**
841840
* Invokes a strided array function based on the provided array data types.
@@ -896,7 +895,7 @@ interface Dispatcher {
896895
* strided( x.length, 'float64', x, 1, 'float64', y, 1, 'float64', z, 1, 'float64', w, 1, 'float64', u, 1, 'float64', v, 1, identity );
897896
* // v => <Float64Array>[ 4.0, 8.0, 12.0 ]
898897
*/
899-
( N: number, dtypeX: any, x: ArrayLike<any>, strideX: number, dtypeY: any, y: ArrayLike<any>, strideY: number, dtypeZ: any, z: ArrayLike<any>, strideZ: number, dtypeW: any, w: ArrayLike<any>, strideW: number, dtypeU: any, u: ArrayLike<any>, strideU: number, ...args: Array<any> ): ArrayLike<any> | void; // tslint:disable-line:max-line-length unified-signatures
898+
( N: number, dtypeX: any, x: Collection, strideX: number, dtypeY: any, y: Collection, strideY: number, dtypeZ: any, z: Collection, strideZ: number, dtypeW: any, w: Collection, strideW: number, dtypeU: any, u: Collection, strideU: number, ...args: Array<any> ): ArrayLike<any> | void; // tslint:disable-line:unified-signatures
900899

901900
/**
902901
* Invokes a strided array function based on the provided array data types using alternative indexing semantics.
@@ -962,7 +961,7 @@ interface Dispatcher {
962961
* strided( x.length, 'float64', x, 1, 0, 'float64', y, 1, 0, 'float64', z, 1, 0, 'float64', w, 1, 0, 'float64', u, 1, 0, 'float64', v, 1, 0, identity );
963962
* // v => <Float64Array>[ 4.0, 8.0, 12.0 ]
964963
*/
965-
( N: number, dtypeX: any, x: ArrayLike<any>, strideX: number, offsetX: number, dtypeY: any, y: ArrayLike<any>, strideY: number, offsetY: number, dtypeZ: any, z: ArrayLike<any>, strideZ: number, offsetZ: number, dtypeW: any, w: ArrayLike<any>, strideW: number, offsetW: number, dtypeU: any, u: ArrayLike<any>, strideU: number, offsetU: number, ...args: Array<any> ): ArrayLike<any> | void; // tslint:disable-line:max-line-length unified-signatures
964+
( N: number, dtypeX: any, x: Collection, strideX: number, offsetX: number, dtypeY: any, y: Collection, strideY: number, offsetY: number, dtypeZ: any, z: Collection, strideZ: number, offsetZ: number, dtypeW: any, w: Collection, strideW: number, offsetW: number, dtypeU: any, u: Collection, strideU: number, offsetU: number, ...args: Array<any> ): ArrayLike<any> | void; // tslint:disable-line:unified-signatures
966965
}
967966

968967
/**
@@ -1010,7 +1009,7 @@ interface Dispatcher {
10101009
* strided( x.length, 'float64', x, 1, 'float64', y, 1, identity );
10111010
* // y => <Float64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0 ]
10121011
*/
1013-
declare function dispatchBy( fcns: StridedArrayFcn | ArrayLike<StridedArrayFcn>, types: ArrayLike<any>, data: ArrayLike<any> | null, nargs: number, nin: number, nout: number ): Dispatcher; // tslint:disable-line:max-line-length
1012+
declare function dispatchBy<T = unknown>( fcns: StridedArrayFcn<T> | ArrayLike<StridedArrayFcn<T>>, types: ArrayLike<any>, data: ArrayLike<any> | null, nargs: number, nin: number, nout: number ): Dispatcher;
10141013

10151014
/**
10161015
* Returns a strided array function interface which accepts a callback function and performs multiple dispatch while supporting alternative indexing semantics.
@@ -1057,7 +1056,7 @@ declare function dispatchBy( fcns: StridedArrayFcn | ArrayLike<StridedArrayFcn>,
10571056
* strided( x.length, 'float64', x, 1, 0, 'float64', y, 1, 0, identity );
10581057
* // y => <Float64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0 ]
10591058
*/
1060-
declare function dispatchBy( fcns: StridedArrayFcnWithOffsets | ArrayLike<StridedArrayFcnWithOffsets>, types: ArrayLike<any>, data: ArrayLike<any> | null, nargs: number, nin: number, nout: number ): Dispatcher; // tslint:disable-line:max-line-length unified-signatures
1059+
declare function dispatchBy<T = unknown>( fcns: StridedArrayFcnWithOffsets<T> | ArrayLike<StridedArrayFcnWithOffsets<T>>, types: ArrayLike<any>, data: ArrayLike<any> | null, nargs: number, nin: number, nout: number ): Dispatcher; // tslint:disable-line:unified-signatures
10611060

10621061

10631062
// EXPORTS //

lib/node_modules/@stdlib/strided/dispatch-by/docs/types/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function identity( ...values: Array<any> ): Array<any> {
101101
* @param clbk - callback
102102
* @param thisArg - callback execution context
103103
*/
104-
function strided( arrays: Array<ArrayLike<any>>, shape: Array<number>, strides: Array<number>, fcn: ( x: any ) => any, clbk: ( ...args: Array<any> ) => any, thisArg?: any ): void { // tslint:disable-line:max-line-length
104+
function strided( arrays: Array<ArrayLike<any>>, shape: Array<number>, strides: Array<number>, fcn: ( x: any ) => any, clbk: ( ...args: Array<any> ) => any, thisArg?: any ): void {
105105
let sx;
106106
let sy;
107107
let ix;
@@ -140,7 +140,7 @@ function strided( arrays: Array<ArrayLike<any>>, shape: Array<number>, strides:
140140
* @param clbk - callback
141141
* @param thisArg - callback execution context
142142
*/
143-
function stridedWithOffsets( arrays: Array<ArrayLike<any>>, shape: Array<number>, strides: Array<number>, offsets: Array<number>, fcn: ( x: any ) => any, clbk: ( ...args: Array<any> ) => any, thisArg?: any ): void { // tslint:disable-line:max-line-length
143+
function stridedWithOffsets( arrays: Array<ArrayLike<any>>, shape: Array<number>, strides: Array<number>, offsets: Array<number>, fcn: ( x: any ) => any, clbk: ( ...args: Array<any> ) => any, thisArg?: any ): void {
144144
let sx;
145145
let sy;
146146
let ix;

0 commit comments

Comments
 (0)