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..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,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, DataTypeMap } 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 ): DataTypeMap[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... 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..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,10 +20,10 @@ /// -import { AnyArray, Complex128Array, Complex64Array, DataType } from '@stdlib/types/array'; +import { AnyArray, DataTypeMap, TypedArray, ComplexTypedArray } from '@stdlib/types/array'; /** -* Creates an uninitialized array having the same length as a provided input array. +* Creates an uninitialized array having the same length and data type as a provided input array. * * ## Notes * @@ -31,19 +31,18 @@ import { AnyArray, Complex128Array, Complex64Array, DataType } from '@stdlib/typ * - 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 x = zeros( 2, 'generic' ); +* // returns [ 0.0, 0.0 ] * -* var arr = emptyLike( x, 'float64' ); -* // returns +* var arr = emptyLike( x ); +* // returns [ 0.0, 0.0 ] */ -declare function emptyLike( x: AnyArray, dtype: 'float64' ): Float64Array; +declare function emptyLike( x: Array ): Array; /** * Creates an uninitialized array having the same length as a provided input array. @@ -54,203 +53,18 @@ declare function emptyLike( x: AnyArray, dtype: 'float64' ): Float64Array; * - 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 ] +* // 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; +declare function emptyLike( x: T ): T; /** * Creates an uninitialized array having the same length as a provided input array. @@ -258,45 +72,10 @@ declare function emptyLike( x: AnyArray, dtype: 'uint8' ): Uint8Array; * ## 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 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: +* The function recognizes the following data types: * * - `float64`: double-precision floating-point numbers (IEEE 754) * - `float32`: single-precision floating-point numbers (IEEE 754) @@ -311,11 +90,6 @@ declare function emptyLike( x: AnyArray, 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. -* - 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 @@ -324,473 +98,12 @@ declare function emptyLike( x: AnyArray, dtype: 'generic' ): Array; * 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 ); +* var arr = emptyLike( x, 'float32' ); * // 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; - -/** -* 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 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 -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'generic' ); -* // returns [ 0.0, 0.0 ] -* -* var arr = emptyLike( x ); -* // returns [ 0.0, 0.0 ] -*/ -declare function emptyLike( x: Array, dtype?: DataType ): Array; - -/** -* Creates an uninitialized array having the same length and data type as a provided input array. -* -* ## 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) -* - `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 -* -* @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 -*/ -declare function emptyLike( x: AnyArray, dtype?: DataType ): AnyArray; +declare function emptyLike>( x: AnyArray, dtype: T ): DataTypeMap[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/empty/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/empty/docs/types/index.d.ts index 35d6bd36696a..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,228 +20,11 @@ /// -import { Complex128Array, Complex64Array, DataType } from '@stdlib/types/array'; +import { DataTypeMap } 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 ): 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 ecb5901b9899..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 @@ -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, DataTypeMap } 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 ): DataTypeMap[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 ): DataTypeMap[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 ): DataTypeMap[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 ): DataTypeMap[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 ): DataTypeMap[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 ): DataTypeMap[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 ): DataTypeMap[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... 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..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,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 { DataTypeMap } 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 ): DataTypeMap[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... 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..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,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 { NumericAndGenericDataTypeMap } 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 ): NumericAndGenericDataTypeMap[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 0afcffe0f598..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,252 +20,29 @@ /// -import { Complex128Array, Complex64Array, AnyArray, DataType } from '@stdlib/types/array'; +import { NumericAndGenericDataTypeMap, AnyArray, TypedArray, ComplexTypedArray } 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. +* 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 -* @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 x = zeros( 2, 'generic' ); +* // returns [ 0, 0 ] * -* var y = onesLike( x, 'generic' ); -* // returns [ 1.0, 1.0 ] +* var y = onesLike( x ); +* // returns [ 1, 1 ] */ -declare function onesLike( x: AnyArray, dtype: 'generic' ): Array; +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. * -* 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 @@ -277,43 +54,10 @@ declare function onesLike( x: AnyArray, dtype: 'generic' ): Array; * 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; +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: * @@ -329,10 +73,6 @@ declare function onesLike( x: Float32Array, dtype?: DataType ): Float32Array; * - `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 @@ -341,356 +81,13 @@ declare function onesLike( x: Float32Array, dtype?: DataType ): Float32Array; * @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; - -/** -* 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 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 -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'generic' ); -* // returns [ 0, 0 ] -* -* var y = onesLike( x ); -* // returns [ 1, 1 ] -*/ -declare function onesLike( x: Array, dtype?: DataType ): 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 ] -* -* @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: 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/ones/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/ones/docs/types/index.d.ts index 88a26bd68441..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,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 { NumericAndGenericDataTypeMap } 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 ): NumericAndGenericDataTypeMap[T]; // EXPORTS // 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..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, ComplexFloatingPointDataType as DataType } 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?: DataType ): ComplexTypedArray; +declare function complexarray( dtype?: T ): DataTypeMap[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 ): DataTypeMap[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 ): DataTypeMap[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 ): DataTypeMap[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 ): DataTypeMap[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 ): DataTypeMap[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 ): DataTypeMap[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... 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..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 { ArrayLike, RealOrComplexTypedArray, NumericDataType } 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?: NumericDataType ): RealOrComplexTypedArray; +declare function typedarray( dtype?: T ): TypedDataTypeMap[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 ): TypedDataTypeMap[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 ): TypedDataTypeMap[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 ): TypedDataTypeMap[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 ): TypedDataTypeMap[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 ): TypedDataTypeMap[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 ): TypedDataTypeMap[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/array/zero-to/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/zero-to/docs/types/index.d.ts index 6122614ea104..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,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 { NumericAndGenericDataTypeMap } 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 ): NumericAndGenericDataTypeMap[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 5418b873488f..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,244 +20,29 @@ /// -import { Complex128Array, Complex64Array, AnyArray, DataType } from '@stdlib/types/array'; +import { NumericAndGenericDataTypeMap, AnyArray, TypedArray, ComplexTypedArray } 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. +* 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 -* @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 x = zeros( 2, 'generic' ); +* // returns [ 0, 0 ] * -* var y = zerosLike( x, 'generic' ); -* // returns [ 0.0, 0.0 ] +* var y = zerosLike( x ); +* // returns [ 0, 0 ] */ -declare function zerosLike( x: AnyArray, dtype: 'generic' ): Array; +declare function zerosLike( x: Array ): 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 @@ -269,76 +54,10 @@ declare function zerosLike( x: AnyArray, dtype: 'generic' ): Array; * var y = zerosLike( x ); * // returns [ 0.0, 0.0 ] */ -declare function zerosLike( x: Float64Array, dtype?: DataType ): Float64Array; +declare function zerosLike( x: T ): T; /** -* 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; - -/** -* 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: * @@ -362,319 +81,13 @@ declare function zerosLike( x: Complex128Array, dtype?: DataType ): Complex128Ar * @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 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 -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'generic' ); -* // returns [ 0, 0 ] -* -* var y = zerosLike( x ); -* // returns [ 0, 0 ] -*/ -declare function zerosLike( x: Array, dtype?: DataType ): 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 ] -* -* @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: 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... 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..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,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 { NumericAndGenericDataTypeMap } 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 ): NumericAndGenericDataTypeMap[T]; // EXPORTS // diff --git a/lib/node_modules/@stdlib/types/index.d.ts b/lib/node_modules/@stdlib/types/index.d.ts index 0a3b8d21ef57..972c8927bffd 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. @@ -594,6 +595,106 @@ declare module '@stdlib/types/array' { */ type Collection = Array | TypedArray | ArrayLike; // eslint-disable-line @typescript-eslint/no-explicit-any + /** + * Mapping of data types to array constructors. + */ + type DataTypeMap = Remap }>; + + /** + * Mapping of data types for real-valued typed arrays to array constructors. + */ + type RealDataTypeMap = Remap; + + /** + * 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; + }; + + /** + * Mapping of data types for complex number typed arrays to array constructors. + */ + 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 = Remap; + + /** + * Mapping for numeric data types (real or complex) to array constructors. + */ + type NumericDataTypeMap = Remap; + + /** + * Type mapping for the following array data types: + */ + type IntegerDataTypeMap = Remap; + + /** + * Mapping of signed integer data types to array constructors. + */ + type SignedIntegerDataTypeMap = { // eslint-disable-line @typescript-eslint/consistent-type-definitions + 'int32': Int32Array; + 'int16': Int16Array; + '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; + }; + + /** + * Mapping for signed integer data types including the generic option to array constructors. + */ + type SignedIntegerAndGenericDataTypeMap = Remap }>; + + /** + * Mapping for unsigned integer data types including the generic option to array constructors. + */ + type UnsignedIntegerAndGenericDataTypeMap = Remap }>; + + /** + * Mapping for real floating point data types including the generic option to array constructors. + */ + type RealFloatingPointAndGenericDataTypeMap = Remap }>; + + /** + * Mapping for complex floating point data types including the generic option to array constructors. + */ + type ComplexFloatingPointAndGenericDataTypeMap = Remap }>; + + /** + * Mapping for floating point (real or complex) data types including the generic option to array constructors. + */ + type FloatingPointAndGenericDataTypeMap = Remap }>; + + /** + * Mapping for numeric (real or complex) data types including the generic option to array constructors. + */ + type NumericAndGenericDataTypeMap = Remap }>; + + /** + * Mapping for all typed (real, complex) data types including the generic option to array constructors. + */ + type TypedAndGenericDataTypeMap = Remap }>; + + /** + * Mapping for strctly typed array data types to array constructors. + */ + type TypedDataTypeMap = Remap; + /** * Boolean index array. */ @@ -3195,6 +3296,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]; + } & {}; } /**