From a713ec2ceb39a1f6619118b3d541cafb592b87d9 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Fri, 16 Feb 2024 11:43:14 -0500 Subject: [PATCH 01/20] refactor: use data type map instead of overloads --- .../@stdlib/array/empty/docs/types/index.d.ts | 227 +----------------- lib/node_modules/@stdlib/types/index.d.ts | 31 +++ 2 files changed, 39 insertions(+), 219 deletions(-) diff --git a/lib/node_modules/@stdlib/array/empty/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/empty/docs/types/index.d.ts index 35d6bd36696a..08bab7a80134 100644 --- a/lib/node_modules/@stdlib/array/empty/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/empty/docs/types/index.d.ts @@ -20,228 +20,11 @@ /// -import { Complex128Array, Complex64Array, DataType } from '@stdlib/types/array'; +import { ArrayDataTypeMap } from '@stdlib/types/array'; /** * Creates an uninitialized array having a specified length. * -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param length - array length -* @param dtype - data type -* @returns empty array -* -* @example -* var arr = empty( 2, 'float64' ); -* // returns -*/ -declare function empty( length: number, dtype: 'float64' ): Float64Array; - -/** -* Creates an uninitialized array having a specified length. -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param length - array length -* @param dtype - data type -* @returns empty array -* -* @example -* var arr = empty( 2, 'float32' ); -* // returns -*/ -declare function empty( length: number, dtype: 'float32' ): Float32Array; - -/** -* Creates an uninitialized array having a specified length. -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param length - array length -* @param dtype - data type -* @returns empty array -* -* @example -* var arr = empty( 2, 'complex128' ); -* // returns -*/ -declare function empty( length: number, dtype: 'complex128' ): Complex128Array; - -/** -* Creates an uninitialized array having a specified length. -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param length - array length -* @param dtype - data type -* @returns empty array -* -* @example -* var arr = empty( 2, 'complex64' ); -* // returns -*/ -declare function empty( length: number, dtype: 'complex64' ): Complex64Array; - -/** -* Creates an uninitialized array having a specified length. -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param length - array length -* @param dtype - data type -* @returns empty array -* -* @example -* var arr = empty( 2, 'int32' ); -* // returns -*/ -declare function empty( length: number, dtype: 'int32' ): Int32Array; - -/** -* Creates an uninitialized array having a specified length. -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param length - array length -* @param dtype - data type -* @returns empty array -* -* @example -* var arr = empty( 2, 'int16' ); -* // returns -*/ -declare function empty( length: number, dtype: 'int16' ): Int16Array; - -/** -* Creates an uninitialized array having a specified length. -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param length - array length -* @param dtype - data type -* @returns empty array -* -* @example -* var arr = empty( 2, 'int8' ); -* // returns -*/ -declare function empty( length: number, dtype: 'int8' ): Int8Array; - -/** -* Creates an uninitialized array having a specified length. -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param length - array length -* @param dtype - data type -* @returns empty array -* -* @example -* var arr = empty( 2, 'uint32' ); -* // returns -*/ -declare function empty( length: number, dtype: 'uint32' ): Uint32Array; - -/** -* Creates an uninitialized array having a specified length. -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param length - array length -* @param dtype - data type -* @returns empty array -* -* @example -* var arr = empty( 2, 'uint16' ); -* // returns -*/ -declare function empty( length: number, dtype: 'uint16' ): Uint16Array; - -/** -* Creates an uninitialized array having a specified length. -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param length - array length -* @param dtype - data type -* @returns empty array -* -* @example -* var arr = empty( 2, 'uint8' ); -* // returns -*/ -declare function empty( length: number, dtype: 'uint8' ): Uint8Array; - -/** -* Creates an uninitialized array having a specified length. -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param length - array length -* @param dtype - data type -* @returns empty array -* -* @example -* var arr = empty( 2, 'uint8c' ); -* // returns -*/ -declare function empty( length: number, dtype: 'uint8c' ): Uint8ClampedArray; - -/** -* Creates a zero-filled array having a specified length. -* -* @param length - array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var arr = empty( 2, 'generic' ); -* // returns -*/ -declare function empty( length: number, dtype: 'generic' ): Array; - -/** -* Creates an uninitialized array having a specified length. -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - If `dtype` is `'generic'`, the function always returns a zero-filled array. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* * The function recognizes the following data types: * * - `float64`: double-precision floating-point numbers (IEEE 754) @@ -257,6 +40,12 @@ declare function empty( length: number, dtype: 'generic' ): Array; * - `uint8c`: 8-bit unsigned integers clamped to `0-255` * - `generic`: generic JavaScript values * +* ## Notes +* +* - In browser environments, the function always returns zero-filled arrays. +* - If `dtype` is `'generic'`, the function always returns a zero-filled array. +* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. +* * @param length - array length * @param dtype - data type (default: 'float64') * @returns empty array @@ -269,7 +58,7 @@ declare function empty( length: number, dtype: 'generic' ): Array; * var arr = empty( 2, 'float32' ); * // returns */ -declare function empty( length: number, dtype?: DataType ): Float64Array; +declare function empty = 'float64'>( length: number, dtype?: T ): ArrayDataTypeMap[T]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/types/index.d.ts b/lib/node_modules/@stdlib/types/index.d.ts index 12ad4a5c77da..dff4cd77405a 100644 --- a/lib/node_modules/@stdlib/types/index.d.ts +++ b/lib/node_modules/@stdlib/types/index.d.ts @@ -593,6 +593,37 @@ declare module '@stdlib/types/array' { * const x: Collection = [ 1, 2, 3 ]; */ type Collection = Array | TypedArray | ArrayLike; // eslint-disable-line @typescript-eslint/no-explicit-any + + /** + * Type mapping for the following array data types: + * + * - `float64`: double-precision floating-point numbers (IEEE 754) + * - `float32`: single-precision floating-point numbers (IEEE 754) + * - `complex128`: double-precision complex floating-point numbers + * - `complex64`: single-precision complex floating-point numbers + * - `int32`: 32-bit two's complement signed integers + * - `uint32`: 32-bit unsigned integers + * - `int16`: 16-bit two's complement signed integers + * - `uint16`: 16-bit unsigned integers + * - `int8`: 8-bit two's complement signed integers + * - `uint8`: 8-bit unsigned integers + * - `uint8c`: 8-bit unsigned integers clamped to `0-255` + * - `generic`: generic JavaScript values + */ + type ArrayDataTypeMap = { // eslint-disable-line @typescript-eslint/consistent-type-definitions + 'float64': Float64Array; + 'float32': Float32Array; + 'complex128': Complex128Array; + 'complex64': Complex64Array; + 'int32': Int32Array; + 'uint32': Uint32Array; + 'int16': Int16Array; + 'uint16': Uint16Array; + 'int8': Int8Array; + 'uint8': Uint8Array; + 'uint8c': Uint8ClampedArray; + 'generic': Array; + }; } /** From b9ead5eea7939eab8a62c458c6955849d447c808 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sat, 17 Feb 2024 12:17:17 -0500 Subject: [PATCH 02/20] refactor: use data type map instead of overloads --- .../array/one-to/docs/types/index.d.ts | 168 +----------------- .../@stdlib/array/ones/docs/types/index.d.ts | 168 +----------------- .../array/zero-to/docs/types/index.d.ts | 168 +----------------- .../@stdlib/array/zeros/docs/types/index.d.ts | 160 +---------------- 4 files changed, 8 insertions(+), 656 deletions(-) diff --git a/lib/node_modules/@stdlib/array/one-to/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/one-to/docs/types/index.d.ts index f746199a9137..79395ce73c98 100644 --- a/lib/node_modules/@stdlib/array/one-to/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/one-to/docs/types/index.d.ts @@ -20,171 +20,7 @@ /// -import { Complex128Array, Complex64Array, NumericDataType } from '@stdlib/types/array'; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one. -* -* @param n - number of elements -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var arr = oneTo( 2, 'float64' ); -* // returns [ 1.0, 2.0 ] -*/ -declare function oneTo( n: number, dtype: 'float64' ): Float64Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one. -* -* @param n - number of elements -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var arr = oneTo( 2, 'float32' ); -* // returns [ 1.0, 2.0 ] -*/ -declare function oneTo( n: number, dtype: 'float32' ): Float32Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one. -* -* ## Notes -* -* - Each element has an imaginary component equal to `0`. -* -* @param n - number of elements -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var arr = oneTo( 2, 'complex128' ); -* // returns -*/ -declare function oneTo( n: number, dtype: 'complex128' ): Complex128Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one. -* -* ## Notes -* -* - Each element has an imaginary component equal to `0`. -* -* @param n - number of elements -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var arr = oneTo( 2, 'complex64' ); -* // returns -*/ -declare function oneTo( n: number, dtype: 'complex64' ): Complex64Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one. -* -* @param n - number of elements -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var arr = oneTo( 2, 'int32' ); -* // returns [ 1, 2 ] -*/ -declare function oneTo( n: number, dtype: 'int32' ): Int32Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one. -* -* @param n - number of elements -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var arr = oneTo( 2, 'int16' ); -* // returns [ 1, 2 ] -*/ -declare function oneTo( n: number, dtype: 'int16' ): Int16Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one. -* -* @param n - number of elements -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var arr = oneTo( 2, 'int8' ); -* // returns [ 1, 2 ] -*/ -declare function oneTo( n: number, dtype: 'int8' ): Int8Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one. -* -* @param n - number of elements -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var arr = oneTo( 2, 'uint32' ); -* // returns [ 1, 2 ] -*/ -declare function oneTo( n: number, dtype: 'uint32' ): Uint32Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one. -* -* @param n - number of elements -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var arr = oneTo( 2, 'uint16' ); -* // returns [ 1, 2 ] -*/ -declare function oneTo( n: number, dtype: 'uint16' ): Uint16Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one. -* -* @param n - number of elements -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var arr = oneTo( 2, 'uint8' ); -* // returns [ 1, 2 ] -*/ -declare function oneTo( n: number, dtype: 'uint8' ): Uint8Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one. -* -* @param n - number of elements -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var arr = oneTo( 2, 'uint8c' ); -* // returns [ 1, 2 ] -*/ -declare function oneTo( n: number, dtype: 'uint8c' ): Uint8ClampedArray; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one. -* -* @param n - number of elements -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var arr = oneTo( 2, 'generic' ); -* // returns [ 1, 2 ] -*/ -declare function oneTo( n: number, dtype: 'generic' ): Array; +import { ArrayDataTypeMap } from '@stdlib/types/array'; /** * Generates a linearly spaced numeric array whose elements increment by 1 starting from one. @@ -201,7 +37,7 @@ declare function oneTo( n: number, dtype: 'generic' ): Array; * var arr = oneTo( 2, 'float32' ); * // returns [ 1.0, 2.0 ] */ -declare function oneTo( n: number, dtype?: NumericDataType ): Float64Array; +declare function oneTo = 'float64'>( n: number, dtype?: T ): ArrayDataTypeMap[T]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/ones/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/ones/docs/types/index.d.ts index 88a26bd68441..203764b6e027 100644 --- a/lib/node_modules/@stdlib/array/ones/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/ones/docs/types/index.d.ts @@ -20,171 +20,7 @@ /// -import { Complex128Array, Complex64Array, DataType } from '@stdlib/types/array'; - -/** -* Creates an array filled with ones and having a specified length. -* -* @param length - array length -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = ones( 2, 'float64' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function ones( length: number, dtype: 'float64' ): Float64Array; - -/** -* Creates an array filled with ones and having a specified length. -* -* @param length - array length -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = ones( 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function ones( length: number, dtype: 'float32' ): Float32Array; - -/** -* Creates an array filled with ones and having a specified length. -* -* ## Notes -* -* - Each entry has a real component equal to `1` and an imaginary component equal to `0`. -* -* @param length - array length -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = ones( 2, 'complex128' ); -* // returns -*/ -declare function ones( length: number, dtype: 'complex128' ): Complex128Array; - -/** -* Creates an array filled with ones and having a specified length. -* -* ## Notes -* -* - Each entry has a real component equal to `1` and an imaginary component equal to `0`. -* -* @param length - array length -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = ones( 2, 'complex64' ); -* // returns -*/ -declare function ones( length: number, dtype: 'complex64' ): Complex64Array; - -/** -* Creates an array filled with ones and having a specified length. -* -* @param length - array length -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = ones( 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -declare function ones( length: number, dtype: 'int32' ): Int32Array; - -/** -* Creates an array filled with ones and having a specified length. -* -* @param length - array length -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = ones( 2, 'int16' ); -* // returns [ 1, 1 ] -*/ -declare function ones( length: number, dtype: 'int16' ): Int16Array; - -/** -* Creates an array filled with ones and having a specified length. -* -* @param length - array length -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = ones( 2, 'int8' ); -* // returns [ 1, 1 ] -*/ -declare function ones( length: number, dtype: 'int8' ): Int8Array; - -/** -* Creates an array filled with ones and having a specified length. -* -* @param length - array length -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = ones( 2, 'uint32' ); -* // returns [ 1, 1 ] -*/ -declare function ones( length: number, dtype: 'uint32' ): Uint32Array; - -/** -* Creates an array filled with ones and having a specified length. -* -* @param length - array length -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = ones( 2, 'uint16' ); -* // returns [ 1, 1 ] -*/ -declare function ones( length: number, dtype: 'uint16' ): Uint16Array; - -/** -* Creates an array filled with ones and having a specified length. -* -* @param length - array length -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = ones( 2, 'uint8' ); -* // returns [ 1, 1 ] -*/ -declare function ones( length: number, dtype: 'uint8' ): Uint8Array; - -/** -* Creates an array filled with ones and having a specified length. -* -* @param length - array length -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = ones( 2, 'uint8c' ); -* // returns [ 1, 1 ] -*/ -declare function ones( length: number, dtype: 'uint8c' ): Uint8ClampedArray; - -/** -* Creates an array filled with ones and having a specified length. -* -* @param length - array length -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = ones( 2, 'generic' ); -* // returns [ 1, 1 ] -*/ -declare function ones( length: number, dtype: 'generic' ): Array; +import { ArrayDataTypeMap } from '@stdlib/types/array'; /** * Creates an array filled with ones and having a specified length. @@ -216,7 +52,7 @@ declare function ones( length: number, dtype: 'generic' ): Array; * var arr = ones( 2, 'float32' ); * // returns [ 1.0, 1.0 ] */ -declare function ones( length: number, dtype?: DataType ): Float64Array; +declare function ones = 'float64'>( length: number, dtype?: T ): ArrayDataTypeMap[T]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/zero-to/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/zero-to/docs/types/index.d.ts index 6122614ea104..c1fee5390121 100644 --- a/lib/node_modules/@stdlib/array/zero-to/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/zero-to/docs/types/index.d.ts @@ -20,171 +20,7 @@ /// -import { Complex128Array, Complex64Array, NumericDataType } from '@stdlib/types/array'; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero. -* -* @param n - number of elements -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var arr = zeroTo( 2, 'float64' ); -* // returns [ 0.0, 1.0 ] -*/ -declare function zeroTo( n: number, dtype: 'float64' ): Float64Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero. -* -* @param n - number of elements -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var arr = zeroTo( 2, 'float32' ); -* // returns [ 0.0, 1.0 ] -*/ -declare function zeroTo( n: number, dtype: 'float32' ): Float32Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero. -* -* ## Notes -* -* - Each element has an imaginary component equal to `0`. -* -* @param n - number of elements -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var arr = zeroTo( 2, 'complex128' ); -* // returns -*/ -declare function zeroTo( n: number, dtype: 'complex128' ): Complex128Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero. -* -* ## Notes -* -* - Each element has an imaginary component equal to `0`. -* -* @param n - number of elements -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var arr = zeroTo( 2, 'complex64' ); -* // returns -*/ -declare function zeroTo( n: number, dtype: 'complex64' ): Complex64Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero. -* -* @param n - number of elements -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var arr = zeroTo( 2, 'int32' ); -* // returns [ 0, 1 ] -*/ -declare function zeroTo( n: number, dtype: 'int32' ): Int32Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero. -* -* @param n - number of elements -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var arr = zeroTo( 2, 'int16' ); -* // returns [ 0, 1 ] -*/ -declare function zeroTo( n: number, dtype: 'int16' ): Int16Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero. -* -* @param n - number of elements -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var arr = zeroTo( 2, 'int8' ); -* // returns [ 0, 1 ] -*/ -declare function zeroTo( n: number, dtype: 'int8' ): Int8Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero. -* -* @param n - number of elements -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var arr = zeroTo( 2, 'uint32' ); -* // returns [ 0, 1 ] -*/ -declare function zeroTo( n: number, dtype: 'uint32' ): Uint32Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero. -* -* @param n - number of elements -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var arr = zeroTo( 2, 'uint16' ); -* // returns [ 0, 1 ] -*/ -declare function zeroTo( n: number, dtype: 'uint16' ): Uint16Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero. -* -* @param n - number of elements -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var arr = zeroTo( 2, 'uint8' ); -* // returns [ 0, 1 ] -*/ -declare function zeroTo( n: number, dtype: 'uint8' ): Uint8Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero. -* -* @param n - number of elements -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var arr = zeroTo( 2, 'uint8c' ); -* // returns [ 0, 1 ] -*/ -declare function zeroTo( n: number, dtype: 'uint8c' ): Uint8ClampedArray; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero. -* -* @param n - number of elements -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var arr = zeroTo( 2, 'generic' ); -* // returns [ 0, 1 ] -*/ -declare function zeroTo( n: number, dtype: 'generic' ): Array; +import { ArrayDataTypeMap } from '@stdlib/types/array'; /** * Generates a linearly spaced numeric array whose elements increment by 1 starting from zero. @@ -201,7 +37,7 @@ declare function zeroTo( n: number, dtype: 'generic' ): Array; * var arr = zeroTo( 2, 'float32' ); * // returns [ 0.0, 1.0 ] */ -declare function zeroTo( n: number, dtype?: NumericDataType ): Float64Array; +declare function zeroTo = 'float64'>( n: number, dtype?: T ): ArrayDataTypeMap[T]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/zeros/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/zeros/docs/types/index.d.ts index 53f2ae9828bf..c124f86396f7 100644 --- a/lib/node_modules/@stdlib/array/zeros/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/zeros/docs/types/index.d.ts @@ -20,163 +20,7 @@ /// -import { Complex128Array, Complex64Array, DataType } from '@stdlib/types/array'; - -/** -* Creates a zero-filled array having a specified length. -* -* @param length - array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var arr = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function zeros( length: number, dtype: 'float64' ): Float64Array; - -/** -* Creates a zero-filled array having a specified length. -* -* @param length - array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var arr = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function zeros( length: number, dtype: 'float32' ): Float32Array; - -/** -* Creates a zero-filled array having a specified length. -* -* @param length - array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var arr = zeros( 2, 'complex128' ); -* // returns -*/ -declare function zeros( length: number, dtype: 'complex128' ): Complex128Array; - -/** -* Creates a zero-filled array having a specified length. -* -* @param length - array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var arr = zeros( 2, 'complex64' ); -* // returns -*/ -declare function zeros( length: number, dtype: 'complex64' ): Complex64Array; - -/** -* Creates a zero-filled array having a specified length. -* -* @param length - array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var arr = zeros( 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function zeros( length: number, dtype: 'int32' ): Int32Array; - -/** -* Creates a zero-filled array having a specified length. -* -* @param length - array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var arr = zeros( 2, 'int16' ); -* // returns [ 0, 0 ] -*/ -declare function zeros( length: number, dtype: 'int16' ): Int16Array; - -/** -* Creates a zero-filled array having a specified length. -* -* @param length - array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var arr = zeros( 2, 'int8' ); -* // returns [ 0, 0 ] -*/ -declare function zeros( length: number, dtype: 'int8' ): Int8Array; - -/** -* Creates a zero-filled array having a specified length. -* -* @param length - array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var arr = zeros( 2, 'uint32' ); -* // returns [ 0, 0 ] -*/ -declare function zeros( length: number, dtype: 'uint32' ): Uint32Array; - -/** -* Creates a zero-filled array having a specified length. -* -* @param length - array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var arr = zeros( 2, 'uint16' ); -* // returns [ 0, 0 ] -*/ -declare function zeros( length: number, dtype: 'uint16' ): Uint16Array; - -/** -* Creates a zero-filled array having a specified length. -* -* @param length - array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var arr = zeros( 2, 'uint8' ); -* // returns [ 0, 0 ] -*/ -declare function zeros( length: number, dtype: 'uint8' ): Uint8Array; - -/** -* Creates a zero-filled array having a specified length. -* -* @param length - array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var arr = zeros( 2, 'uint8c' ); -* // returns [ 0, 0 ] -*/ -declare function zeros( length: number, dtype: 'uint8c' ): Uint8ClampedArray; - -/** -* Creates a zero-filled array having a specified length. -* -* @param length - array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var arr = zeros( 2, 'generic' ); -* // returns [ 0, 0 ] -*/ -declare function zeros( length: number, dtype: 'generic' ): Array; +import { ArrayDataTypeMap } from '@stdlib/types/array'; /** * Creates a zero-filled array having a specified length. @@ -208,7 +52,7 @@ declare function zeros( length: number, dtype: 'generic' ): Array; * var arr = zeros( 2, 'float32' ); * // returns [ 0.0, 0.0 ] */ -declare function zeros( length: number, dtype?: DataType ): Float64Array; +declare function zeros = 'float64'>( length: number, dtype?: T ): ArrayDataTypeMap[T]; // EXPORTS // From e3ba4221f0977a804c2ab3e9bbd7328f61e384b1 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sat, 17 Feb 2024 12:18:56 -0500 Subject: [PATCH 03/20] fix: use data type map instead of overloads and improve types --- .../@stdlib/array/full/docs/types/index.d.ts | 177 +----------------- .../@stdlib/array/full/docs/types/test.ts | 5 +- 2 files changed, 5 insertions(+), 177 deletions(-) diff --git a/lib/node_modules/@stdlib/array/full/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/full/docs/types/index.d.ts index cd3ace9569de..3e52c7c9251f 100644 --- a/lib/node_modules/@stdlib/array/full/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/full/docs/types/index.d.ts @@ -20,180 +20,7 @@ /// -import { AnyArray, Complex128Array, Complex64Array, DataType } from '@stdlib/types/array'; -import { ComplexLike } from '@stdlib/types/complex'; - -/** -* Creates a filled array having a specified length. -* -* @param length - array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = full( 2, 1.0, 'float64' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function full( length: number, value: number, dtype: 'float64' ): Float64Array; - -/** -* Creates a filled array having a specified length. -* -* @param length - array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = full( 2, 1.0, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function full( length: number, value: number, dtype: 'float32' ): Float32Array; - -/** -* Creates a filled array having a specified length. -* -* @param length - array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var Complex128 = require( '@stdlib/complex/float64' ); -* -* var arr = full( 2, new Complex128( 1.0, 2.0 ), 'complex128' ); -* // returns -*/ -declare function full( length: number, value: ComplexLike, dtype: 'complex128' ): Complex128Array; - -/** -* Creates a filled array having a specified length. -* -* @param length - array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var Complex64 = require( '@stdlib/complex/float32' ); -* -* var arr = full( 2, new Complex64( 1.0, 2.0 ), 'complex64' ); -* // returns -*/ -declare function full( length: number, value: ComplexLike, dtype: 'complex64' ): Complex64Array; - -/** -* Creates a filled array having a specified length. -* -* @param length - array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = full( 2, 1, 'int32' ); -* // returns [ 1, 1 ] -*/ -declare function full( length: number, value: number, dtype: 'int32' ): Int32Array; - -/** -* Creates a filled array having a specified length. -* -* @param length - array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = full( 2, 1, 'int16' ); -* // returns [ 1, 1 ] -*/ -declare function full( length: number, value: number, dtype: 'int16' ): Int16Array; - -/** -* Creates a filled array having a specified length. -* -* @param length - array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = full( 2, 1, 'int8' ); -* // returns [ 1, 1 ] -*/ -declare function full( length: number, value: number, dtype: 'int8' ): Int8Array; - -/** -* Creates a filled array having a specified length. -* -* @param length - array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = full( 2, 1, 'uint32' ); -* // returns [ 1, 1 ] -*/ -declare function full( length: number, value: number, dtype: 'uint32' ): Uint32Array; - -/** -* Creates a filled array having a specified length. -* -* @param length - array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = full( 2, 1, 'uint16' ); -* // returns [ 1, 1 ] -*/ -declare function full( length: number, value: number, dtype: 'uint16' ): Uint16Array; - -/** -* Creates a filled array having a specified length. -* -* @param length - array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = full( 2, 1, 'uint8' ); -* // returns [ 1, 1 ] -*/ -declare function full( length: number, value: number, dtype: 'uint8' ): Uint8Array; - -/** -* Creates a filled array having a specified length. -* -* @param length - array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = full( 2, 1, 'uint8c' ); -* // returns [ 1, 1 ] -*/ -declare function full( length: number, value: number, dtype: 'uint8c' ): Uint8ClampedArray; - -/** -* Creates a filled array having a specified length. -* -* @param length - array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = full( 2, 1, 'generic' ); -* // returns [ 1, 1 ] -*/ -declare function full( length: number, value: any, dtype: 'generic' ): Array; +import { ArrayDataTypeMap } from '@stdlib/types/array'; /** * Creates a filled array having a specified length. @@ -226,7 +53,7 @@ declare function full( length: number, value: any, dtype: 'generic' ): Array[ 1.0, 1.0 ] */ -declare function full( length: number, value: any, dtype?: DataType ): AnyArray; +declare function full = 'float64'>( length: number, value: T, dtype?: U ): ArrayDataTypeMap[U]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/full/docs/types/test.ts b/lib/node_modules/@stdlib/array/full/docs/types/test.ts index b4974f4dbf42..cfb26c6f8ec6 100644 --- a/lib/node_modules/@stdlib/array/full/docs/types/test.ts +++ b/lib/node_modules/@stdlib/array/full/docs/types/test.ts @@ -26,7 +26,7 @@ import full = require( './index' ); { const z = new Complex128( 1.0, 2.0 ); - full( 10, 1 ); // $ExpectType AnyArray + full( 10, 1 ); // $ExpectType Float64Array full( 10, 1, 'float64' ); // $ExpectType Float64Array full( 10, 1, 'float32' ); // $ExpectType Float32Array full( 10, z, 'complex128' ); // $ExpectType Complex128Array @@ -38,7 +38,8 @@ import full = require( './index' ); full( 10, 1, 'uint16' ); // $ExpectType Uint16Array full( 10, 1, 'uint8' ); // $ExpectType Uint8Array full( 10, 1, 'uint8c' ); // $ExpectType Uint8ClampedArray - full( 10, 1, 'generic' ); // $ExpectType any[] + full( 10, 1, 'generic' ); // $ExpectType number[] + full( 10, 'abc', 'generic' ); // $ExpectType string[] } // The compiler throws an error if the function is not provided a number for the first argument... From 11eb9ad12ab73aa6241821bf9e2b67224d0df544 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sat, 17 Feb 2024 12:29:26 -0500 Subject: [PATCH 04/20] fix: use data type map to improve return types --- .../@stdlib/array/typed/docs/types/index.d.ts | 16 +++++----- .../@stdlib/array/typed/docs/types/test.ts | 8 ++--- lib/node_modules/@stdlib/types/index.d.ts | 29 +++++++++++++++++++ 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/lib/node_modules/@stdlib/array/typed/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/typed/docs/types/index.d.ts index 096ebfac4d4e..979f16df07ef 100644 --- a/lib/node_modules/@stdlib/array/typed/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/typed/docs/types/index.d.ts @@ -22,7 +22,7 @@ /// -import { ArrayLike, RealOrComplexTypedArray, NumericDataType } from '@stdlib/types/array'; +import { RealOrComplexTypedArray, TypedArrayMap } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array/buffer' ); /** @@ -39,7 +39,7 @@ import ArrayBuffer = require( '@stdlib/array/buffer' ); * var arr = typedarray( 'float32'); * // returns */ -declare function typedarray( dtype?: NumericDataType ): RealOrComplexTypedArray; +declare function typedarray( dtype?: T ): TypedArrayMap[T]; /** * Creates a typed array. @@ -56,7 +56,7 @@ declare function typedarray( dtype?: NumericDataType ): RealOrComplexTypedArray; * var arr = typedarray( 2, 'float32' ); * // returns [ 0.0, 0.0 ] */ -declare function typedarray( length: number, dtype?: NumericDataType ): RealOrComplexTypedArray; +declare function typedarray( length: number, dtype?: T ): TypedArrayMap[T]; /** * Creates a typed array. @@ -83,7 +83,7 @@ declare function typedarray( length: number, dtype?: NumericDataType ): RealOrCo * var arr2 = typedarray( arr1, 'uint32' ); * // returns [ 5, 3 ] */ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: NumericDataType ): RealOrComplexTypedArray; +declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: T ): TypedArrayMap[T]; /** * Creates a typed array. @@ -100,7 +100,7 @@ declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: Numeri * var arr = typedarray( [ 5, -3 ], 'int32' ); * // returns [ 5, -3 ] */ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: NumericDataType ): RealOrComplexTypedArray; +declare function typedarray( obj: ArrayLike | Iterable, dtype?: T ): TypedArrayMap[T]; /** * Creates a typed array. @@ -123,7 +123,7 @@ declare function typedarray( obj: ArrayLike | Iterable, dtype?: Num * var arr = typedarray( buf, 'float32' ); * // returns [ 0.0, 0.0, 0.0, 0.0 ] */ -declare function typedarray( buffer: ArrayBuffer, dtype?: NumericDataType ): RealOrComplexTypedArray; +declare function typedarray( buffer: ArrayBuffer, dtype?: T ): TypedArrayMap[T]; /** * Creates a typed array. @@ -147,7 +147,7 @@ declare function typedarray( buffer: ArrayBuffer, dtype?: NumericDataType ): Rea * var arr = typedarray( buf, 8, 'float32' ); * // returns [ 0.0, 0.0 ] */ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: NumericDataType ): RealOrComplexTypedArray; +declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: T ): TypedArrayMap[T]; /** * Creates a typed array. @@ -172,7 +172,7 @@ declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: N * var arr = typedarray( buf, 8, 2, 'int32' ); * // returns [ 0, 0 ] */ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: NumericDataType ): RealOrComplexTypedArray; +declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: T ): TypedArrayMap[T]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/typed/docs/types/test.ts b/lib/node_modules/@stdlib/array/typed/docs/types/test.ts index 1974fca7b9ac..08c9fb16ebd0 100644 --- a/lib/node_modules/@stdlib/array/typed/docs/types/test.ts +++ b/lib/node_modules/@stdlib/array/typed/docs/types/test.ts @@ -23,10 +23,10 @@ import typedarray = require( './index' ); // The function returns a typed array.. { - typedarray(); // $ExpectType RealOrComplexTypedArray - typedarray( 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( 10, 'float32' ); // $ExpectType RealOrComplexTypedArray - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType RealOrComplexTypedArray + typedarray(); // $ExpectType Float64Array + typedarray( 'float32' ); // $ExpectType Float32Array + typedarray( 10, 'float32' ); // $ExpectType Float32Array + typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType Int32Array } // The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... diff --git a/lib/node_modules/@stdlib/types/index.d.ts b/lib/node_modules/@stdlib/types/index.d.ts index dff4cd77405a..54e1d568453a 100644 --- a/lib/node_modules/@stdlib/types/index.d.ts +++ b/lib/node_modules/@stdlib/types/index.d.ts @@ -624,6 +624,35 @@ declare module '@stdlib/types/array' { 'uint8c': Uint8ClampedArray; 'generic': Array; }; + + /** + * Type mapping for the following array data types: + * + * - `float64`: double-precision floating-point numbers (IEEE 754) + * - `float32`: single-precision floating-point numbers (IEEE 754) + * - `complex128`: double-precision complex floating-point numbers + * - `complex64`: single-precision complex floating-point numbers + * - `int32`: 32-bit two's complement signed integers + * - `uint32`: 32-bit unsigned integers + * - `int16`: 16-bit two's complement signed integers + * - `uint16`: 16-bit unsigned integers + * - `int8`: 8-bit two's complement signed integers + * - `uint8`: 8-bit unsigned integers + * - `uint8c`: 8-bit unsigned integers clamped to `0-255` + */ + type TypedArrayMap = { // eslint-disable-line @typescript-eslint/consistent-type-definitions + 'float64': Float64Array; + 'float32': Float32Array; + 'complex128': Complex128Array; + 'complex64': Complex64Array; + 'int32': Int32Array; + 'uint32': Uint32Array; + 'int16': Int16Array; + 'uint16': Uint16Array; + 'int8': Int8Array; + 'uint8': Uint8Array; + 'uint8c': Uint8ClampedArray; + }; } /** From f969e7bc886e8427da01f1a139930f52f5ac360c Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sat, 17 Feb 2024 12:34:19 -0500 Subject: [PATCH 05/20] fix: use data type map instead of overloads and improve types --- .../array/convert/docs/types/index.d.ts | 172 +----------------- .../@stdlib/array/convert/docs/types/test.ts | 2 + 2 files changed, 4 insertions(+), 170 deletions(-) diff --git a/lib/node_modules/@stdlib/array/convert/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/convert/docs/types/index.d.ts index aed997b22a11..7113cadeb115 100644 --- a/lib/node_modules/@stdlib/array/convert/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/convert/docs/types/index.d.ts @@ -20,175 +20,7 @@ /// -import { AnyArray, Collection, Complex128Array, Complex64Array, DataType } from '@stdlib/types/array'; - -/** -* Converts an array to a `Float64Array`. -* -* @param x - array to convert -* @param dtype - output data type -* @returns output array -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0 ]; -* var out = convert( arr, 'float64' ); -* // returns [ 1.0, 2.0, 3.0, 4.0 ] -*/ -declare function convert( x: Collection, dtype: 'float64' ): Float64Array; - -/** -* Converts an array to a `Float32Array`. -* -* @param x - array to convert -* @param dtype - output data type -* @returns output array -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0 ]; -* var out = convert( arr, 'float32' ); -* // returns [ 1.0, 2.0, 3.0, 4.0 ] -*/ -declare function convert( x: Collection, dtype: 'float32' ): Float32Array; - -/** -* Converts an array to an `Int32Array`. -* -* @param x - array to convert -* @param dtype - output data type -* @returns output array -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0 ]; -* var out = convert( arr, 'int32' ); -* // returns [ 1, 2, 3, 4 ] -*/ -declare function convert( x: Collection, dtype: 'int32' ): Int32Array; - -/** -* Converts an array to an `Int16Array`. -* -* @param x - array to convert -* @param dtype - output data type -* @returns output array -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0 ]; -* var out = convert( arr, 'int16' ); -* // returns [ 1, 2, 3, 4 ] -*/ -declare function convert( x: Collection, dtype: 'int16' ): Int16Array; - -/** -* Converts an array to an `Int8Array`. -* -* @param x - array to convert -* @param dtype - output data type -* @returns output array -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0 ]; -* var out = convert( arr, 'int8' ); -* // returns [ 1, 2, 3, 4 ] -*/ -declare function convert( x: Collection, dtype: 'int8' ): Int8Array; - -/** -* Converts an array to a `Uint32Array`. -* -* @param x - array to convert -* @param dtype - output data type -* @returns output array -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0 ]; -* var out = convert( arr, 'uint32' ); -* // returns [ 1, 2, 3, 4 ] -*/ -declare function convert( x: Collection, dtype: 'uint32' ): Uint32Array; - -/** -* Converts an array to a `Uint16Array`. -* -* @param x - array to convert -* @param dtype - output data type -* @returns output array -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0 ]; -* var out = convert( arr, 'uint16' ); -* // returns [ 1, 2, 3, 4 ] -*/ -declare function convert( x: Collection, dtype: 'uint16' ): Uint16Array; - -/** -* Converts an array to a `Uint8Array`. -* -* @param x - array to convert -* @param dtype - output data type -* @returns output array -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0 ]; -* var out = convert( arr, 'uint8' ); -* // returns [ 1, 2, 3, 4 ] -*/ -declare function convert( x: Collection, dtype: 'uint8' ): Uint8Array; - -/** -* Converts an array to a `Uint8ClampedArray`. -* -* @param x - array to convert -* @param dtype - output data type -* @returns output array -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0 ]; -* var out = convert( arr, 'uint8c' ); -* // returns [ 1, 2, 3, 4 ] -*/ -declare function convert( x: Collection, dtype: 'uint8c' ): Uint8ClampedArray; - -/** -* Converts an array to a `Complex128Array`. -* -* @param x - array to convert -* @param dtype - output data type -* @returns output array -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0 ]; -* var out = convert( arr, 'complex128' ); -* // returns -*/ -declare function convert( x: Collection, dtype: 'complex128' ): Complex128Array; - -/** -* Converts an array to a `Complex64Array`. -* -* @param x - array to convert -* @param dtype - output data type -* @returns output array -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0 ]; -* var out = convert( arr, 'complex64' ); -* // returns -*/ -declare function convert( x: Collection, dtype: 'complex64' ): Complex64Array; - -/** -* Converts an array to an `Array`. -* -* @param x - array to convert -* @param dtype - output data type -* @returns output array -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0 ]; -* var out = convert( arr, 'generic' ); -* // returns [ 1.0, 2.0, 3.0, 4.0 ] -*/ -declare function convert( x: Collection, dtype: 'generic' ): Array; +import { Collection, ArrayDataTypeMap } from '@stdlib/types/array'; /** * Converts an array to an array of a different data type. @@ -202,7 +34,7 @@ declare function convert( x: Collection, dtype: 'generic' ): Array; * var out = convert( arr, 'float64' ); * // returns [ 1.0, 2.0, 3.0, 4.0 ] */ -declare function convert( x: Collection, dtype: DataType ): AnyArray; +declare function convert>( x: Collection, dtype: U ): ArrayDataTypeMap[U]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/convert/docs/types/test.ts b/lib/node_modules/@stdlib/array/convert/docs/types/test.ts index 26de09a24334..98916b6c99f3 100644 --- a/lib/node_modules/@stdlib/array/convert/docs/types/test.ts +++ b/lib/node_modules/@stdlib/array/convert/docs/types/test.ts @@ -34,6 +34,8 @@ import convert = require( './index' ); convert( [ 1.0, 2.0, 3.0, 4.0 ], 'uint8c' ); // $ExpectType Uint8ClampedArray convert( [ 1.0, 2.0, 3.0, 4.0 ], 'complex128' ); // $ExpectType Complex128Array convert( [ 1.0, 2.0, 3.0, 4.0 ], 'complex64' ); // $ExpectType Complex64Array + convert( [ 1.0, 2.0, 3.0, 4.0 ], 'generic' ); // $ExpectType number[] + convert( [ 'a', 'b', 'c', 'd' ], 'generic' ); // $ExpectType string[] } // The compiler throws an error if the function is provided a first argument which is not array-like... From cddaee8c3734c2a563c54f507bb2a214e5d3f70d Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sat, 17 Feb 2024 14:28:30 -0500 Subject: [PATCH 06/20] refactor: avoid duplication --- lib/node_modules/@stdlib/types/index.d.ts | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/lib/node_modules/@stdlib/types/index.d.ts b/lib/node_modules/@stdlib/types/index.d.ts index 54e1d568453a..7807bd7bdff0 100644 --- a/lib/node_modules/@stdlib/types/index.d.ts +++ b/lib/node_modules/@stdlib/types/index.d.ts @@ -608,9 +608,8 @@ declare module '@stdlib/types/array' { * - `int8`: 8-bit two's complement signed integers * - `uint8`: 8-bit unsigned integers * - `uint8c`: 8-bit unsigned integers clamped to `0-255` - * - `generic`: generic JavaScript values */ - type ArrayDataTypeMap = { // eslint-disable-line @typescript-eslint/consistent-type-definitions + type TypedArrayMap = { // eslint-disable-line @typescript-eslint/consistent-type-definitions 'float64': Float64Array; 'float32': Float32Array; 'complex128': Complex128Array; @@ -622,7 +621,6 @@ declare module '@stdlib/types/array' { 'int8': Int8Array; 'uint8': Uint8Array; 'uint8c': Uint8ClampedArray; - 'generic': Array; }; /** @@ -639,20 +637,9 @@ declare module '@stdlib/types/array' { * - `int8`: 8-bit two's complement signed integers * - `uint8`: 8-bit unsigned integers * - `uint8c`: 8-bit unsigned integers clamped to `0-255` + * - `generic`: generic JavaScript values */ - type TypedArrayMap = { // eslint-disable-line @typescript-eslint/consistent-type-definitions - 'float64': Float64Array; - 'float32': Float32Array; - 'complex128': Complex128Array; - 'complex64': Complex64Array; - 'int32': Int32Array; - 'uint32': Uint32Array; - 'int16': Int16Array; - 'uint16': Uint16Array; - 'int8': Int8Array; - 'uint8': Uint8Array; - 'uint8c': Uint8ClampedArray; - }; + type ArrayDataTypeMap = TypedArrayMap & { 'generic': Array }; } /** From 2827f4e726005bd4e4e6ef2ffc2ec5a1a17444ee Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sat, 17 Feb 2024 14:40:27 -0500 Subject: [PATCH 07/20] feat: add additional fine-grained array type maps --- lib/node_modules/@stdlib/types/index.d.ts | 42 ++++++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/types/index.d.ts b/lib/node_modules/@stdlib/types/index.d.ts index 7807bd7bdff0..e85df44f15ed 100644 --- a/lib/node_modules/@stdlib/types/index.d.ts +++ b/lib/node_modules/@stdlib/types/index.d.ts @@ -599,8 +599,27 @@ declare module '@stdlib/types/array' { * * - `float64`: double-precision floating-point numbers (IEEE 754) * - `float32`: single-precision floating-point numbers (IEEE 754) + */ + type RealFloatingPointArrayMap = { // eslint-disable-line @typescript-eslint/consistent-type-definitions + 'float64': Float64Array; + 'float32': Float32Array; + }; + + /** + * Type mapping for the following array data types: + * * - `complex128`: double-precision complex floating-point numbers * - `complex64`: single-precision complex floating-point numbers + */ + type ComplexArrayMap = { // eslint-disable-line @typescript-eslint/consistent-type-definitions + 'complex64': Complex64Array; + 'complex128': Complex128Array; + }; + + /** + * Type mapping for the following array data types: + * + * - `complex64`: single-precision complex floating-point numbers * - `int32`: 32-bit two's complement signed integers * - `uint32`: 32-bit unsigned integers * - `int16`: 16-bit two's complement signed integers @@ -609,11 +628,7 @@ declare module '@stdlib/types/array' { * - `uint8`: 8-bit unsigned integers * - `uint8c`: 8-bit unsigned integers clamped to `0-255` */ - type TypedArrayMap = { // eslint-disable-line @typescript-eslint/consistent-type-definitions - 'float64': Float64Array; - 'float32': Float32Array; - 'complex128': Complex128Array; - 'complex64': Complex64Array; + type IntegerArrayMap = { // eslint-disable-line @typescript-eslint/consistent-type-definitions 'int32': Int32Array; 'uint32': Uint32Array; 'int16': Int16Array; @@ -623,6 +638,23 @@ declare module '@stdlib/types/array' { 'uint8c': Uint8ClampedArray; }; + /** + * Type mapping for the following array data types: + * + * - `float64`: double-precision floating-point numbers (IEEE 754) + * - `float32`: single-precision floating-point numbers (IEEE 754) + * - `complex128`: double-precision complex floating-point numbers + * - `complex64`: single-precision complex floating-point numbers + * - `int32`: 32-bit two's complement signed integers + * - `uint32`: 32-bit unsigned integers + * - `int16`: 16-bit two's complement signed integers + * - `uint16`: 16-bit unsigned integers + * - `int8`: 8-bit two's complement signed integers + * - `uint8`: 8-bit unsigned integers + * - `uint8c`: 8-bit unsigned integers clamped to `0-255` + */ + type TypedArrayMap = RealFloatingPointArrayMap & ComplexArrayMap & IntegerArrayMap; + /** * Type mapping for the following array data types: * From 0eed947c6688ec5f289a9645b63dfef7638040de Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sat, 17 Feb 2024 14:58:29 -0500 Subject: [PATCH 08/20] fix: use data type map to improve return types --- .../array/filled/docs/types/index.d.ts | 23 ++++---- .../@stdlib/array/filled/docs/types/test.ts | 55 +++++++++---------- 2 files changed, 37 insertions(+), 41 deletions(-) diff --git a/lib/node_modules/@stdlib/array/filled/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/filled/docs/types/index.d.ts index ecb5901b9899..d795e89f335e 100644 --- a/lib/node_modules/@stdlib/array/filled/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/filled/docs/types/index.d.ts @@ -16,18 +16,15 @@ * limitations under the License. */ +/* eslint-disable @typescript-eslint/unified-signatures */ + // TypeScript Version: 4.1 /// -import { RealOrComplexTypedArray, DataType, Collection } from '@stdlib/types/array'; +import { Collection, ArrayDataTypeMap } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray; - /** * Creates a filled array. * @@ -57,7 +54,7 @@ type ArrayOrTypedArray = Array | RealOrComplexTypedArray; * var arr = filledarray( 'float32' ); * // returns */ -declare function filledarray( dtype?: DataType ): ArrayOrTypedArray; +declare function filledarray = 'float64'>( dtype?: U ): ArrayDataTypeMap[U]; /** * Creates a filled array having a specified `length`. @@ -75,7 +72,7 @@ declare function filledarray( dtype?: DataType ): ArrayOrTypedArray; * var arr = filledarray( 1.0, 5, 'float32' ); * // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] */ -declare function filledarray( value: any, length: number, dtype?: DataType ): ArrayOrTypedArray; +declare function filledarray = 'float64'>( value: T, length: number, dtype?: U ): ArrayDataTypeMap[U]; /** * Creates a filled array from another `array`. @@ -93,7 +90,7 @@ declare function filledarray( value: any, length: number, dtype?: DataType ): Ar * var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); * // returns [ 1.0, 1.0, 1.0 ] */ -declare function filledarray( value: any, array: Collection, dtype?: DataType ): ArrayOrTypedArray; +declare function filledarray = 'float64'>( value: T, array: Collection, dtype?: U ): ArrayDataTypeMap[U]; /** * Creates a filled array from an iterable. @@ -121,7 +118,7 @@ declare function filledarray( value: any, array: Collection, dtype?: DataType ): * var arr = filledarray( 1.0, it, 'float32' ); * // returns [ 1.0, 1.0, 1.0 ] */ -declare function filledarray( value: any, iterable: IterableIterator, dtype?: DataType ): ArrayOrTypedArray; +declare function filledarray = 'float64'>( value: T, iterable: IterableIterator, dtype?: U ): ArrayDataTypeMap[U]; /** * Returns a filled typed array view of an `ArrayBuffer`. @@ -151,7 +148,7 @@ declare function filledarray( value: any, iterable: IterableIterator, dtype?: Da * var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); * // returns [ 1.0, 1.0 ] */ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: DataType ): RealOrComplexTypedArray; +declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: U ): ArrayDataTypeMap[U]; /** * Returns a filled typed array view of an `ArrayBuffer`. @@ -180,7 +177,7 @@ declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: numbe * var arr = filledarray( 1.0, buf, 8, 'float32' ); * // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] */ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, dtype?: DataType ): RealOrComplexTypedArray; +declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, dtype?: U ): ArrayDataTypeMap[U]; /** * Returns a filled typed array view of an `ArrayBuffer`. @@ -208,7 +205,7 @@ declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: numbe * var arr = filledarray( 1.0, buf, 'float32' ); * // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] */ -declare function filledarray( value: any, buffer: ArrayBuffer, dtype?: DataType ): RealOrComplexTypedArray; +declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, dtype?: U ): ArrayDataTypeMap[U]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/filled/docs/types/test.ts b/lib/node_modules/@stdlib/array/filled/docs/types/test.ts index 164a3972a5f2..4da77fe1c4cd 100644 --- a/lib/node_modules/@stdlib/array/filled/docs/types/test.ts +++ b/lib/node_modules/@stdlib/array/filled/docs/types/test.ts @@ -21,30 +21,29 @@ import { IterableIterator } from '@stdlib/types/iter'; import filledarray = require( './index' ); - /** -* Returns an iterator protocol-compliant object. +* Implements the iterator protocol `next` method. * * @returns iterator protocol-compliant object */ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next +function next(): any { + return { + 'value': 1.0, + 'done': false }; - return obj; } /** -* Implements the iterator protocol `next` method. +* Returns an iterator protocol-compliant object. * * @returns iterator protocol-compliant object */ -function next(): any { - return { - 'value': 1.0, - 'done': false +function iterator(): IterableIterator { + const obj: IterableIterator = { + [Symbol.iterator]: iterator, + 'next': next }; + return obj; } @@ -52,33 +51,33 @@ function next(): any { // The function returns an array or typed array... { - filledarray(); // $ExpectType ArrayOrTypedArray - filledarray( 'float32' ); // $ExpectType ArrayOrTypedArray + filledarray(); // $ExpectType Float64Array + filledarray( 'float32' ); // $ExpectType Float32Array - filledarray( 1.0, 10 ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, 10, 'int32' ); // $ExpectType ArrayOrTypedArray + filledarray( 1.0, 10 ); // $ExpectType Float64Array + filledarray( 1.0, 10, 'int32' ); // $ExpectType Int32Array const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, x, 'uint8' ); // $ExpectType ArrayOrTypedArray + filledarray( 1.0, x ); // $ExpectType Float64Array + filledarray( 1.0, x, 'uint8' ); // $ExpectType Uint8Array const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, y, 'float64' ); // $ExpectType ArrayOrTypedArray + filledarray( 1.0, y ); // $ExpectType Float64Array + filledarray( 1.0, y, 'float64' ); // $ExpectType Float64Array const it = iterator(); - filledarray( 1.0, it ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, it, 'uint8c' ); // $ExpectType ArrayOrTypedArray + filledarray( 1.0, it ); // $ExpectType Float64Array + filledarray( 1.0, it, 'uint8c' ); // $ExpectType Uint8ClampedArray const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 'uint32' ); // $ExpectType RealOrComplexTypedArray + filledarray( 1.0, buf ); // $ExpectType Float64Array + filledarray( 1.0, buf, 'uint32' ); // $ExpectType Uint32Array - filledarray( 1.0, buf, 8 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType RealOrComplexTypedArray + filledarray( 1.0, buf, 8 ); // $ExpectType Float64Array + filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType Uint16Array - filledarray( 1.0, buf, 8, 2 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType RealOrComplexTypedArray + filledarray( 1.0, buf, 8, 2 ); // $ExpectType Float64Array + filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType Int16Array } // The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... From d6f59b0f415f55e84418e429debd8e549aa3793b Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sat, 17 Feb 2024 14:58:56 -0500 Subject: [PATCH 09/20] fix: use data type map to improve return types --- .../array/typed-complex/docs/types/index.d.ts | 16 ++++++++-------- .../array/typed-complex/docs/types/test.ts | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/node_modules/@stdlib/array/typed-complex/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/typed-complex/docs/types/index.d.ts index 558265cca695..7655601a4a10 100644 --- a/lib/node_modules/@stdlib/array/typed-complex/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/typed-complex/docs/types/index.d.ts @@ -22,7 +22,7 @@ /// -import { ArrayLike, ComplexTypedArray, ComplexFloatingPointDataType as DataType } from '@stdlib/types/array'; +import { ArrayLike, ComplexTypedArray, ComplexArrayMap } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array/buffer' ); /** @@ -39,7 +39,7 @@ import ArrayBuffer = require( '@stdlib/array/buffer' ); * var arr = complexarray( 'complex64'); * // returns */ -declare function complexarray( dtype?: DataType ): ComplexTypedArray; +declare function complexarray( dtype?: T ): ComplexArrayMap[T]; /** * Creates a complex number typed array. @@ -56,7 +56,7 @@ declare function complexarray( dtype?: DataType ): ComplexTypedArray; * var arr = complexarray( 2, 'complex64' ); * // returns */ -declare function complexarray( length: number, dtype?: DataType ): ComplexTypedArray; +declare function complexarray( length: number, dtype?: T ): ComplexArrayMap[T]; /** * Creates a complex number typed array. @@ -73,7 +73,7 @@ declare function complexarray( length: number, dtype?: DataType ): ComplexTypedA * var arr = complexarray( new Complex128Array( 2 ), 'complex64' ); * // returns */ -declare function complexarray( complexarray: ComplexTypedArray, dtype?: DataType ): ComplexTypedArray; +declare function complexarray( complexarray: ComplexTypedArray, dtype?: T ): ComplexArrayMap[T]; /** * Creates a complex number typed array. @@ -91,7 +91,7 @@ declare function complexarray( complexarray: ComplexTypedArray, dtype?: DataType * var arr = complexarray( [ 5, -3 ], 'complex64' ); * // returns */ -declare function complexarray( obj: ArrayLike | Iterable, dtype?: DataType ): ComplexTypedArray; +declare function complexarray( obj: ArrayLike | Iterable, dtype?: T ): ComplexArrayMap[T]; /** * Creates a complex number typed array. @@ -114,7 +114,7 @@ declare function complexarray( obj: ArrayLike | Iterable, dtype?: D * var arr = complexarray( buf, 'complex64' ); * // returns */ -declare function complexarray( buffer: ArrayBuffer, dtype?: DataType ): ComplexTypedArray; +declare function complexarray( buffer: ArrayBuffer, dtype?: T ): ComplexArrayMap[T]; /** * Creates a complex number typed array. @@ -138,7 +138,7 @@ declare function complexarray( buffer: ArrayBuffer, dtype?: DataType ): ComplexT * var arr = complexarray( buf, 16, 'complex64' ); * // returns */ -declare function complexarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: DataType ): ComplexTypedArray; +declare function complexarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: T ): ComplexArrayMap[T]; /** * Creates a complex number typed array. @@ -163,7 +163,7 @@ declare function complexarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: * var arr = complexarray( buf, 16, 2, 'complex64' ); * // returns */ -declare function complexarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: DataType ): ComplexTypedArray; +declare function complexarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: T ): ComplexArrayMap[T]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/typed-complex/docs/types/test.ts b/lib/node_modules/@stdlib/array/typed-complex/docs/types/test.ts index 7d7979521000..33077f3b1d8e 100644 --- a/lib/node_modules/@stdlib/array/typed-complex/docs/types/test.ts +++ b/lib/node_modules/@stdlib/array/typed-complex/docs/types/test.ts @@ -23,10 +23,10 @@ import complexarray = require( './index' ); // The function returns a typed array.. { - complexarray(); // $ExpectType ComplexTypedArray - complexarray( 'complex64' ); // $ExpectType ComplexTypedArray - complexarray( 10, 'complex64' ); // $ExpectType ComplexTypedArray - complexarray( [ 1, 2, 3 ], 'complex128' ); // $ExpectType ComplexTypedArray + complexarray(); // $ExpectType Complex128Array + complexarray( 'complex64' ); // $ExpectType Complex64Array + complexarray( 10, 'complex64' ); // $ExpectType Complex64Array + complexarray( [ 1, 2, 3 ], 'complex128' ); // $ExpectType Complex128Array } // The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... From 534b2360e0676c68b2480c37d3575d553fe94986 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sat, 17 Feb 2024 15:44:03 -0500 Subject: [PATCH 10/20] refactor: use data type map and generic parameter to simplify --- .../array/empty-like/docs/types/index.d.ts | 718 +----------------- .../array/ones-like/docs/types/index.d.ts | 625 +-------------- .../array/zeros-like/docs/types/index.d.ts | 609 +-------------- 3 files changed, 23 insertions(+), 1929 deletions(-) diff --git a/lib/node_modules/@stdlib/array/empty-like/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/empty-like/docs/types/index.d.ts index f06dc549c53e..4898492ec8d5 100644 --- a/lib/node_modules/@stdlib/array/empty-like/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/empty-like/docs/types/index.d.ts @@ -20,718 +20,27 @@ /// -import { AnyArray, Complex128Array, Complex64Array, DataType } from '@stdlib/types/array'; - -/** -* Creates an uninitialized array having the same length as a provided input array. -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns empty array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var arr = emptyLike( x, 'float64' ); -* // returns -*/ -declare function emptyLike( x: AnyArray, dtype: 'float64' ): Float64Array; - -/** -* Creates an uninitialized array having the same length as a provided input array. -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns empty array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var arr = emptyLike( x, 'float32' ); -* // returns -*/ -declare function emptyLike( x: AnyArray, dtype: 'float32' ): Float32Array; - -/** -* Creates an uninitialized array having the same length as a provided input array. -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns empty array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var arr = emptyLike( x, 'complex128' ); -* // returns -*/ -declare function emptyLike( x: AnyArray, dtype: 'complex128' ): Complex128Array; - -/** -* Creates an uninitialized array having the same length as a provided input array. -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns empty array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var arr = emptyLike( x, 'complex64' ); -* // returns -*/ -declare function emptyLike( x: AnyArray, dtype: 'complex64' ): Complex64Array; - -/** -* Creates an uninitialized array having the same length as a provided input array. -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns empty array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var arr = emptyLike( x, 'int32' ); -* // returns -*/ -declare function emptyLike( x: AnyArray, dtype: 'int32' ): Int32Array; - -/** -* Creates an uninitialized array having the same length as a provided input array. -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns empty array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var arr = emptyLike( x, 'int16' ); -* // returns -*/ -declare function emptyLike( x: AnyArray, dtype: 'int16' ): Int16Array; - -/** -* Creates an uninitialized array having the same length as a provided input array. -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns empty array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var arr = emptyLike( x, 'int8' ); -* // returns -*/ -declare function emptyLike( x: AnyArray, dtype: 'int8' ): Int8Array; - -/** -* Creates an uninitialized array having the same length as a provided input array. -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns empty array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var arr = emptyLike( x, 'uint32' ); -* // returns -*/ -declare function emptyLike( x: AnyArray, dtype: 'uint32' ): Uint32Array; - -/** -* Creates an uninitialized array having the same length as a provided input array. -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns empty array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var arr = emptyLike( x, 'uint16' ); -* // returns -*/ -declare function emptyLike( x: AnyArray, dtype: 'uint16' ): Uint16Array; - -/** -* Creates an uninitialized array having the same length as a provided input array. -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns empty array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var arr = emptyLike( x, 'uint8' ); -* // returns -*/ -declare function emptyLike( x: AnyArray, dtype: 'uint8' ): Uint8Array; - -/** -* Creates an uninitialized array having the same length as a provided input array. -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns empty array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var arr = emptyLike( x, 'uint8c' ); -* // returns -*/ -declare function emptyLike( x: AnyArray, dtype: 'uint8c' ): Uint8ClampedArray; - -/** -* Creates a zero-filled array having a specified length. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var arr = emptyLike( x, 'generic' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function emptyLike( x: AnyArray, dtype: 'generic' ): Array; - -/** -* Creates an uninitialized array having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns empty array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var arr = emptyLike( x ); -* // returns -*/ -declare function emptyLike( x: Float64Array, dtype?: DataType ): Float64Array; - -/** -* Creates an uninitialized array having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns empty array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var arr = emptyLike( x ); -* // returns -*/ -declare function emptyLike( x: Float32Array, dtype?: DataType ): Float32Array; - -/** -* Creates an uninitialized array having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns empty array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'complex128' ); -* // returns -* -* var arr = emptyLike( x ); -* // returns -*/ -declare function emptyLike( x: Complex128Array, dtype?: DataType ): Complex128Array; - -/** -* Creates an uninitialized array having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns empty array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'complex64' ); -* // returns -* -* var arr = emptyLike( x ); -* // returns -*/ -declare function emptyLike( x: Complex64Array, dtype?: DataType ): Complex64Array; - -/** -* Creates an uninitialized array having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns empty array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'int32' ); -* // returns [ 0, 0 ] -* -* var arr = emptyLike( x ); -* // returns -*/ -declare function emptyLike( x: Int32Array, dtype?: DataType ): Int32Array; - -/** -* Creates an uninitialized array having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns empty array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'int16' ); -* // returns [ 0, 0 ] -* -* var arr = emptyLike( x ); -* // returns -*/ -declare function emptyLike( x: Int16Array, dtype?: DataType ): Int16Array; - -/** -* Creates an uninitialized array having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns empty array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'int8' ); -* // returns [ 0, 0 ] -* -* var arr = emptyLike( x ); -* // returns -*/ -declare function emptyLike( x: Int8Array, dtype?: DataType ): Int8Array; - -/** -* Creates an uninitialized array having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns empty array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'uint32' ); -* // returns [ 0, 0 ] -* -* var arr = emptyLike( x ); -* // returns -*/ -declare function emptyLike( x: Uint32Array, dtype?: DataType ): Uint32Array; - -/** -* Creates an uninitialized array having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns empty array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'uint16' ); -* // returns [ 0, 0 ] -* -* var arr = emptyLike( x ); -* // returns -*/ -declare function emptyLike( x: Uint16Array, dtype?: DataType ): Uint16Array; - -/** -* Creates an uninitialized array having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns empty array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'uint8' ); -* // returns [ 0, 0 ] -* -* var arr = emptyLike( x ); -* // returns -*/ -declare function emptyLike( x: Uint8Array, dtype?: DataType ): Uint8Array; +import { AnyArray, ArrayDataTypeMap } from '@stdlib/types/array'; /** * Creates an uninitialized array having the same length and data type as a provided input array. * -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* * ## Notes * * - In browser environments, the function always returns zero-filled arrays. * - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. * * @param x - input array from which to derive the output array length -* @param dtype - data type * @returns empty array * * @example * var zeros = require( '@stdlib/array/zeros' ); * -* var x = zeros( 2, 'uint8c' ); -* // returns [ 0, 0 ] +* var x = zeros( 2, 'float32' ); +* // returns [ 0.0, 0.0 ] * * var arr = emptyLike( x ); -* // returns -*/ -declare function emptyLike( x: Uint8ClampedArray, dtype?: DataType ): Uint8ClampedArray; - -/** -* Creates an uninitialized array having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns empty array +* // returns * * @example * var zeros = require( '@stdlib/array/zeros' ); @@ -742,10 +51,10 @@ declare function emptyLike( x: Uint8ClampedArray, dtype?: DataType ): Uint8Clamp * var arr = emptyLike( x ); * // returns [ 0.0, 0.0 ] */ -declare function emptyLike( x: Array, dtype?: DataType ): Array; +declare function emptyLike( x: T ): T; /** -* Creates an uninitialized array having the same length and data type as a provided input array. +* Creates an uninitialized array having the same length as a provided input array. * * ## Notes * @@ -775,22 +84,13 @@ declare function emptyLike( x: Array, dtype?: DataType ): Array; * @example * var zeros = require( '@stdlib/array/zeros' ); * -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var arr = emptyLike( x ); -* // returns -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* * var x = zeros( 2, 'float64' ); * // returns [ 0.0, 0.0 ] * -* var arr = emptyLike( x ); -* // returns +* var arr = emptyLike( x, 'float32' ); +* // returns */ -declare function emptyLike( x: AnyArray, dtype?: DataType ): AnyArray; +declare function emptyLike>( x: T, dtype: U ): ArrayDataTypeMap[U]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/ones-like/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/ones-like/docs/types/index.d.ts index 0afcffe0f598..87237a3102cb 100644 --- a/lib/node_modules/@stdlib/array/ones-like/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/ones-like/docs/types/index.d.ts @@ -20,624 +20,22 @@ /// -import { Complex128Array, Complex64Array, AnyArray, DataType } from '@stdlib/types/array'; - -/** -* Creates an array filled with ones and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = onesLike( x, 'float64' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function onesLike( x: AnyArray, dtype: 'float64' ): Float64Array; - -/** -* Creates an array filled with ones and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = onesLike( x, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function onesLike( x: AnyArray, dtype: 'float32' ): Float32Array; - -/** -* Creates an array filled with ones and having the same length as a provided input array. -* -* ## Notes -* -* - Each element of the returned array has a real component equal to `1` and an imaginary component equal to `0`. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = onesLike( x, 'complex128' ); -* // returns -*/ -declare function onesLike( x: AnyArray, dtype: 'complex128' ): Complex128Array; - -/** -* Creates an array filled with ones and having the same length as a provided input array. -* - ## Notes -* -* - Each element of the returned array has a real component equal to `1` and an imaginary component equal to `0`. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = onesLike( x, 'complex64' ); -* // returns -*/ -declare function onesLike( x: AnyArray, dtype: 'complex64' ): Complex64Array; - -/** -* Creates an array filled with ones and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = onesLike( x, 'int32' ); -* // returns [ 1, 1 ] -*/ -declare function onesLike( x: AnyArray, dtype: 'int32' ): Int32Array; - -/** -* Creates an array filled with ones and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = onesLike( x, 'int16' ); -* // returns [ 1, 1 ] -*/ -declare function onesLike( x: AnyArray, dtype: 'int16' ): Int16Array; - -/** -* Creates an array filled with ones and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = onesLike( x, 'int8' ); -* // returns [ 1, 1 ] -*/ -declare function onesLike( x: AnyArray, dtype: 'int8' ): Int8Array; - -/** -* Creates an array filled with ones and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = onesLike( x, 'uint32' ); -* // returns [ 1, 1 ] -*/ -declare function onesLike( x: AnyArray, dtype: 'uint32' ): Uint32Array; - -/** -* Creates an array filled with ones and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = onesLike( x, 'uint16' ); -* // returns [ 1, 1 ] -*/ -declare function onesLike( x: AnyArray, dtype: 'uint16' ): Uint16Array; - -/** -* Creates an array filled with ones and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = onesLike( x, 'uint8' ); -* // returns [ 1, 1 ] -*/ -declare function onesLike( x: AnyArray, dtype: 'uint8' ): Uint8Array; - -/** -* Creates an array filled with ones and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = onesLike( x, 'uint8c' ); -* // returns [ 1, 1 ] -*/ -declare function onesLike( x: AnyArray, dtype: 'uint8c' ): Uint8ClampedArray; - -/** -* Creates an array filled with ones and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = onesLike( x, 'generic' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function onesLike( x: AnyArray, dtype: 'generic' ): Array; - -/** -* Creates an array filled with ones and having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = onesLike( x ); -* // returns [ 1.0, 1.0 ] -*/ -declare function onesLike( x: Float64Array, dtype?: DataType ): Float64Array; - -/** -* Creates an array filled with ones and having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = onesLike( x ); -* // returns [ 1.0, 1.0 ] -*/ -declare function onesLike( x: Float32Array, dtype?: DataType ): Float32Array; - -/** -* Creates an array filled with ones and having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* - ## Notes -* -* - Each element of the returned array has a real component equal to `1` and an imaginary component equal to `0`. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'complex128' ); -* // returns -* -* var y = onesLike( x ); -* // returns -*/ -declare function onesLike( x: Complex128Array, dtype?: DataType ): Complex128Array; - -/** -* Creates an array filled with ones and having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* - ## Notes -* -* - Each element of the returned array has a real component equal to `1` and an imaginary component equal to `0`. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'complex64' ); -* // returns -* -* var y = onesLike( x ); -* // returns -*/ -declare function onesLike( x: Complex64Array, dtype?: DataType ): Complex64Array; - -/** -* Creates an array filled with ones and having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'int32' ); -* // returns [ 0, 0 ] -* -* var y = onesLike( x ); -* // returns [ 1, 1 ] -*/ -declare function onesLike( x: Int32Array, dtype?: DataType ): Int32Array; - -/** -* Creates an array filled with ones and having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'int16' ); -* // returns [ 0, 0 ] -* -* var y = onesLike( x ); -* // returns [ 1, 1 ] -*/ -declare function onesLike( x: Int16Array, dtype?: DataType ): Int16Array; - -/** -* Creates an array filled with ones and having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'int8' ); -* // returns [ 0, 0 ] -* -* var y = onesLike( x ); -* // returns [ 1, 1 ] -*/ -declare function onesLike( x: Int8Array, dtype?: DataType ): Int8Array; - -/** -* Creates an array filled with ones and having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'uint32' ); -* // returns [ 0, 0 ] -* -* var y = onesLike( x ); -* // returns [ 1, 1 ] -*/ -declare function onesLike( x: Uint32Array, dtype?: DataType ): Uint32Array; - -/** -* Creates an array filled with ones and having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'uint16' ); -* // returns [ 0, 0 ] -* -* var y = onesLike( x ); -* // returns [ 1, 1 ] -*/ -declare function onesLike( x: Uint16Array, dtype?: DataType ): Uint16Array; - -/** -* Creates an array filled with ones and having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'uint8' ); -* // returns [ 0, 0 ] -* -* var y = onesLike( x ); -* // returns [ 1, 1 ] -*/ -declare function onesLike( x: Uint8Array, dtype?: DataType ): Uint8Array; +import { ArrayDataTypeMap, AnyArray } from '@stdlib/types/array'; /** * Creates an array filled with ones and having the same length and data type as a provided input array. * -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* * @param x - input array from which to derive the output array length -* @param dtype - data type * @returns filled array * * @example * var zeros = require( '@stdlib/array/zeros' ); * -* var x = zeros( 2, 'uint8c' ); -* // returns [ 0, 0 ] +* var x = zeros( 2, 'float64' ); +* // returns [ 0.0, 0.0 ] * * var y = onesLike( x ); -* // returns [ 1, 1 ] -*/ -declare function onesLike( x: Uint8ClampedArray, dtype?: DataType ): Uint8ClampedArray; - -/** -* Creates an array filled with ones and having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array +* // returns [ 1.0, 1.0 ] * * @example * var zeros = require( '@stdlib/array/zeros' ); @@ -648,10 +46,10 @@ declare function onesLike( x: Uint8ClampedArray, dtype?: DataType ): Uint8Clampe * var y = onesLike( x ); * // returns [ 1, 1 ] */ -declare function onesLike( x: Array, dtype?: DataType ): Array; +declare function onesLike( x: T ): T; /** -* Creates an array filled with ones and having the same length and data type as a provided input array. +* Creates an array filled with ones and having the same length as a provided input array. * * The function supports the following data types: * @@ -678,19 +76,10 @@ declare function onesLike( x: Array, dtype?: DataType ): Array; * var x = zeros( 2, 'float64' ); * // returns [ 0.0, 0.0 ] * -* var y = onesLike( x ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* * var y = onesLike( x, 'float32' ); * // returns [ 1.0, 1.0 ] */ -declare function onesLike( x: AnyArray, dtype?: DataType ): AnyArray; +declare function onesLike>( x: T, dtype: U ): ArrayDataTypeMap[U]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/zeros-like/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/zeros-like/docs/types/index.d.ts index 5418b873488f..7f1d909bad9f 100644 --- a/lib/node_modules/@stdlib/array/zeros-like/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/zeros-like/docs/types/index.d.ts @@ -20,608 +20,22 @@ /// -import { Complex128Array, Complex64Array, AnyArray, DataType } from '@stdlib/types/array'; - -/** -* Creates a zero-filled array having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zerosLike( x, 'float64' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function zerosLike( x: AnyArray, dtype: 'float64' ): Float64Array; - -/** -* Creates a zero-filled array having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zerosLike( x, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function zerosLike( x: AnyArray, dtype: 'float32' ): Float32Array; - -/** -* Creates a zero-filled array having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zerosLike( x, 'complex128' ); -* // returns -*/ -declare function zerosLike( x: AnyArray, dtype: 'complex128' ): Complex128Array; - -/** -* Creates a zero-filled array having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zerosLike( x, 'complex64' ); -* // returns -*/ -declare function zerosLike( x: AnyArray, dtype: 'complex64' ): Complex64Array; - -/** -* Creates a zero-filled array having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zerosLike( x, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function zerosLike( x: AnyArray, dtype: 'int32' ): Int32Array; - -/** -* Creates a zero-filled array having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zerosLike( x, 'int16' ); -* // returns [ 0, 0 ] -*/ -declare function zerosLike( x: AnyArray, dtype: 'int16' ): Int16Array; - -/** -* Creates a zero-filled array having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zerosLike( x, 'int8' ); -* // returns [ 0, 0 ] -*/ -declare function zerosLike( x: AnyArray, dtype: 'int8' ): Int8Array; - -/** -* Creates a zero-filled array having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zerosLike( x, 'uint32' ); -* // returns [ 0, 0 ] -*/ -declare function zerosLike( x: AnyArray, dtype: 'uint32' ): Uint32Array; - -/** -* Creates a zero-filled array having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zerosLike( x, 'uint16' ); -* // returns [ 0, 0 ] -*/ -declare function zerosLike( x: AnyArray, dtype: 'uint16' ): Uint16Array; - -/** -* Creates a zero-filled array having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zerosLike( x, 'uint8' ); -* // returns [ 0, 0 ] -*/ -declare function zerosLike( x: AnyArray, dtype: 'uint8' ): Uint8Array; - -/** -* Creates a zero-filled array having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zerosLike( x, 'uint8c' ); -* // returns [ 0, 0 ] -*/ -declare function zerosLike( x: AnyArray, dtype: 'uint8c' ): Uint8ClampedArray; - -/** -* Creates a zero-filled array having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zerosLike( x, 'generic' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function zerosLike( x: AnyArray, dtype: 'generic' ): Array; - -/** -* Creates a zero-filled array having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zerosLike( x ); -* // returns [ 0.0, 0.0 ] -*/ -declare function zerosLike( x: Float64Array, dtype?: DataType ): Float64Array; - -/** -* Creates a zero-filled array having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zerosLike( x ); -* // returns [ 0.0, 0.0 ] -*/ -declare function zerosLike( x: Float32Array, dtype?: DataType ): Float32Array; - -/** -* Creates a zero-filled array having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'complex128' ); -* // returns -* -* var y = zerosLike( x ); -* // returns -*/ -declare function zerosLike( x: Complex128Array, dtype?: DataType ): Complex128Array; +import { ArrayDataTypeMap, AnyArray } from '@stdlib/types/array'; /** * Creates a zero-filled array having the same length and data type as a provided input array. * -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'complex64' ); -* // returns -* -* var y = zerosLike( x ); -* // returns -*/ -declare function zerosLike( x: Complex64Array, dtype?: DataType ): Complex64Array; - -/** -* Creates a zero-filled array having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'int32' ); -* // returns [ 0, 0 ] -* -* var y = zerosLike( x ); -* // returns [ 0, 0 ] -*/ -declare function zerosLike( x: Int32Array, dtype?: DataType ): Int32Array; - -/** -* Creates a zero-filled array having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'int16' ); -* // returns [ 0, 0 ] -* -* var y = zerosLike( x ); -* // returns [ 0, 0 ] -*/ -declare function zerosLike( x: Int16Array, dtype?: DataType ): Int16Array; - -/** -* Creates a zero-filled array having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'int8' ); -* // returns [ 0, 0 ] -* -* var y = zerosLike( x ); -* // returns [ 0, 0 ] -*/ -declare function zerosLike( x: Int8Array, dtype?: DataType ): Int8Array; - -/** -* Creates a zero-filled array having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'uint32' ); -* // returns [ 0, 0 ] -* -* var y = zerosLike( x ); -* // returns [ 0, 0 ] -*/ -declare function zerosLike( x: Uint32Array, dtype?: DataType ): Uint32Array; - -/** -* Creates a zero-filled array having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'uint16' ); -* // returns [ 0, 0 ] -* -* var y = zerosLike( x ); -* // returns [ 0, 0 ] -*/ -declare function zerosLike( x: Uint16Array, dtype?: DataType ): Uint16Array; - -/** -* Creates a zero-filled array having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'uint8' ); -* // returns [ 0, 0 ] -* -* var y = zerosLike( x ); -* // returns [ 0, 0 ] -*/ -declare function zerosLike( x: Uint8Array, dtype?: DataType ): Uint8Array; - -/** -* Creates a zero-filled array having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* * @param x - input array from which to derive the output array length -* @param dtype - data type * @returns zero-filled array * * @example * var zeros = require( '@stdlib/array/zeros' ); * -* var x = zeros( 2, 'uint8c' ); -* // returns [ 0, 0 ] +* var x = zeros( 2, 'float64' ); +* // returns [ 0.0, 0.0 ] * * var y = zerosLike( x ); -* // returns [ 0, 0 ] -*/ -declare function zerosLike( x: Uint8ClampedArray, dtype?: DataType ): Uint8ClampedArray; - -/** -* Creates a zero-filled array having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns zero-filled array +* // returns [ 0.0, 0.0 ] * * @example * var zeros = require( '@stdlib/array/zeros' ); @@ -632,10 +46,10 @@ declare function zerosLike( x: Uint8ClampedArray, dtype?: DataType ): Uint8Clamp * var y = zerosLike( x ); * // returns [ 0, 0 ] */ -declare function zerosLike( x: Array, dtype?: DataType ): Array; +declare function zerosLike( x: T ): T; /** -* Creates a zero-filled array having the same length and data type as a provided input array. +* Creates a zero-filled array having the same length as a provided input array. * * The function supports the following data types: * @@ -662,19 +76,10 @@ declare function zerosLike( x: Array, dtype?: DataType ): Array; * var x = zeros( 2, 'float64' ); * // returns [ 0.0, 0.0 ] * -* var y = zerosLike( x ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* * var y = zerosLike( x, 'float32' ); * // returns [ 0.0, 0.0 ] */ -declare function zerosLike( x: AnyArray, dtype?: DataType ): AnyArray; +declare function zerosLike>( x: T, dtype: U ): ArrayDataTypeMap[U]; // EXPORTS // From d43d99f28d956386fdc7087bf1fe85891b4cbb26 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sat, 17 Feb 2024 15:45:08 -0500 Subject: [PATCH 11/20] chore: remove extra space --- lib/node_modules/@stdlib/types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/types/index.d.ts b/lib/node_modules/@stdlib/types/index.d.ts index e85df44f15ed..d5e341a917e9 100644 --- a/lib/node_modules/@stdlib/types/index.d.ts +++ b/lib/node_modules/@stdlib/types/index.d.ts @@ -600,7 +600,7 @@ declare module '@stdlib/types/array' { * - `float64`: double-precision floating-point numbers (IEEE 754) * - `float32`: single-precision floating-point numbers (IEEE 754) */ - type RealFloatingPointArrayMap = { // eslint-disable-line @typescript-eslint/consistent-type-definitions + type RealFloatingPointArrayMap = { // eslint-disable-line @typescript-eslint/consistent-type-definitions 'float64': Float64Array; 'float32': Float32Array; }; From 94edd4c5a4809935e0e7da1d28787a4e3162ee02 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sat, 17 Feb 2024 15:55:35 -0500 Subject: [PATCH 12/20] refactor: remove unneeded generic parameter --- lib/node_modules/@stdlib/array/empty-like/docs/types/index.d.ts | 2 +- lib/node_modules/@stdlib/array/ones-like/docs/types/index.d.ts | 2 +- lib/node_modules/@stdlib/array/zeros-like/docs/types/index.d.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/array/empty-like/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/empty-like/docs/types/index.d.ts index 4898492ec8d5..5c633c08e185 100644 --- a/lib/node_modules/@stdlib/array/empty-like/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/empty-like/docs/types/index.d.ts @@ -90,7 +90,7 @@ declare function emptyLike( x: T ): T; * var arr = emptyLike( x, 'float32' ); * // returns */ -declare function emptyLike>( x: T, dtype: U ): ArrayDataTypeMap[U]; +declare function emptyLike>( x: AnyArray, dtype: T ): ArrayDataTypeMap[T]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/ones-like/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/ones-like/docs/types/index.d.ts index 87237a3102cb..5dff75a0f972 100644 --- a/lib/node_modules/@stdlib/array/ones-like/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/ones-like/docs/types/index.d.ts @@ -79,7 +79,7 @@ declare function onesLike( x: T ): T; * var y = onesLike( x, 'float32' ); * // returns [ 1.0, 1.0 ] */ -declare function onesLike>( x: T, dtype: U ): ArrayDataTypeMap[U]; +declare function onesLike>( x: AnyArray, dtype: T ): ArrayDataTypeMap[T]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/zeros-like/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/zeros-like/docs/types/index.d.ts index 7f1d909bad9f..bfba5caa5091 100644 --- a/lib/node_modules/@stdlib/array/zeros-like/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/zeros-like/docs/types/index.d.ts @@ -79,7 +79,7 @@ declare function zerosLike( x: T ): T; * var y = zerosLike( x, 'float32' ); * // returns [ 0.0, 0.0 ] */ -declare function zerosLike>( x: T, dtype: U ): ArrayDataTypeMap[U]; +declare function zerosLike>( x: AnyArray, dtype: T ): ArrayDataTypeMap[T]; // EXPORTS // From b74bdbc90e98644bf72b1a5f3aabde8ab5471e75 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Wed, 21 Feb 2024 20:46:21 -0500 Subject: [PATCH 13/20] feat: rename and add additional type map types --- .../array/convert/docs/types/index.d.ts | 4 +- .../array/empty-like/docs/types/index.d.ts | 4 +- .../@stdlib/array/empty/docs/types/index.d.ts | 4 +- .../array/filled/docs/types/index.d.ts | 16 +-- .../@stdlib/array/full/docs/types/index.d.ts | 4 +- .../array/one-to/docs/types/index.d.ts | 4 +- .../array/ones-like/docs/types/index.d.ts | 4 +- .../@stdlib/array/ones/docs/types/index.d.ts | 4 +- .../@stdlib/array/typed/docs/types/index.d.ts | 16 +-- .../array/zero-to/docs/types/index.d.ts | 4 +- .../array/zeros-like/docs/types/index.d.ts | 4 +- .../@stdlib/array/zeros/docs/types/index.d.ts | 4 +- lib/node_modules/@stdlib/types/index.d.ts | 125 ++++++++++-------- 13 files changed, 109 insertions(+), 88 deletions(-) diff --git a/lib/node_modules/@stdlib/array/convert/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/convert/docs/types/index.d.ts index 7113cadeb115..ea0c1d777073 100644 --- a/lib/node_modules/@stdlib/array/convert/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/convert/docs/types/index.d.ts @@ -20,7 +20,7 @@ /// -import { Collection, ArrayDataTypeMap } from '@stdlib/types/array'; +import { Collection, DataTypeMap } from '@stdlib/types/array'; /** * Converts an array to an array of a different data type. @@ -34,7 +34,7 @@ import { Collection, ArrayDataTypeMap } from '@stdlib/types/array'; * var out = convert( arr, 'float64' ); * // returns [ 1.0, 2.0, 3.0, 4.0 ] */ -declare function convert>( x: Collection, dtype: U ): ArrayDataTypeMap[U]; +declare function convert>( x: Collection, dtype: U ): DataTypeMap[U]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/empty-like/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/empty-like/docs/types/index.d.ts index 5c633c08e185..2c6744997b90 100644 --- a/lib/node_modules/@stdlib/array/empty-like/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/empty-like/docs/types/index.d.ts @@ -20,7 +20,7 @@ /// -import { AnyArray, ArrayDataTypeMap } from '@stdlib/types/array'; +import { AnyArray, DataTypeMap } from '@stdlib/types/array'; /** * Creates an uninitialized array having the same length and data type as a provided input array. @@ -90,7 +90,7 @@ declare function emptyLike( x: T ): T; * var arr = emptyLike( x, 'float32' ); * // returns */ -declare function emptyLike>( x: AnyArray, dtype: T ): ArrayDataTypeMap[T]; +declare function emptyLike>( x: AnyArray, dtype: T ): DataTypeMap[T]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/empty/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/empty/docs/types/index.d.ts index 08bab7a80134..41c408b6b34b 100644 --- a/lib/node_modules/@stdlib/array/empty/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/empty/docs/types/index.d.ts @@ -20,7 +20,7 @@ /// -import { ArrayDataTypeMap } from '@stdlib/types/array'; +import { DataTypeMap } from '@stdlib/types/array'; /** * Creates an uninitialized array having a specified length. @@ -58,7 +58,7 @@ import { ArrayDataTypeMap } from '@stdlib/types/array'; * var arr = empty( 2, 'float32' ); * // returns */ -declare function empty = 'float64'>( length: number, dtype?: T ): ArrayDataTypeMap[T]; +declare function empty = 'float64'>( length: number, dtype?: T ): DataTypeMap[T]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/filled/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/filled/docs/types/index.d.ts index d795e89f335e..2823527ff051 100644 --- a/lib/node_modules/@stdlib/array/filled/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/filled/docs/types/index.d.ts @@ -22,7 +22,7 @@ /// -import { Collection, ArrayDataTypeMap } from '@stdlib/types/array'; +import { Collection, DataTypeMap } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; /** @@ -54,7 +54,7 @@ import { IterableIterator } from '@stdlib/types/iter'; * var arr = filledarray( 'float32' ); * // returns */ -declare function filledarray = 'float64'>( dtype?: U ): ArrayDataTypeMap[U]; +declare function filledarray = 'float64'>( dtype?: U ): DataTypeMap[U]; /** * Creates a filled array having a specified `length`. @@ -72,7 +72,7 @@ declare function filledarray = 'flo * var arr = filledarray( 1.0, 5, 'float32' ); * // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] */ -declare function filledarray = 'float64'>( value: T, length: number, dtype?: U ): ArrayDataTypeMap[U]; +declare function filledarray = 'float64'>( value: T, length: number, dtype?: U ): DataTypeMap[U]; /** * Creates a filled array from another `array`. @@ -90,7 +90,7 @@ declare function filledarray = 'float64'> * var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); * // returns [ 1.0, 1.0, 1.0 ] */ -declare function filledarray = 'float64'>( value: T, array: Collection, dtype?: U ): ArrayDataTypeMap[U]; +declare function filledarray = 'float64'>( value: T, array: Collection, dtype?: U ): DataTypeMap[U]; /** * Creates a filled array from an iterable. @@ -118,7 +118,7 @@ declare function filledarray = 'float64'> * var arr = filledarray( 1.0, it, 'float32' ); * // returns [ 1.0, 1.0, 1.0 ] */ -declare function filledarray = 'float64'>( value: T, iterable: IterableIterator, dtype?: U ): ArrayDataTypeMap[U]; +declare function filledarray = 'float64'>( value: T, iterable: IterableIterator, dtype?: U ): DataTypeMap[U]; /** * Returns a filled typed array view of an `ArrayBuffer`. @@ -148,7 +148,7 @@ declare function filledarray = 'float64'> * var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); * // returns [ 1.0, 1.0 ] */ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: U ): ArrayDataTypeMap[U]; +declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: U ): DataTypeMap[U]; /** * Returns a filled typed array view of an `ArrayBuffer`. @@ -177,7 +177,7 @@ declare function filledarray = 'float64'> * var arr = filledarray( 1.0, buf, 8, 'float32' ); * // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] */ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, dtype?: U ): ArrayDataTypeMap[U]; +declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, dtype?: U ): DataTypeMap[U]; /** * Returns a filled typed array view of an `ArrayBuffer`. @@ -205,7 +205,7 @@ declare function filledarray = 'float64'> * var arr = filledarray( 1.0, buf, 'float32' ); * // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] */ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, dtype?: U ): ArrayDataTypeMap[U]; +declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, dtype?: U ): DataTypeMap[U]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/full/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/full/docs/types/index.d.ts index 3e52c7c9251f..b6220bef6f36 100644 --- a/lib/node_modules/@stdlib/array/full/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/full/docs/types/index.d.ts @@ -20,7 +20,7 @@ /// -import { ArrayDataTypeMap } from '@stdlib/types/array'; +import { DataTypeMap } from '@stdlib/types/array'; /** * Creates a filled array having a specified length. @@ -53,7 +53,7 @@ import { ArrayDataTypeMap } from '@stdlib/types/array'; * var arr = full( 2, 1.0, 'float32' ); * // returns [ 1.0, 1.0 ] */ -declare function full = 'float64'>( length: number, value: T, dtype?: U ): ArrayDataTypeMap[U]; +declare function full = 'float64'>( length: number, value: T, dtype?: U ): DataTypeMap[U]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/one-to/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/one-to/docs/types/index.d.ts index 79395ce73c98..aa883d897e92 100644 --- a/lib/node_modules/@stdlib/array/one-to/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/one-to/docs/types/index.d.ts @@ -20,7 +20,7 @@ /// -import { ArrayDataTypeMap } from '@stdlib/types/array'; +import { DataTypeMap } from '@stdlib/types/array'; /** * Generates a linearly spaced numeric array whose elements increment by 1 starting from one. @@ -37,7 +37,7 @@ import { ArrayDataTypeMap } from '@stdlib/types/array'; * var arr = oneTo( 2, 'float32' ); * // returns [ 1.0, 2.0 ] */ -declare function oneTo = 'float64'>( n: number, dtype?: T ): ArrayDataTypeMap[T]; +declare function oneTo = 'float64'>( n: number, dtype?: T ): DataTypeMap[T]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/ones-like/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/ones-like/docs/types/index.d.ts index 5dff75a0f972..3081f97465ec 100644 --- a/lib/node_modules/@stdlib/array/ones-like/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/ones-like/docs/types/index.d.ts @@ -20,7 +20,7 @@ /// -import { ArrayDataTypeMap, AnyArray } from '@stdlib/types/array'; +import { DataTypeMap, AnyArray } from '@stdlib/types/array'; /** * Creates an array filled with ones and having the same length and data type as a provided input array. @@ -79,7 +79,7 @@ declare function onesLike( x: T ): T; * var y = onesLike( x, 'float32' ); * // returns [ 1.0, 1.0 ] */ -declare function onesLike>( x: AnyArray, dtype: T ): ArrayDataTypeMap[T]; +declare function onesLike>( x: AnyArray, dtype: T ): DataTypeMap[T]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/ones/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/ones/docs/types/index.d.ts index 203764b6e027..f98e15ec2386 100644 --- a/lib/node_modules/@stdlib/array/ones/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/ones/docs/types/index.d.ts @@ -20,7 +20,7 @@ /// -import { ArrayDataTypeMap } from '@stdlib/types/array'; +import { DataTypeMap } from '@stdlib/types/array'; /** * Creates an array filled with ones and having a specified length. @@ -52,7 +52,7 @@ import { ArrayDataTypeMap } from '@stdlib/types/array'; * var arr = ones( 2, 'float32' ); * // returns [ 1.0, 1.0 ] */ -declare function ones = 'float64'>( length: number, dtype?: T ): ArrayDataTypeMap[T]; +declare function ones = 'float64'>( length: number, dtype?: T ): DataTypeMap[T]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/typed/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/typed/docs/types/index.d.ts index 979f16df07ef..6cf6c705f800 100644 --- a/lib/node_modules/@stdlib/array/typed/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/typed/docs/types/index.d.ts @@ -22,7 +22,7 @@ /// -import { RealOrComplexTypedArray, TypedArrayMap } from '@stdlib/types/array'; +import { RealOrComplexTypedArray, TypedDataTypeMap } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array/buffer' ); /** @@ -39,7 +39,7 @@ import ArrayBuffer = require( '@stdlib/array/buffer' ); * var arr = typedarray( 'float32'); * // returns */ -declare function typedarray( dtype?: T ): TypedArrayMap[T]; +declare function typedarray( dtype?: T ): TypedDataTypeMap[T]; /** * Creates a typed array. @@ -56,7 +56,7 @@ declare function typedarray( dtype?: * var arr = typedarray( 2, 'float32' ); * // returns [ 0.0, 0.0 ] */ -declare function typedarray( length: number, dtype?: T ): TypedArrayMap[T]; +declare function typedarray( length: number, dtype?: T ): TypedDataTypeMap[T]; /** * Creates a typed array. @@ -83,7 +83,7 @@ declare function typedarray( length: * var arr2 = typedarray( arr1, 'uint32' ); * // returns [ 5, 3 ] */ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: T ): TypedArrayMap[T]; +declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: T ): TypedDataTypeMap[T]; /** * Creates a typed array. @@ -100,7 +100,7 @@ declare function typedarray( typedarr * var arr = typedarray( [ 5, -3 ], 'int32' ); * // returns [ 5, -3 ] */ -declare function typedarray( obj: ArrayLike | Iterable, dtype?: T ): TypedArrayMap[T]; +declare function typedarray( obj: ArrayLike | Iterable, dtype?: T ): TypedDataTypeMap[T]; /** * Creates a typed array. @@ -123,7 +123,7 @@ declare function typedarray( obj: Arr * var arr = typedarray( buf, 'float32' ); * // returns [ 0.0, 0.0, 0.0, 0.0 ] */ -declare function typedarray( buffer: ArrayBuffer, dtype?: T ): TypedArrayMap[T]; +declare function typedarray( buffer: ArrayBuffer, dtype?: T ): TypedDataTypeMap[T]; /** * Creates a typed array. @@ -147,7 +147,7 @@ declare function typedarray( buffer: * var arr = typedarray( buf, 8, 'float32' ); * // returns [ 0.0, 0.0 ] */ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: T ): TypedArrayMap[T]; +declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: T ): TypedDataTypeMap[T]; /** * Creates a typed array. @@ -172,7 +172,7 @@ declare function typedarray( buffer: * var arr = typedarray( buf, 8, 2, 'int32' ); * // returns [ 0, 0 ] */ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: T ): TypedArrayMap[T]; +declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: T ): TypedDataTypeMap[T]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/zero-to/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/zero-to/docs/types/index.d.ts index c1fee5390121..25d6b1316b1a 100644 --- a/lib/node_modules/@stdlib/array/zero-to/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/zero-to/docs/types/index.d.ts @@ -20,7 +20,7 @@ /// -import { ArrayDataTypeMap } from '@stdlib/types/array'; +import { DataTypeMap } from '@stdlib/types/array'; /** * Generates a linearly spaced numeric array whose elements increment by 1 starting from zero. @@ -37,7 +37,7 @@ import { ArrayDataTypeMap } from '@stdlib/types/array'; * var arr = zeroTo( 2, 'float32' ); * // returns [ 0.0, 1.0 ] */ -declare function zeroTo = 'float64'>( n: number, dtype?: T ): ArrayDataTypeMap[T]; +declare function zeroTo = 'float64'>( n: number, dtype?: T ): DataTypeMap[T]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/zeros-like/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/zeros-like/docs/types/index.d.ts index bfba5caa5091..47785c8f91dd 100644 --- a/lib/node_modules/@stdlib/array/zeros-like/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/zeros-like/docs/types/index.d.ts @@ -20,7 +20,7 @@ /// -import { ArrayDataTypeMap, AnyArray } from '@stdlib/types/array'; +import { DataTypeMap, AnyArray } from '@stdlib/types/array'; /** * Creates a zero-filled array having the same length and data type as a provided input array. @@ -79,7 +79,7 @@ declare function zerosLike( x: T ): T; * var y = zerosLike( x, 'float32' ); * // returns [ 0.0, 0.0 ] */ -declare function zerosLike>( x: AnyArray, dtype: T ): ArrayDataTypeMap[T]; +declare function zerosLike>( x: AnyArray, dtype: T ): DataTypeMap[T]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/zeros/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/zeros/docs/types/index.d.ts index c124f86396f7..c7deb797c224 100644 --- a/lib/node_modules/@stdlib/array/zeros/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/zeros/docs/types/index.d.ts @@ -20,7 +20,7 @@ /// -import { ArrayDataTypeMap } from '@stdlib/types/array'; +import { DataTypeMap } from '@stdlib/types/array'; /** * Creates a zero-filled array having a specified length. @@ -52,7 +52,7 @@ import { ArrayDataTypeMap } from '@stdlib/types/array'; * var arr = zeros( 2, 'float32' ); * // returns [ 0.0, 0.0 ] */ -declare function zeros = 'float64'>( length: number, dtype?: T ): ArrayDataTypeMap[T]; +declare function zeros = 'float64'>( length: number, dtype?: T ): DataTypeMap[T]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/types/index.d.ts b/lib/node_modules/@stdlib/types/index.d.ts index d5e341a917e9..786c47d53386 100644 --- a/lib/node_modules/@stdlib/types/index.d.ts +++ b/lib/node_modules/@stdlib/types/index.d.ts @@ -595,83 +595,104 @@ declare module '@stdlib/types/array' { type Collection = Array | TypedArray | ArrayLike; // eslint-disable-line @typescript-eslint/no-explicit-any /** - * Type mapping for the following array data types: - * - * - `float64`: double-precision floating-point numbers (IEEE 754) - * - `float32`: single-precision floating-point numbers (IEEE 754) + * Mapping of data types to array constructors. */ - type RealFloatingPointArrayMap = { // eslint-disable-line @typescript-eslint/consistent-type-definitions + type DataTypeMap = TypedDataTypeMap & { 'generic': Array }; + + /** + * Mapping of data types for real-valued typed arrays to array constructors. + */ + type RealDataTypeMap = RealFloatingPointDataTypeMap & IntegerDataTypeMap; + + /** + * Mapping of data types for complex number typed arrays to array constructors. + */ + type RealFloatingPointDataTypeMap = { // eslint-disable-line @typescript-eslint/consistent-type-definitions 'float64': Float64Array; 'float32': Float32Array; }; /** - * Type mapping for the following array data types: - * - * - `complex128`: double-precision complex floating-point numbers - * - `complex64`: single-precision complex floating-point numbers + * Mapping of data types for complex number typed arrays to array constructors. */ - type ComplexArrayMap = { // eslint-disable-line @typescript-eslint/consistent-type-definitions + type ComplexFloatingPointDataTypeMap = { // eslint-disable-line @typescript-eslint/consistent-type-definitions 'complex64': Complex64Array; 'complex128': Complex128Array; }; + /** + * Mapping of data types for floating-point (real or complex) typed arrays to array constructors. + */ + type FloatingPointDataTypeMap = RealFloatingPointDataTypeMap & ComplexFloatingPointDataTypeMap; + + /** + * Mapping for numeric data types (real or complex) to array constructors. + */ + type NumericDataTypeMap = RealDataTypeMap & ComplexFloatingPointDataTypeMap; + /** * Type mapping for the following array data types: - * - * - `complex64`: single-precision complex floating-point numbers - * - `int32`: 32-bit two's complement signed integers - * - `uint32`: 32-bit unsigned integers - * - `int16`: 16-bit two's complement signed integers - * - `uint16`: 16-bit unsigned integers - * - `int8`: 8-bit two's complement signed integers - * - `uint8`: 8-bit unsigned integers - * - `uint8c`: 8-bit unsigned integers clamped to `0-255` */ - type IntegerArrayMap = { // eslint-disable-line @typescript-eslint/consistent-type-definitions + type IntegerDataTypeMap = SignedIntegerDataTypeMap & UnsignedIntegerDataTypeMap; + + /** + * Mapping of signed integer data types to array constructors. + */ + type SignedIntegerDataTypeMap = { // eslint-disable-line @typescript-eslint/consistent-type-definitions 'int32': Int32Array; - 'uint32': Uint32Array; 'int16': Int16Array; - 'uint16': Uint16Array; 'int8': Int8Array; + }; + + /** + * Mapping of unsigned integer data types to array constructors. + */ + type UnsignedIntegerDataTypeMap = { // eslint-disable-line @typescript-eslint/consistent-type-definitions + 'uint32': Uint32Array; + 'uint16': Uint16Array; 'uint8': Uint8Array; 'uint8c': Uint8ClampedArray; }; /** - * Type mapping for the following array data types: - * - * - `float64`: double-precision floating-point numbers (IEEE 754) - * - `float32`: single-precision floating-point numbers (IEEE 754) - * - `complex128`: double-precision complex floating-point numbers - * - `complex64`: single-precision complex floating-point numbers - * - `int32`: 32-bit two's complement signed integers - * - `uint32`: 32-bit unsigned integers - * - `int16`: 16-bit two's complement signed integers - * - `uint16`: 16-bit unsigned integers - * - `int8`: 8-bit two's complement signed integers - * - `uint8`: 8-bit unsigned integers - * - `uint8c`: 8-bit unsigned integers clamped to `0-255` + * Mapping for signed integer data types including the generic option to array constructors. */ - type TypedArrayMap = RealFloatingPointArrayMap & ComplexArrayMap & IntegerArrayMap; + type SignedIntegerAndGenericDataTypeMap = SignedIntegerDataTypeMap & { 'generic': Array }; /** - * Type mapping for the following array data types: - * - * - `float64`: double-precision floating-point numbers (IEEE 754) - * - `float32`: single-precision floating-point numbers (IEEE 754) - * - `complex128`: double-precision complex floating-point numbers - * - `complex64`: single-precision complex floating-point numbers - * - `int32`: 32-bit two's complement signed integers - * - `uint32`: 32-bit unsigned integers - * - `int16`: 16-bit two's complement signed integers - * - `uint16`: 16-bit unsigned integers - * - `int8`: 8-bit two's complement signed integers - * - `uint8`: 8-bit unsigned integers - * - `uint8c`: 8-bit unsigned integers clamped to `0-255` - * - `generic`: generic JavaScript values - */ - type ArrayDataTypeMap = TypedArrayMap & { 'generic': Array }; + * Mapping for unsigned integer data types including the generic option to array constructors. + */ + type UnsignedIntegerAndGenericDataTypeMap = UnsignedIntegerDataTypeMap & { 'generic': Array }; + + /** + * Mapping for real floating point data types including the generic option to array constructors. + */ + type RealFloatingPointAndGenericDataTypeMap = RealFloatingPointDataTypeMap & { 'generic': Array }; + + /** + * Mapping for complex floating point data types including the generic option to array constructors. + */ + type ComplexFloatingPointAndGenericDataTypeMap = ComplexFloatingPointDataTypeMap & { 'generic': Array }; + + /** + * Mapping for floating point (real or complex) data types including the generic option to array constructors. + */ + type FloatingPointAndGenericDataTypeMap = FloatingPointDataTypeMap & { 'generic': Array }; + + /** + * Mapping for numeric (real or complex) data types including the generic option to array constructors. + */ + type NumericAndGenericDataTypeMap = NumericDataTypeMap & { 'generic': Array }; + + /** + * Mapping for all typed (real, complex) data types including the generic option to array constructors. + */ + type TypedAndGenericDataTypeMap = TypedDataTypeMap & { 'generic': Array }; + + /** + * Mapping for strctly typed array data types to array constructors. + */ + type TypedDataTypeMap = RealFloatingPointDataTypeMap & ComplexFloatingPointDataTypeMap; } /** From 44f5c269b01375f9111735738d5cf1f155ffd566 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Wed, 21 Feb 2024 21:28:24 -0500 Subject: [PATCH 14/20] feat: add and use remap utility type --- lib/node_modules/@stdlib/types/index.d.ts | 34 ++++++++++++++--------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/lib/node_modules/@stdlib/types/index.d.ts b/lib/node_modules/@stdlib/types/index.d.ts index 786c47d53386..380f621fed22 100644 --- a/lib/node_modules/@stdlib/types/index.d.ts +++ b/lib/node_modules/@stdlib/types/index.d.ts @@ -35,6 +35,7 @@ */ declare module '@stdlib/types/array' { import { ComplexLike, Complex64, Complex128 } from '@stdlib/types/complex'; + import { Remap } from '@stdlib/types/utilities'; /** * Data type. @@ -597,12 +598,12 @@ declare module '@stdlib/types/array' { /** * Mapping of data types to array constructors. */ - type DataTypeMap = TypedDataTypeMap & { 'generic': Array }; + type DataTypeMap = Remap }>; /** * Mapping of data types for real-valued typed arrays to array constructors. */ - type RealDataTypeMap = RealFloatingPointDataTypeMap & IntegerDataTypeMap; + type RealDataTypeMap = Remap; /** * Mapping of data types for complex number typed arrays to array constructors. @@ -623,17 +624,17 @@ declare module '@stdlib/types/array' { /** * Mapping of data types for floating-point (real or complex) typed arrays to array constructors. */ - type FloatingPointDataTypeMap = RealFloatingPointDataTypeMap & ComplexFloatingPointDataTypeMap; + type FloatingPointDataTypeMap = Remap; /** * Mapping for numeric data types (real or complex) to array constructors. */ - type NumericDataTypeMap = RealDataTypeMap & ComplexFloatingPointDataTypeMap; + type NumericDataTypeMap = Remap; /** * Type mapping for the following array data types: */ - type IntegerDataTypeMap = SignedIntegerDataTypeMap & UnsignedIntegerDataTypeMap; + type IntegerDataTypeMap = Remap; /** * Mapping of signed integer data types to array constructors. @@ -657,42 +658,42 @@ declare module '@stdlib/types/array' { /** * Mapping for signed integer data types including the generic option to array constructors. */ - type SignedIntegerAndGenericDataTypeMap = SignedIntegerDataTypeMap & { 'generic': Array }; + type SignedIntegerAndGenericDataTypeMap = Remap }>; /** * Mapping for unsigned integer data types including the generic option to array constructors. */ - type UnsignedIntegerAndGenericDataTypeMap = UnsignedIntegerDataTypeMap & { 'generic': Array }; + type UnsignedIntegerAndGenericDataTypeMap = Remap }>; /** * Mapping for real floating point data types including the generic option to array constructors. */ - type RealFloatingPointAndGenericDataTypeMap = RealFloatingPointDataTypeMap & { 'generic': Array }; + type RealFloatingPointAndGenericDataTypeMap = Remap }>; /** * Mapping for complex floating point data types including the generic option to array constructors. */ - type ComplexFloatingPointAndGenericDataTypeMap = ComplexFloatingPointDataTypeMap & { 'generic': Array }; + type ComplexFloatingPointAndGenericDataTypeMap = Remap }>; /** * Mapping for floating point (real or complex) data types including the generic option to array constructors. */ - type FloatingPointAndGenericDataTypeMap = FloatingPointDataTypeMap & { 'generic': Array }; + type FloatingPointAndGenericDataTypeMap = Remap }>; /** * Mapping for numeric (real or complex) data types including the generic option to array constructors. */ - type NumericAndGenericDataTypeMap = NumericDataTypeMap & { 'generic': Array }; + type NumericAndGenericDataTypeMap = Remap }>; /** * Mapping for all typed (real, complex) data types including the generic option to array constructors. */ - type TypedAndGenericDataTypeMap = TypedDataTypeMap & { 'generic': Array }; + type TypedAndGenericDataTypeMap = Remap }>; /** * Mapping for strctly typed array data types to array constructors. */ - type TypedDataTypeMap = RealFloatingPointDataTypeMap & ComplexFloatingPointDataTypeMap; + type TypedDataTypeMap = Remap; } /** @@ -3053,6 +3054,13 @@ declare module '@stdlib/types/utilities' { * Override the properties of a first type with the properties of a second type. */ type Override = Omit & U; + + /** + * Remap all properties of a type for better Intellisense. + */ + type Remap = { + [K in keyof T]: T[K]; + } & {}; } /** From efb404c2e2a9a68537565ed87db6ae4ddf8bf44e Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Wed, 21 Feb 2024 21:36:20 -0500 Subject: [PATCH 15/20] fix: ensure generic arrays yield numeric arrays as return type --- .../array/empty-like/docs/types/index.d.ts | 33 +++++++++++++------ .../array/empty-like/docs/types/test.ts | 4 +++ .../array/ones-like/docs/types/index.d.ts | 26 ++++++++++----- .../array/ones-like/docs/types/test.ts | 4 +++ .../array/zeros-like/docs/types/index.d.ts | 26 ++++++++++----- .../array/zeros-like/docs/types/test.ts | 4 +++ 6 files changed, 69 insertions(+), 28 deletions(-) diff --git a/lib/node_modules/@stdlib/array/empty-like/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/empty-like/docs/types/index.d.ts index 2c6744997b90..1ab4fb6120a6 100644 --- a/lib/node_modules/@stdlib/array/empty-like/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/empty-like/docs/types/index.d.ts @@ -20,7 +20,7 @@ /// -import { AnyArray, DataTypeMap } from '@stdlib/types/array'; +import { AnyArray, NumericAndGenericDataTypeMap, TypedArray, ComplexTypedArray } from '@stdlib/types/array'; /** * Creates an uninitialized array having the same length and data type as a provided input array. @@ -36,22 +36,35 @@ import { AnyArray, DataTypeMap } from '@stdlib/types/array'; * @example * var zeros = require( '@stdlib/array/zeros' ); * -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] +* var x = zeros( 2, 'generic' ); +* // returns [ 0.0, 0.0 ] * * var arr = emptyLike( x ); -* // returns +* // returns [ 0.0, 0.0 ] +*/ +declare function emptyLike( x: Array ): Array; + +/** +* Creates an uninitialized array having the same length as a provided input array. +* +* ## Notes +* +* - In browser environments, the function always returns zero-filled arrays. +* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. +* +* @param x - input array from which to derive the output array length +* @returns empty array * * @example * var zeros = require( '@stdlib/array/zeros' ); * -* var x = zeros( 2, 'generic' ); -* // returns [ 0.0, 0.0 ] +* var x = zeros( 2, 'float64' ); +* // returns [ 0.0, 0.0 ] * -* var arr = emptyLike( x ); -* // returns [ 0.0, 0.0 ] +* var arr = emptyLike( x, 'float32' ); +* // returns */ -declare function emptyLike( x: T ): T; +declare function emptyLike( x: T ): T; /** * Creates an uninitialized array having the same length as a provided input array. @@ -90,7 +103,7 @@ declare function emptyLike( x: T ): T; * var arr = emptyLike( x, 'float32' ); * // returns */ -declare function emptyLike>( x: AnyArray, dtype: T ): DataTypeMap[T]; +declare function emptyLike>( x: AnyArray, dtype: T ): NumericAndGenericDataTypeMap[T]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/empty-like/docs/types/test.ts b/lib/node_modules/@stdlib/array/empty-like/docs/types/test.ts index 18732504416d..58f865dd9318 100644 --- a/lib/node_modules/@stdlib/array/empty-like/docs/types/test.ts +++ b/lib/node_modules/@stdlib/array/empty-like/docs/types/test.ts @@ -39,6 +39,7 @@ import emptyLike = require( './index' ); emptyLike( new Uint16Array( [ 0, 0 ] ) ); // $ExpectType Uint16Array emptyLike( new Uint8Array( [ 0, 0 ] ) ); // $ExpectType Uint8Array emptyLike( new Uint8ClampedArray( [ 0, 0 ] ) ); // $ExpectType Uint8ClampedArray + emptyLike( [ 'a', 'b', 'c' ] ); // $ExpectType number[] emptyLike( [ 0, 0 ], 'float64' ); // $ExpectType Float64Array emptyLike( [ 0, 0 ], 'float32' ); // $ExpectType Float32Array @@ -54,6 +55,9 @@ import emptyLike = require( './index' ); emptyLike( [ 0, 0 ], 'uint8' ); // $ExpectType Uint8Array emptyLike( [ 0, 0 ], 'uint8c' ); // $ExpectType Uint8ClampedArray emptyLike( [ 0, 0 ], 'generic' ); // $ExpectType number[] + emptyLike( new Int32Array( [ 0, 0 ] ), 'generic' ); // $ExpectType number[] + emptyLike( [ 'a', 'b', 'c' ], 'generic' ); // $ExpectType number[] + emptyLike( [ 'a', 'b', 'c' ], 'float64' ); // $ExpectType Float64Array } // The compiler throws an error if the function is not provided an array or typed array for the first argument... diff --git a/lib/node_modules/@stdlib/array/ones-like/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/ones-like/docs/types/index.d.ts index 3081f97465ec..2b85c7692ec6 100644 --- a/lib/node_modules/@stdlib/array/ones-like/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/ones-like/docs/types/index.d.ts @@ -20,7 +20,7 @@ /// -import { DataTypeMap, AnyArray } from '@stdlib/types/array'; +import { NumericAndGenericDataTypeMap, AnyArray, TypedArray, ComplexTypedArray } from '@stdlib/types/array'; /** * Creates an array filled with ones and having the same length and data type as a provided input array. @@ -31,22 +31,30 @@ import { DataTypeMap, AnyArray } from '@stdlib/types/array'; * @example * var zeros = require( '@stdlib/array/zeros' ); * -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] +* var x = zeros( 2, 'generic' ); +* // returns [ 0, 0 ] * * var y = onesLike( x ); -* // returns [ 1.0, 1.0 ] +* // returns [ 1, 1 ] +*/ +declare function onesLike( x: Array ): Array; + +/** +* Creates an array filled with ones and having the same length and data type as a provided input array. +* +* @param x - input array from which to derive the output array length +* @returns filled array * * @example * var zeros = require( '@stdlib/array/zeros' ); * -* var x = zeros( 2, 'generic' ); -* // returns [ 0, 0 ] +* var x = zeros( 2, 'float64' ); +* // returns [ 0.0, 0.0 ] * * var y = onesLike( x ); -* // returns [ 1, 1 ] +* // returns [ 1.0, 1.0 ] */ -declare function onesLike( x: T ): T; +declare function onesLike( x: T ): T; /** * Creates an array filled with ones and having the same length as a provided input array. @@ -79,7 +87,7 @@ declare function onesLike( x: T ): T; * var y = onesLike( x, 'float32' ); * // returns [ 1.0, 1.0 ] */ -declare function onesLike>( x: AnyArray, dtype: T ): DataTypeMap[T]; +declare function onesLike>( x: AnyArray, dtype: T ): NumericAndGenericDataTypeMap[T]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/ones-like/docs/types/test.ts b/lib/node_modules/@stdlib/array/ones-like/docs/types/test.ts index 65617157c7e0..cb69754a8bbc 100644 --- a/lib/node_modules/@stdlib/array/ones-like/docs/types/test.ts +++ b/lib/node_modules/@stdlib/array/ones-like/docs/types/test.ts @@ -37,6 +37,7 @@ import onesLike = require( './index' ); onesLike( new Uint16Array( [ 0, 0 ] ) ); // $ExpectType Uint16Array onesLike( new Uint8Array( [ 0, 0 ] ) ); // $ExpectType Uint8Array onesLike( new Uint8ClampedArray( [ 0, 0 ] ) ); // $ExpectType Uint8ClampedArray + onesLike( [ 'a', 'b', 'c' ] ); // $ExpectType number[] onesLike( [ 0, 0 ], 'float64' ); // $ExpectType Float64Array onesLike( [ 0, 0 ], 'float32' ); // $ExpectType Float32Array @@ -50,6 +51,9 @@ import onesLike = require( './index' ); onesLike( [ 0, 0 ], 'uint8' ); // $ExpectType Uint8Array onesLike( [ 0, 0 ], 'uint8c' ); // $ExpectType Uint8ClampedArray onesLike( [ 0, 0 ], 'generic' ); // $ExpectType number[] + onesLike( new Int32Array( [ 0, 0 ] ), 'generic' ); // $ExpectType number[] + onesLike( [ 'a', 'b', 'c' ], 'generic' ); // $ExpectType number[] + onesLike( [ 'a', 'b', 'c' ], 'float64' ); // $ExpectType Float64Array } // The compiler throws an error if the function is not provided an array or typed array for the first argument... diff --git a/lib/node_modules/@stdlib/array/zeros-like/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/zeros-like/docs/types/index.d.ts index 47785c8f91dd..dc82b05ba5d8 100644 --- a/lib/node_modules/@stdlib/array/zeros-like/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/zeros-like/docs/types/index.d.ts @@ -20,7 +20,7 @@ /// -import { DataTypeMap, AnyArray } from '@stdlib/types/array'; +import { NumericAndGenericDataTypeMap, AnyArray, TypedArray, ComplexTypedArray } from '@stdlib/types/array'; /** * Creates a zero-filled array having the same length and data type as a provided input array. @@ -31,22 +31,30 @@ import { DataTypeMap, AnyArray } from '@stdlib/types/array'; * @example * var zeros = require( '@stdlib/array/zeros' ); * -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] +* var x = zeros( 2, 'generic' ); +* // returns [ 0, 0 ] * * var y = zerosLike( x ); -* // returns [ 0.0, 0.0 ] +* // returns [ 0, 0 ] +*/ +declare function zerosLike( x: Array ): Array; + +/** +* Creates a zero-filled array having the same length and data type as a provided input array. +* +* @param x - input array from which to derive the output array length +* @returns zero-filled array * * @example * var zeros = require( '@stdlib/array/zeros' ); * -* var x = zeros( 2, 'generic' ); -* // returns [ 0, 0 ] +* var x = zeros( 2, 'float64' ); +* // returns [ 0.0, 0.0 ] * * var y = zerosLike( x ); -* // returns [ 0, 0 ] +* // returns [ 0.0, 0.0 ] */ -declare function zerosLike( x: T ): T; +declare function zerosLike( x: T ): T; /** * Creates a zero-filled array having the same length as a provided input array. @@ -79,7 +87,7 @@ declare function zerosLike( x: T ): T; * var y = zerosLike( x, 'float32' ); * // returns [ 0.0, 0.0 ] */ -declare function zerosLike>( x: AnyArray, dtype: T ): DataTypeMap[T]; +declare function zerosLike>( x: AnyArray, dtype: T ): NumericAndGenericDataTypeMap[T]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/zeros-like/docs/types/test.ts b/lib/node_modules/@stdlib/array/zeros-like/docs/types/test.ts index ae406445f526..51064dda33e2 100644 --- a/lib/node_modules/@stdlib/array/zeros-like/docs/types/test.ts +++ b/lib/node_modules/@stdlib/array/zeros-like/docs/types/test.ts @@ -37,6 +37,7 @@ import zerosLike = require( './index' ); zerosLike( new Uint16Array( [ 0, 0 ] ) ); // $ExpectType Uint16Array zerosLike( new Uint8Array( [ 0, 0 ] ) ); // $ExpectType Uint8Array zerosLike( new Uint8ClampedArray( [ 0, 0 ] ) ); // $ExpectType Uint8ClampedArray + zerosLike( [ 'a', 'b', 'c' ] ); // $ExpectType number[] zerosLike( [ 0, 0 ], 'float64' ); // $ExpectType Float64Array zerosLike( [ 0, 0 ], 'float32' ); // $ExpectType Float32Array @@ -50,6 +51,9 @@ import zerosLike = require( './index' ); zerosLike( [ 0, 0 ], 'uint8' ); // $ExpectType Uint8Array zerosLike( [ 0, 0 ], 'uint8c' ); // $ExpectType Uint8ClampedArray zerosLike( [ 0, 0 ], 'generic' ); // $ExpectType number[] + zerosLike( new Int32Array( [ 0, 0 ] ), 'generic' ); // $ExpectType number[] + zerosLike( [ 'a', 'b', 'c' ], 'generic' ); // $ExpectType number[] + zerosLike( [ 'a', 'b', 'c' ], 'float64' ); // $ExpectType Float64Array } // The compiler throws an error if the function is not provided an array or typed array for the first argument... From 838a1d2bd9edd191d9f7ea6f57f8434713c82aee Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Wed, 21 Feb 2024 21:39:39 -0500 Subject: [PATCH 16/20] chore: fix indentation Signed-off-by: Philipp Burckhardt --- lib/node_modules/@stdlib/types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/types/index.d.ts b/lib/node_modules/@stdlib/types/index.d.ts index f5cea676e7f8..e35aab0aebd1 100644 --- a/lib/node_modules/@stdlib/types/index.d.ts +++ b/lib/node_modules/@stdlib/types/index.d.ts @@ -695,7 +695,7 @@ declare module '@stdlib/types/array' { */ type TypedDataTypeMap = Remap; - /** + /** * Boolean index array. */ type BooleanIndexArray = Collection | AccessorArrayLike; From 90b3657e59d9110b8bbd4a76606c2fcc7500b7c0 Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 21 Feb 2024 19:40:56 -0800 Subject: [PATCH 17/20] Apply suggestions from code review Signed-off-by: Athan --- lib/node_modules/@stdlib/types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/types/index.d.ts b/lib/node_modules/@stdlib/types/index.d.ts index e35aab0aebd1..972c8927bffd 100644 --- a/lib/node_modules/@stdlib/types/index.d.ts +++ b/lib/node_modules/@stdlib/types/index.d.ts @@ -693,7 +693,7 @@ declare module '@stdlib/types/array' { /** * Mapping for strctly typed array data types to array constructors. */ - type TypedDataTypeMap = Remap; + type TypedDataTypeMap = Remap; /** * Boolean index array. From 855b5ac3ad34e9c8555cfa93aebe3547f7ae7010 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Thu, 22 Feb 2024 09:07:23 -0500 Subject: [PATCH 18/20] fix: update import of complex type map and alias it --- .../array/typed-complex/docs/types/index.d.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/array/typed-complex/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/typed-complex/docs/types/index.d.ts index 7655601a4a10..f9f799a8194b 100644 --- a/lib/node_modules/@stdlib/array/typed-complex/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/typed-complex/docs/types/index.d.ts @@ -22,7 +22,7 @@ /// -import { ArrayLike, ComplexTypedArray, ComplexArrayMap } from '@stdlib/types/array'; +import { ArrayLike, ComplexTypedArray, ComplexFloatingPointDataTypeMap as DataTypeMap } from '@stdlib/types/array'; import ArrayBuffer = require( '@stdlib/array/buffer' ); /** @@ -39,7 +39,7 @@ import ArrayBuffer = require( '@stdlib/array/buffer' ); * var arr = complexarray( 'complex64'); * // returns */ -declare function complexarray( dtype?: T ): ComplexArrayMap[T]; +declare function complexarray( dtype?: T ): DataTypeMap[T]; /** * Creates a complex number typed array. @@ -56,7 +56,7 @@ declare function complexarray( d * var arr = complexarray( 2, 'complex64' ); * // returns */ -declare function complexarray( length: number, dtype?: T ): ComplexArrayMap[T]; +declare function complexarray( length: number, dtype?: T ): DataTypeMap[T]; /** * Creates a complex number typed array. @@ -73,7 +73,7 @@ declare function complexarray( l * var arr = complexarray( new Complex128Array( 2 ), 'complex64' ); * // returns */ -declare function complexarray( complexarray: ComplexTypedArray, dtype?: T ): ComplexArrayMap[T]; +declare function complexarray( complexarray: ComplexTypedArray, dtype?: T ): DataTypeMap[T]; /** * Creates a complex number typed array. @@ -91,7 +91,7 @@ declare function complexarray( c * var arr = complexarray( [ 5, -3 ], 'complex64' ); * // returns */ -declare function complexarray( obj: ArrayLike | Iterable, dtype?: T ): ComplexArrayMap[T]; +declare function complexarray( obj: ArrayLike | Iterable, dtype?: T ): DataTypeMap[T]; /** * Creates a complex number typed array. @@ -114,7 +114,7 @@ declare function complexarray( o * var arr = complexarray( buf, 'complex64' ); * // returns */ -declare function complexarray( buffer: ArrayBuffer, dtype?: T ): ComplexArrayMap[T]; +declare function complexarray( buffer: ArrayBuffer, dtype?: T ): DataTypeMap[T]; /** * Creates a complex number typed array. @@ -138,7 +138,7 @@ declare function complexarray( b * var arr = complexarray( buf, 16, 'complex64' ); * // returns */ -declare function complexarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: T ): ComplexArrayMap[T]; +declare function complexarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: T ): DataTypeMap[T]; /** * Creates a complex number typed array. @@ -163,7 +163,7 @@ declare function complexarray( b * var arr = complexarray( buf, 16, 2, 'complex64' ); * // returns */ -declare function complexarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: T ): ComplexArrayMap[T]; +declare function complexarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: T ): DataTypeMap[T]; // EXPORTS // From 0aa9a991afa86028f4e9530877f33c5b3fa394bf Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Thu, 22 Feb 2024 09:08:02 -0500 Subject: [PATCH 19/20] refactor: use NumericAndGenericDataTypeMap due to numeric nature of functions --- lib/node_modules/@stdlib/array/one-to/docs/types/index.d.ts | 4 ++-- lib/node_modules/@stdlib/array/ones/docs/types/index.d.ts | 4 ++-- lib/node_modules/@stdlib/array/zero-to/docs/types/index.d.ts | 4 ++-- lib/node_modules/@stdlib/array/zeros/docs/types/index.d.ts | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/array/one-to/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/one-to/docs/types/index.d.ts index aa883d897e92..dd7b3407e73d 100644 --- a/lib/node_modules/@stdlib/array/one-to/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/one-to/docs/types/index.d.ts @@ -20,7 +20,7 @@ /// -import { DataTypeMap } from '@stdlib/types/array'; +import { NumericAndGenericDataTypeMap } from '@stdlib/types/array'; /** * Generates a linearly spaced numeric array whose elements increment by 1 starting from one. @@ -37,7 +37,7 @@ import { DataTypeMap } from '@stdlib/types/array'; * var arr = oneTo( 2, 'float32' ); * // returns [ 1.0, 2.0 ] */ -declare function oneTo = 'float64'>( n: number, dtype?: T ): DataTypeMap[T]; +declare function oneTo = 'float64'>( n: number, dtype?: T ): NumericAndGenericDataTypeMap[T]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/ones/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/ones/docs/types/index.d.ts index f98e15ec2386..e9da827f9cf2 100644 --- a/lib/node_modules/@stdlib/array/ones/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/ones/docs/types/index.d.ts @@ -20,7 +20,7 @@ /// -import { DataTypeMap } from '@stdlib/types/array'; +import { NumericAndGenericDataTypeMap } from '@stdlib/types/array'; /** * Creates an array filled with ones and having a specified length. @@ -52,7 +52,7 @@ import { DataTypeMap } from '@stdlib/types/array'; * var arr = ones( 2, 'float32' ); * // returns [ 1.0, 1.0 ] */ -declare function ones = 'float64'>( length: number, dtype?: T ): DataTypeMap[T]; +declare function ones = 'float64'>( length: number, dtype?: T ): NumericAndGenericDataTypeMap[T]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/zero-to/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/zero-to/docs/types/index.d.ts index 25d6b1316b1a..93e2a1695e5f 100644 --- a/lib/node_modules/@stdlib/array/zero-to/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/zero-to/docs/types/index.d.ts @@ -20,7 +20,7 @@ /// -import { DataTypeMap } from '@stdlib/types/array'; +import { NumericAndGenericDataTypeMap } from '@stdlib/types/array'; /** * Generates a linearly spaced numeric array whose elements increment by 1 starting from zero. @@ -37,7 +37,7 @@ import { DataTypeMap } from '@stdlib/types/array'; * var arr = zeroTo( 2, 'float32' ); * // returns [ 0.0, 1.0 ] */ -declare function zeroTo = 'float64'>( n: number, dtype?: T ): DataTypeMap[T]; +declare function zeroTo = 'float64'>( n: number, dtype?: T ): NumericAndGenericDataTypeMap[T]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/zeros/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/zeros/docs/types/index.d.ts index c7deb797c224..848339a517b0 100644 --- a/lib/node_modules/@stdlib/array/zeros/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/zeros/docs/types/index.d.ts @@ -20,7 +20,7 @@ /// -import { DataTypeMap } from '@stdlib/types/array'; +import { NumericAndGenericDataTypeMap } from '@stdlib/types/array'; /** * Creates a zero-filled array having a specified length. @@ -52,7 +52,7 @@ import { DataTypeMap } from '@stdlib/types/array'; * var arr = zeros( 2, 'float32' ); * // returns [ 0.0, 0.0 ] */ -declare function zeros = 'float64'>( length: number, dtype?: T ): DataTypeMap[T]; +declare function zeros = 'float64'>( length: number, dtype?: T ): NumericAndGenericDataTypeMap[T]; // EXPORTS // From f5a633294289b16fb2f40259dd85cfdd0f0697ca Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Thu, 22 Feb 2024 09:10:13 -0500 Subject: [PATCH 20/20] refactor: use DataTypeMap to convey empty array not necessarily being numeric --- .../@stdlib/array/empty-like/docs/types/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/array/empty-like/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/empty-like/docs/types/index.d.ts index 1ab4fb6120a6..189f7afd9cdd 100644 --- a/lib/node_modules/@stdlib/array/empty-like/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/empty-like/docs/types/index.d.ts @@ -20,7 +20,7 @@ /// -import { AnyArray, NumericAndGenericDataTypeMap, TypedArray, ComplexTypedArray } from '@stdlib/types/array'; +import { AnyArray, DataTypeMap, TypedArray, ComplexTypedArray } from '@stdlib/types/array'; /** * Creates an uninitialized array having the same length and data type as a provided input array. @@ -103,7 +103,7 @@ declare function emptyLike( x: T ): T; * var arr = emptyLike( x, 'float32' ); * // returns */ -declare function emptyLike>( x: AnyArray, dtype: T ): NumericAndGenericDataTypeMap[T]; +declare function emptyLike>( x: AnyArray, dtype: T ): DataTypeMap[T]; // EXPORTS //