diff --git a/lib/node_modules/@stdlib/array/min-dtype/README.md b/lib/node_modules/@stdlib/array/min-dtype/README.md index 8e9f4511cf6b..c2e706a06a78 100644 --- a/lib/node_modules/@stdlib/array/min-dtype/README.md +++ b/lib/node_modules/@stdlib/array/min-dtype/README.md @@ -68,7 +68,7 @@ dt = minDataType( '3' ); ## Notes -- The function does **not** provide precision guarantees for non-integer-valued real numbers. In other words, the function returns the smallest possible floating-point (i.e., inexact) [data type][@stdlib/array/dtypes] for storing numbers having decimals. +- The function does **not** provide precision guarantees for non-integer-valued numbers. In other words, the function returns the smallest possible floating-point (i.e., inexact) [data type][@stdlib/array/dtypes] for storing numbers having decimals. diff --git a/lib/node_modules/@stdlib/array/min-dtype/docs/repl.txt b/lib/node_modules/@stdlib/array/min-dtype/docs/repl.txt index bc72a8d18b31..56df9cf1ca14 100644 --- a/lib/node_modules/@stdlib/array/min-dtype/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/min-dtype/docs/repl.txt @@ -4,7 +4,7 @@ storing a provided scalar value. The function does *not* provide precision guarantees for non-integer-valued - real numbers. In other words, the function returns the smallest possible + numbers. In other words, the function returns the smallest possible floating-point (i.e., inexact) data type for storing numbers having decimals. diff --git a/lib/node_modules/@stdlib/array/min-dtype/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/min-dtype/docs/types/index.d.ts index 814b932b70a5..e2c68295eaac 100644 --- a/lib/node_modules/@stdlib/array/min-dtype/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/min-dtype/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2021 The Stdlib Authors. +* Copyright (c) 2024 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ /// -import { RealDataType, ComplexFloatingPointDataType } from '@stdlib/types/array'; +import { RealDataType, ComplexFloatingPointDataType, BooleanDataType } from '@stdlib/types/array'; import { ComplexLike } from '@stdlib/types/complex'; /** @@ -28,7 +28,7 @@ import { ComplexLike } from '@stdlib/types/complex'; * * ## Notes * -* - The function does *not* provide precision guarantees for non-integer-valued real numbers. In other words, the function returns the smallest possible floating-point (i.e., inexact) data type for storing numbers having decimals. +* - The function does *not* provide precision guarantees for non-integer-valued numbers. In other words, the function returns the smallest possible floating-point (i.e., inexact) data type for storing numbers having decimals. * * @param value - scalar value * @returns array data type @@ -48,7 +48,7 @@ declare function minDataType( value: number ): RealDataType; * * ## Notes * -* - The function does *not* provide precision guarantees for non-integer-valued real numbers. In other words, the function returns the smallest possible floating-point (i.e., inexact) data type for storing numbers having decimals. +* - The function does *not* provide precision guarantees for non-integer-valued numbers. In other words, the function returns the smallest possible floating-point (i.e., inexact) data type for storing numbers having decimals. * * @param value - scalar value * @returns array data type @@ -63,12 +63,24 @@ declare function minDataType( value: number ): RealDataType; */ declare function minDataType( value: ComplexLike ): ComplexFloatingPointDataType; +/** +* Returns the minimum array data type of the closest "kind" necessary for storing a provided scalar value. +* +* @param value - scalar value +* @returns array data type +* +* @example +* var dt = minDataType( true ); +* // returns 'bool' +*/ +declare function minDataType( value: boolean ): BooleanDataType; + /** * Returns the minimum array data type of the closest "kind" necessary for storing a provided scalar value. * * ## Notes * -* - The function does *not* provide precision guarantees for non-integer-valued real numbers. In other words, the function returns the smallest possible floating-point (i.e., inexact) data type for storing numbers having decimals. +* - The function does *not* provide precision guarantees for non-integer-valued numbers. In other words, the function returns the smallest possible floating-point (i.e., inexact) data type for storing numbers having decimals. * * @param value - scalar value * @returns array data type diff --git a/lib/node_modules/@stdlib/array/min-dtype/docs/types/test.ts b/lib/node_modules/@stdlib/array/min-dtype/docs/types/test.ts index 2957567d6ee5..79214d61da54 100644 --- a/lib/node_modules/@stdlib/array/min-dtype/docs/types/test.ts +++ b/lib/node_modules/@stdlib/array/min-dtype/docs/types/test.ts @@ -30,6 +30,7 @@ import minDataType = require( './index' ); minDataType( 2.13 ); // $ExpectType RealDataType minDataType( z ); // $ExpectType ComplexFloatingPointDataType + minDataType( true ); // $ExpectType "bool" minDataType( 'beep' ); // $ExpectType "generic" } diff --git a/lib/node_modules/@stdlib/array/min-dtype/lib/main.js b/lib/node_modules/@stdlib/array/min-dtype/lib/main.js index bc8af625dd96..5342fcafab31 100644 --- a/lib/node_modules/@stdlib/array/min-dtype/lib/main.js +++ b/lib/node_modules/@stdlib/array/min-dtype/lib/main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2024 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,8 @@ // MODULES // +var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; var isInteger = require( '@stdlib/math/base/assert/is-integer' ); var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); @@ -84,7 +86,10 @@ function minFloatDataType( value ) { * // returns 'uint8' */ function minDataType( value ) { - if ( typeof value !== 'number' ) { + if ( !isNumber( value ) ) { + if ( isBoolean( value ) ) { + return 'bool'; + } if ( isComplexLike( value ) ) { if ( minFloatDataType( value.re ) === 'float64' || minFloatDataType( value.im ) === 'float64' ) { return 'complex128'; diff --git a/lib/node_modules/@stdlib/array/min-dtype/test/test.js b/lib/node_modules/@stdlib/array/min-dtype/test/test.js index 3075eb8808ca..7dab65e18b3d 100644 --- a/lib/node_modules/@stdlib/array/min-dtype/test/test.js +++ b/lib/node_modules/@stdlib/array/min-dtype/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2024 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -179,8 +179,8 @@ tape( 'the function returns the minimum array data type of the closest "kind" ne 'float32', 'generic', 'generic', - 'generic', - 'generic', + 'bool', + 'bool', 'generic', 'complex64', 'complex64',