diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts index c9a109e..10745d2 100644 --- a/docs/types/index.d.ts +++ b/docs/types/index.d.ts @@ -23,8 +23,21 @@ import contains = require( '@stdlib/array-base-assert-contains' ); import hasSameValues = require( '@stdlib/array-base-assert-has-same-values' ); import isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); +import isComplexFloatingPointDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); +import isComplexTypedArray = require( '@stdlib/array-base-assert-is-complex-typed-array' ); import isComplex64Array = require( '@stdlib/array-base-assert-is-complex64array' ); import isComplex128Array = require( '@stdlib/array-base-assert-is-complex128array' ); +import isDataType = require( '@stdlib/array-base-assert-is-data-type' ); +import isFloatingPointDataType = require( '@stdlib/array-base-assert-is-floating-point-data-type' ); +import isIntegerDataType = require( '@stdlib/array-base-assert-is-integer-data-type' ); +import isMostlySafeDataTypeCast = require( '@stdlib/array-base-assert-is-mostly-safe-data-type-cast' ); +import isNumericDataType = require( '@stdlib/array-base-assert-is-numeric-data-type' ); +import isRealDataType = require( '@stdlib/array-base-assert-is-real-data-type' ); +import isRealFloatingPointDataType = require( '@stdlib/array-base-assert-is-real-floating-point-data-type' ); +import isSafeDataTypeCast = require( '@stdlib/array-base-assert-is-safe-data-type-cast' ); +import isSameKindDataTypeCast = require( '@stdlib/array-base-assert-is-same-kind-data-type-cast' ); +import isSignedIntegerDataType = require( '@stdlib/array-base-assert-is-signed-integer-data-type' ); +import isUnsignedIntegerDataType = require( '@stdlib/array-base-assert-is-unsigned-integer-data-type' ); /** * Interface describing the `assert` namespace. @@ -93,6 +106,73 @@ interface Namespace { */ isAccessorArray: typeof isAccessorArray; + /** + * Tests whether an input value is a supported array complex-valued floating-point data type. + * + * @param v - value to test + * @returns boolean indicating whether an input value is a supported array complex-valued floating-point data type + * + * @example + * var bool = ns.isComplexFloatingPointDataType( 'complex64' ); + * // returns true + * + * bool = ns.isComplexFloatingPointDataType( 'complex128' ); + * // returns true + * + * bool = ns.isComplexFloatingPointDataType( 'float32' ); + * // returns false + * + * bool = ns.isComplexFloatingPointDataType( 'float64' ); + * // returns false + * + * bool = ns.isComplexFloatingPointDataType( 'generic' ); + * // returns false + * + * bool = ns.isComplexFloatingPointDataType( 'int16' ); + * // returns false + * + * bool = ns.isComplexFloatingPointDataType( 'int32' ); + * // returns false + * + * bool = ns.isComplexFloatingPointDataType( 'int8' ); + * // returns false + * + * bool = ns.isComplexFloatingPointDataType( 'uint16' ); + * // returns false + * + * bool = ns.isComplexFloatingPointDataType( 'uint32' ); + * // returns false + * + * bool = ns.isComplexFloatingPointDataType( 'uint8' ); + * // returns false + * + * bool = ns.isComplexFloatingPointDataType( 'uint8c' ); + * // returns false + * + * bool = ns.isComplexFloatingPointDataType( 'foo' ); + * // returns false + */ + isComplexFloatingPointDataType: typeof isComplexFloatingPointDataType; + + /** + * Tests if a value is a complex typed array. + * + * @param value - value to test + * @returns boolean indicating whether a value is complex typed array + * + * @example + * var Complex128Array = require( '@stdlib/array-complex128' ); + * + * var arr = new Complex128Array( 10 ); + * var bool = ns.isComplexTypedArray( arr ); + * // returns true + * + * @example + * var bool = ns.isComplexTypedArray( [] ); + * // returns false + */ + isComplexTypedArray: typeof isComplexTypedArray; + /** * Tests if a value is a `Complex64Array`. * @@ -130,6 +210,393 @@ interface Namespace { * // returns false */ isComplex128Array: typeof isComplex128Array; + + /** + * Tests whether an input value is a supported array data type. + * + * @param v - value to test + * @returns boolean indicating whether an input value is a supported array data type + * + * @example + * var bool = ns.isDataType( 'float32' ); + * // returns true + * + * bool = ns.isDataType( 'float64' ); + * // returns true + * + * bool = ns.isDataType( 'generic' ); + * // returns true + * + * bool = ns.isDataType( 'int16' ); + * // returns true + * + * bool = ns.isDataType( 'int32' ); + * // returns true + * + * bool = ns.isDataType( 'int8' ); + * // returns true + * + * bool = ns.isDataType( 'uint16' ); + * // returns true + * + * bool = ns.isDataType( 'uint32' ); + * // returns true + * + * bool = ns.isDataType( 'uint8' ); + * // returns true + * + * bool = ns.isDataType( 'uint8c' ); + * // returns true + * + * bool = ns.isDataType( 'foo' ); + * // returns false + */ + isDataType: typeof isDataType; + + /** + * Tests whether an input value is a supported array floating-point data type. + * + * @param v - value to test + * @returns boolean indicating whether an input value is a supported array floating-point data type + * + * @example + * var bool = ns.isFloatingPointDataType( 'float32' ); + * // returns true + * + * bool = ns.isFloatingPointDataType( 'float64' ); + * // returns true + * + * bool = ns.isFloatingPointDataType( 'generic' ); + * // returns false + * + * bool = ns.isFloatingPointDataType( 'int16' ); + * // returns false + * + * bool = ns.isFloatingPointDataType( 'int32' ); + * // returns false + * + * bool = ns.isFloatingPointDataType( 'int8' ); + * // returns false + * + * bool = ns.isFloatingPointDataType( 'uint16' ); + * // returns false + * + * bool = ns.isFloatingPointDataType( 'uint32' ); + * // returns false + * + * bool = ns.isFloatingPointDataType( 'uint8' ); + * // returns false + * + * bool = ns.isFloatingPointDataType( 'uint8c' ); + * // returns false + * + * bool = ns.isFloatingPointDataType( 'foo' ); + * // returns false + */ + isFloatingPointDataType: typeof isFloatingPointDataType; + + /** + * Tests whether an input value is a supported array integer (i.e., signed or unsigned integer) data type. + * + * @param v - value to test + * @returns boolean indicating whether an input value is a supported array integer data type + * + * @example + * var bool = ns.isIntegerDataType( 'float32' ); + * // returns false + * + * bool = ns.isIntegerDataType( 'float64' ); + * // returns false + * + * bool = ns.isIntegerDataType( 'generic' ); + * // returns false + * + * bool = ns.isIntegerDataType( 'int16' ); + * // returns true + * + * bool = ns.isIntegerDataType( 'int32' ); + * // returns true + * + * bool = ns.isIntegerDataType( 'int8' ); + * // returns true + * + * bool = ns.isIntegerDataType( 'uint16' ); + * // returns true + * + * bool = ns.isIntegerDataType( 'uint32' ); + * // returns true + * + * bool = ns.isIntegerDataType( 'uint8' ); + * // returns true + * + * bool = ns.isIntegerDataType( 'uint8c' ); + * // returns true + * + * bool = ns.isIntegerDataType( 'foo' ); + * // returns false + */ + isIntegerDataType: typeof isIntegerDataType; + + /** + * Returns a boolean indicating if a provided array data type can be safely cast or, for floating-point data types, downcast to another array data type. + * + * @param from - array data type + * @param to - array data type + * @returns boolean indicating if a data type can be cast to another data type + * + * @example + * var bool = ns.isMostlySafeDataTypeCast( 'float32', 'float64' ); + * // returns true + * + * bool = ns.isMostlySafeDataTypeCast( 'float64', 'int32' ); + * // returns false + */ + isMostlySafeDataTypeCast: typeof isMostlySafeDataTypeCast; + + /** + * Tests whether an input value is a supported array numeric data type. + * + * @param v - value to test + * @returns boolean indicating whether an input value is a supported array numeric data type + * + * @example + * var bool = ns.isNumericDataType( 'float32' ); + * // returns true + * + * bool = ns.isNumericDataType( 'float64' ); + * // returns true + * + * bool = ns.isNumericDataType( 'generic' ); + * // returns false + * + * bool = ns.isNumericDataType( 'int16' ); + * // returns true + * + * bool = ns.isNumericDataType( 'int32' ); + * // returns true + * + * bool = ns.isNumericDataType( 'int8' ); + * // returns true + * + * bool = ns.isNumericDataType( 'uint16' ); + * // returns true + * + * bool = ns.isNumericDataType( 'uint32' ); + * // returns true + * + * bool = ns.isNumericDataType( 'uint8' ); + * // returns true + * + * bool = ns.isNumericDataType( 'uint8c' ); + * // returns true + * + * bool = ns.isNumericDataType( 'foo' ); + * // returns false + */ + isNumericDataType: typeof isNumericDataType; + + /** + * Tests whether an input value is a supported array real-valued data type. + * + * @param v - value to test + * @returns boolean indicating whether an input value is a supported array real-valued data type + * + * @example + * var bool = ns.isRealDataType( 'float32' ); + * // returns true + * + * bool = ns.isRealDataType( 'float64' ); + * // returns true + * + * bool = ns.isRealDataType( 'complex128' ); + * // returns false + * + * bool = ns.isRealDataType( 'generic' ); + * // returns false + * + * bool = ns.isRealDataType( 'int16' ); + * // returns true + * + * bool = ns.isRealDataType( 'int32' ); + * // returns true + * + * bool = ns.isRealDataType( 'int8' ); + * // returns true + * + * bool = ns.isRealDataType( 'uint16' ); + * // returns true + * + * bool = ns.isRealDataType( 'uint32' ); + * // returns true + * + * bool = ns.isRealDataType( 'uint8' ); + * // returns true + * + * bool = ns.isRealDataType( 'uint8c' ); + * // returns true + * + * bool = ns.isRealDataType( 'foo' ); + * // returns false + */ + isRealDataType: typeof isRealDataType; + + /** + * Tests whether an input value is a supported array real-valued floating-point data type. + * + * @param v - value to test + * @returns boolean indicating whether an input value is a supported array real-valued floating-point data type + * + * @example + * var bool = ns.isRealFloatingPointDataType( 'float32' ); + * // returns true + * + * bool = ns.isRealFloatingPointDataType( 'float64' ); + * // returns true + * + * bool = ns.isRealFloatingPointDataType( 'generic' ); + * // returns false + * + * bool = ns.isRealFloatingPointDataType( 'int16' ); + * // returns false + * + * bool = ns.isRealFloatingPointDataType( 'int32' ); + * // returns false + * + * bool = ns.isRealFloatingPointDataType( 'int8' ); + * // returns false + * + * bool = ns.isRealFloatingPointDataType( 'uint16' ); + * // returns false + * + * bool = ns.isRealFloatingPointDataType( 'uint32' ); + * // returns false + * + * bool = ns.isRealFloatingPointDataType( 'uint8' ); + * // returns false + * + * bool = ns.isRealFloatingPointDataType( 'uint8c' ); + * // returns false + * + * bool = ns.isRealFloatingPointDataType( 'foo' ); + * // returns false + */ + isRealFloatingPointDataType: typeof isRealFloatingPointDataType; + + /** + * Returns a boolean indicating if a provided array data type can be safely cast to another array data type. + * + * @param from - array data type + * @param to - array data type + * @returns boolean indicating if a data type can be safely cast to another data type + * + * @example + * var bool = ns.isSafeDataTypeCast( 'float32', 'float64' ); + * // returns true + * + * bool = ns.isSafeDataTypeCast( 'float64', 'int32' ); + * // returns false + */ + isSafeDataTypeCast: typeof isSafeDataTypeCast; + + /** + * Returns a boolean indicating if a provided array data type can be safely cast to, or is of the same "kind" as, another array data type. + * + * @param from - array data type + * @param to - array data type + * @returns boolean indicating if a data type can be cast to another data type + * + * @example + * var bool = ns.isSameKindDataTypeCast( 'float32', 'float64' ); + * // returns true + * + * bool = ns.isSameKindDataTypeCast( 'uint16', 'int16' ); + * // returns false + */ + isSameKindDataTypeCast: typeof isSameKindDataTypeCast; + + /** + * Tests whether an input value is a supported array signed integer data type. + * + * @param v - value to test + * @returns boolean indicating whether an input value is a supported array signed integer data type + * + * @example + * var bool = ns.isSignedIntegerDataType( 'float32' ); + * // returns false + * + * bool = ns.isSignedIntegerDataType( 'float64' ); + * // returns false + * + * bool = ns.isSignedIntegerDataType( 'generic' ); + * // returns false + * + * bool = ns.isSignedIntegerDataType( 'int16' ); + * // returns true + * + * bool = ns.isSignedIntegerDataType( 'int32' ); + * // returns true + * + * bool = ns.isSignedIntegerDataType( 'int8' ); + * // returns true + * + * bool = ns.isSignedIntegerDataType( 'uint16' ); + * // returns false + * + * bool = ns.isSignedIntegerDataType( 'uint32' ); + * // returns false + * + * bool = ns.isSignedIntegerDataType( 'uint8' ); + * // returns false + * + * bool = ns.isSignedIntegerDataType( 'uint8c' ); + * // returns false + * + * bool = ns.isSignedIntegerDataType( 'foo' ); + * // returns false + */ + isSignedIntegerDataType: typeof isSignedIntegerDataType; + + /** + * Tests whether an input value is a supported array unsigned integer data type. + * + * @param v - value to test + * @returns boolean indicating whether an input value is a supported array unsigned integer data type + * + * @example + * var bool = ns.isUnsignedIntegerDataType( 'float32' ); + * // returns false + * + * bool = ns.isUnsignedIntegerDataType( 'float64' ); + * // returns false + * + * bool = ns.isUnsignedIntegerDataType( 'generic' ); + * // returns false + * + * bool = ns.isUnsignedIntegerDataType( 'int16' ); + * // returns false + * + * bool = ns.isUnsignedIntegerDataType( 'int32' ); + * // returns false + * + * bool = ns.isUnsignedIntegerDataType( 'int8' ); + * // returns false + * + * bool = ns.isUnsignedIntegerDataType( 'uint16' ); + * // returns true + * + * bool = ns.isUnsignedIntegerDataType( 'uint32' ); + * // returns true + * + * bool = ns.isUnsignedIntegerDataType( 'uint8' ); + * // returns true + * + * bool = ns.isUnsignedIntegerDataType( 'uint8c' ); + * // returns true + * + * bool = ns.isUnsignedIntegerDataType( 'foo' ); + * // returns false + */ + isUnsignedIntegerDataType: typeof isUnsignedIntegerDataType; } /** diff --git a/package.json b/package.json index fe0f48f..5c942b8 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/array-base-assert-has-same-values": "^0.2.0", "@stdlib/array-base-assert-is-accessor-array": "^0.2.0", "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.0", - "@stdlib/array-base-assert-is-complex-typed-array": "github:stdlib-js/array-base-assert-is-complex-typed-array#main", + "@stdlib/array-base-assert-is-complex-typed-array": "^0.1.0", "@stdlib/array-base-assert-is-complex128array": "^0.2.0", "@stdlib/array-base-assert-is-complex64array": "^0.2.0", "@stdlib/array-base-assert-is-data-type": "^0.2.0", @@ -54,7 +54,7 @@ "@stdlib/array-base-assert-is-same-kind-data-type-cast": "^0.3.0", "@stdlib/array-base-assert-is-signed-integer-data-type": "^0.2.0", "@stdlib/array-base-assert-is-unsigned-integer-data-type": "^0.2.0", - "@stdlib/utils-define-read-only-property": "^0.2.0" + "@stdlib/utils-define-read-only-property": "^0.2.1" }, "devDependencies": { "@stdlib/array-base-accessor": "^0.2.0", @@ -80,8 +80,8 @@ "@stdlib/array-uint32": "^0.2.0", "@stdlib/array-uint8": "^0.2.0", "@stdlib/array-uint8c": "^0.2.0", - "@stdlib/assert-has-own-property": "^0.2.0", - "@stdlib/assert-is-boolean": "^0.2.0", + "@stdlib/assert-has-own-property": "^0.2.1", + "@stdlib/assert-is-boolean": "^0.2.1", "@stdlib/assert-is-collection": "^0.2.0", "@stdlib/assert-is-same-value": "^0.2.0", "@stdlib/buffer-alloc-unsafe": "^0.2.0", @@ -89,9 +89,9 @@ "@stdlib/random-array-discrete-uniform": "^0.2.0", "@stdlib/strided-base-reinterpret-complex128": "^0.2.0", "@stdlib/strided-base-reinterpret-complex64": "^0.2.0", - "@stdlib/string-format": "^0.2.0", - "@stdlib/utils-constructor-name": "^0.2.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0", + "@stdlib/string-format": "^0.2.1", + "@stdlib/utils-constructor-name": "^0.2.1", + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", "@stdlib/utils-keys": "^0.2.0", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", "istanbul": "^0.4.1",