isBinaryFixedPoint

function isBinaryFixedPoint<TSignedness, TTotalBits, TFractionalBits>(
    value,
    signedness?,
    totalBits?,
    fractionalBits?,
): value is BinaryFixedPoint<TSignedness, TTotalBits, TFractionalBits>;

Type guard that refines an unknown value to a BinaryFixedPoint.

Accepts the same partial-positional shape arguments as assertIsBinaryFixedPoint and returns true if the assertion would pass, false otherwise.

Type Parameters

Type ParameterDefault type
TSignedness extends SignednessSignedness
TTotalBits extends numbernumber
TFractionalBits extends numbernumber

Parameters

ParameterType
valueunknown
signedness?TSignedness
totalBits?TTotalBits
fractionalBits?TFractionalBits

Returns

value is BinaryFixedPoint<TSignedness, TTotalBits, TFractionalBits>

Example

if (isBinaryFixedPoint(value)) {
    value satisfies BinaryFixedPoint<Signedness, number, number>;
}
if (isBinaryFixedPoint(value, 'signed', 16, 15)) {
    value satisfies BinaryFixedPoint<'signed', 16, 15>;
}

See

On this page