Skip to content

Commit

Permalink
fix: update import path for Collection type definition and use gene…
Browse files Browse the repository at this point in the history
…rics

Ref: bde4671
  • Loading branch information
kgryte committed Sep 11, 2023
1 parent 5573a67 commit e2a2a33
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
30 changes: 15 additions & 15 deletions lib/node_modules/@stdlib/strided/base/map-by/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,71 +20,71 @@

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

import { Collection } from '@stdlib/types/object';
import { Collection } from '@stdlib/types/array';

/**
* Returns the accessed value.
*
* @returns accessed value
*/
type NullaryCallback = () => any;
type NullaryCallback<V, W> = ( this: W ) => V;

/**
* Returns the accessed value.
*
* @param values - array element value
* @param value - array element value
* @returns accessed value
*/
type UnaryCallback = ( values: any ) => any;
type UnaryCallback<U, V, W> = ( this: W, value: U ) => V;

/**
* Returns the accessed value.
*
* @param values - array element value
* @param value - array element value
* @param idx - iteration index
* @returns accessed value
*/
type BinaryCallback = ( values: any, idx: number ) => any;
type BinaryCallback<U, V, W> = ( this: W, value: U, idx: number ) => V;

/**
* Returns the accessed value.
*
* @param values - array element value
* @param value - array element value
* @param idx - iteration index
* @param indices - strided indices (offset + idx*stride)
* @returns accessed value
*/
type TernaryCallback = ( values: any, idx: number, indices: Array<number> ) => any; // tslint-disable-line max-line-length
type TernaryCallback<U, V, W> = ( this: W, value: U, idx: number, indices: Array<number> ) => V;

/**
* Returns the accessed value.
*
* @param values - array element value
* @param value - array element value
* @param idx - iteration index
* @param indices - strided indices (offset + idx*stride)
* @param arrays - input and output arrays
* @returns accessed value
*/
type QuaternaryCallback = ( values: any, idx: number, indices: Array<number>, arrays: Array<Collection> ) => any; // tslint-disable-line max-line-length
type QuaternaryCallback<T, U, V, W> = ( this: W, value: U, idx: number, indices: Array<number>, arrays: [ Collection<T>, Collection<V> ] ) => V;

/**
* Returns the accessed value.
*
* @param values - array element value
* @param value - array element value
* @param idx - iteration index
* @param indices - strided indices (offset + idx*stride)
* @param arrays - input and output arrays
* @returns accessed value
*/
type Callback = NullaryCallback | UnaryCallback | BinaryCallback | TernaryCallback | QuaternaryCallback; // tslint-disable-line max-line-length
type Callback<T, U, V, W> = NullaryCallback<V, W> | UnaryCallback<U, V, W> | BinaryCallback<U, V, W> | TernaryCallback<U, V, W> | QuaternaryCallback<T, U, V, W>;

/**
* Callback invoked for each indexed strided array element retrieved via a callback function.
*
* @param value - strided array element
* @returns result
*/
type Unary = ( value: any ) => any;
type Unary<T, U> = ( value: T ) => U;

/**
* Interface describing `mapBy`.
Expand Down Expand Up @@ -116,7 +116,7 @@ interface Routine {
* mapBy( x.length, x, 1, y, 1, abs, accessor );
* // y => [ 2.0, 4.0, 6.0, 8.0, 10.0 ]
*/
( N: number, x: Collection, strideX: number, y: Collection, strideY: number, fcn: Unary, clbk: Callback, thisArg?: any ): Collection; // tslint:disable-line:max-line-length
<T = unknown, U = unknown, V = unknown, W = unknown>( N: number, x: Collection<T>, strideX: number, y: Collection<V>, strideY: number, fcn: Unary<T, U>, clbk: Callback<T, U, V, W>, thisArg?: ThisParameterType<Callback<T, U, V, W>> ): Collection<V>;

/**
* Applies a unary function to each element retrieved from a strided input array according to a callback function and assigns results to a strided output array using alternative indexing semantics.
Expand Down Expand Up @@ -146,7 +146,7 @@ interface Routine {
* mapBy.ndarray( x.length, x, 1, 0, y, 1, 0, abs, accessor );
* // y => [ 2.0, 4.0, 6.0, 8.0, 10.0 ]
*/
ndarray( N: number, x: Collection, strideX: number, offsetX: number, y: Collection, strideY: number, offsetY: number, fcn: Unary, clbk: Callback, thisArg?: any ): Collection; // tslint:disable-line:max-line-length
ndarray<T = unknown, U = unknown, V = unknown, W = unknown>( N: number, x: Collection<T>, strideX: number, offsetX: number, y: Collection<V>, strideY: number, offsetY: number, fcn: Unary<T, U>, clbk: Callback<T, U, V, W>, thisArg?: ThisParameterType<Callback<T, U, V, W>> ): Collection<V>;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ function unary( x: number ): number {
const x = new Float64Array( 10 );
const y = new Float64Array( 10 );

mapBy( x.length, x, 1, y, 1, unary, accessor ); // $ExpectType Collection
mapBy( x.length, x, 1, y, 1, unary, accessor, {} ); // $ExpectType Collection
mapBy( x.length, x, 1, y, 1, unary, accessor ); // $ExpectType Collection<number>
mapBy( x.length, x, 1, y, 1, unary, accessor, {} ); // $ExpectType Collection<number>
}

// The compiler throws an error if the function is provided a first argument which is not a number...
Expand Down Expand Up @@ -169,8 +169,8 @@ function unary( x: number ): number {
const x = new Float64Array( 10 );
const y = new Float64Array( 10 );

mapBy.ndarray( x.length, x, 1, 0, y, 1, 0, unary, accessor ); // $ExpectType Collection
mapBy.ndarray( x.length, x, 1, 0, y, 1, 0, unary, accessor, {} ); // $ExpectType Collection
mapBy.ndarray( x.length, x, 1, 0, y, 1, 0, unary, accessor ); // $ExpectType Collection<number>
mapBy.ndarray( x.length, x, 1, 0, y, 1, 0, unary, accessor, {} ); // $ExpectType Collection<number>
}

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

0 comments on commit e2a2a33

Please sign in to comment.