Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Feb 22, 2024
1 parent f9da7b4 commit 4433e6a
Show file tree
Hide file tree
Showing 21 changed files with 131 additions and 3,197 deletions.
172 changes: 2 additions & 170 deletions convert/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,175 +20,7 @@

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

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 <Float64Array>[ 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 <Float32Array>[ 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 <Int32Array>[ 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 <Int16Array>[ 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 <Int8Array>[ 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 <Uint32Array>[ 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 <Uint16Array>[ 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 <Uint8Array>[ 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 <Uint8ClampedArray>[ 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 <Complex128>
*/
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 <Complex64>
*/
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<any>;
import { Collection, DataTypeMap } from '@stdlib/types/array';

/**
* Converts an array to an array of a different data type.
Expand All @@ -202,7 +34,7 @@ declare function convert( x: Collection, dtype: 'generic' ): Array<any>;
* var out = convert( arr, 'float64' );
* // returns <Float64Array>[ 1.0, 2.0, 3.0, 4.0 ]
*/
declare function convert( x: Collection, dtype: DataType ): AnyArray;
declare function convert<T, U extends keyof DataTypeMap<T>>( x: Collection<T>, dtype: U ): DataTypeMap<T>[U];


// EXPORTS //
Expand Down
2 changes: 2 additions & 0 deletions convert/docs/types/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand Down
Loading

0 comments on commit 4433e6a

Please sign in to comment.