Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify types of array/slice and array/base/slice via use of generic type parameter #1318

Merged
merged 5 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 4 additions & 170 deletions lib/node_modules/@stdlib/array/base/slice/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

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

import { Collection, Complex128Array, Complex64Array } from '@stdlib/types/array';
import { Collection, TypedArray, ComplexTypedArray } from '@stdlib/types/array';

/**
* Returns a shallow copy of a portion of an array.
Expand All @@ -37,160 +37,6 @@ import { Collection, Complex128Array, Complex64Array } from '@stdlib/types/array
*
* var out = slice( x, 0, 3 );
* // returns <Float64Array>[ 1.0, 2.0, 3.0 ]
*/
declare function slice( x: Float64Array, start: number, end: number ): Float64Array;

/**
* Returns a shallow copy of a portion of an array.
*
* @param x - input array
* @param start - starting index (inclusive)
* @param end - ending index (exclusive)
* @returns output array
*
* @example
* var Float32Array = require( '@stdlib/array/float32' );
*
* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] );
*
* var out = slice( x, 0, 3 );
* // returns <Float32Array>[ 1.0, 2.0, 3.0 ]
*/
declare function slice( x: Float32Array, start: number, end: number ): Float32Array;

/**
* Returns a shallow copy of a portion of an array.
*
* @param x - input array
* @param start - starting index (inclusive)
* @param end - ending index (exclusive)
* @returns output array
*
* @example
* var Int32Array = require( '@stdlib/array/int32' );
*
* var x = new Int32Array( [ 1, 2, 3 ] );
*
* var out = slice( x, 0, 3 );
* // returns <Int32Array>[ 1, 2, 3 ]
*/
declare function slice( x: Int32Array, start: number, end: number ): Int32Array;

/**
* Returns a shallow copy of a portion of an array.
*
* @param x - input array
* @param start - starting index (inclusive)
* @param end - ending index (exclusive)
* @returns output array
*
* @example
* var Int16Array = require( '@stdlib/array/int16' );
*
* var x = new Int16Array( [ 1, 2, 3 ] );
*
* var out = slice( x, 0, 3 );
* // returns <Int16Array>[ 1, 2, 3 ]
*/
declare function slice( x: Int16Array, start: number, end: number ): Int16Array;

/**
* Returns a shallow copy of a portion of an array.
*
* @param x - input array
* @param start - starting index (inclusive)
* @param end - ending index (exclusive)
* @returns output array
*
* @example
* var Int8Array = require( '@stdlib/array/int8' );
*
* var x = new Int8Array( [ 1, 2, 3 ] );
*
* var out = slice( x, 0, 3 );
* // returns <Int8Array>[ 1, 2, 3 ]
*/
declare function slice( x: Int8Array, start: number, end: number ): Int8Array;

/**
* Returns a shallow copy of a portion of an array.
*
* @param x - input array
* @param start - starting index (inclusive)
* @param end - ending index (exclusive)
* @returns output array
*
* @example
* var Uint32Array = require( '@stdlib/array/uint32' );
*
* var x = new Uint32Array( [ 1, 2, 3 ] );
*
* var out = slice( x, 0, 3 );
* // returns <Uint32Array>[ 1, 2, 3 ]
*/
declare function slice( x: Uint32Array, start: number, end: number ): Uint32Array;

/**
* Returns a shallow copy of a portion of an array.
*
* @param x - input array
* @param start - starting index (inclusive)
* @param end - ending index (exclusive)
* @returns output array
*
* @example
* var Uint16Array = require( '@stdlib/array/uint16' );
*
* var x = new Uint16Array( [ 1, 2, 3 ] );
*
* var out = slice( x, 0, 3 );
* // returns <Uint16Array>[ 1, 2, 3 ]
*/
declare function slice( x: Uint16Array, start: number, end: number ): Uint16Array;

/**
* Returns a shallow copy of a portion of an array.
*
* @param x - input array
* @param start - starting index (inclusive)
* @param end - ending index (exclusive)
* @returns output array
*
* @example
* var Uint8Array = require( '@stdlib/array/uint8' );
*
* var x = new Uint8Array( [ 1, 2, 3 ] );
*
* var out = slice( x, 0, 3 );
* // returns <Uint8Array>[ 1, 2, 3 ]
*/
declare function slice( x: Uint8Array, start: number, end: number ): Uint8Array;

/**
* Returns a shallow copy of a portion of an array.
*
* @param x - input array
* @param start - starting index (inclusive)
* @param end - ending index (exclusive)
* @returns output array
*
* @example
* var Uint8ClampedArray = require( '@stdlib/array/uint8c' );
*
* var x = new Uint8ClampedArray( [ 1, 2, 3 ] );
*
* var out = slice( x, 0, 3 );
* // returns <Uint8ClampedArray>[ 1, 2, 3 ]
*/
declare function slice( x: Uint8ClampedArray, start: number, end: number ): Uint8ClampedArray;

/**
* Returns a shallow copy of a portion of an array.
*
* @param x - input array
* @param start - starting index (inclusive)
* @param end - ending index (exclusive)
* @returns output array
*
* @example
* var Complex128Array = require( '@stdlib/array/complex128' );
Expand All @@ -200,7 +46,7 @@ declare function slice( x: Uint8ClampedArray, start: number, end: number ): Uint
* var out = slice( x, 0, 3 );
* // returns <Complex128Array>[ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]
*/
declare function slice( x: Complex128Array, start: number, end: number ): Complex128Array;
declare function slice<T extends TypedArray | ComplexTypedArray>( x: T, start: number, end: number ): T;

/**
* Returns a shallow copy of a portion of an array.
Expand All @@ -211,22 +57,10 @@ declare function slice( x: Complex128Array, start: number, end: number ): Comple
* @returns output array
*
* @example
* var Complex64Array = require( '@stdlib/array/complex64' );
*
* var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
* var x = [ 1, 2, 3 ];
*
* var out = slice( x, 0, 3 );
* // returns <Complex64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]
*/
declare function slice( x: Complex64Array, start: number, end: number ): Complex64Array;

/**
* Returns a shallow copy of a portion of an array.
*
* @param x - input array
* @param start - starting index (inclusive)
* @param end - ending index (exclusive)
* @returns output array
* // returns [ 1, 2, 3 ]
*
* @example
* var x = [ 1, 2, 3, 4, 5, 6 ];
Expand Down
Loading
Loading