isStringifiedNumber

function isStringifiedNumber(
    putativeNumber,
): putativeNumber is StringifiedNumber;

A type guard that returns true if the input string parses as a Number, and refines its type for use in your program.

Parameters

ParameterType
putativeNumberstring

Returns

putativeNumber is StringifiedNumber

Example

import { isStringifiedNumber } from '@solana/rpc-types';
 
if (isStringifiedNumber(numericString)) {
    // At this point, `numericString` has been refined to a `StringifiedNumber`
    numericString satisfies StringifiedNumber; // OK
} else {
    setError(`${numericString} does not represent a number`);
}

On this page