Function: isBigNumberish()
isBigNumberish(
input):input is BigNumberish
Defined in: src/utils/num.ts:431
Checks if a given value is of BigNumberish type.
234, 234n, "234" and "0xea" are valid ; a boolean is not, nor a string that spells no number —
'0x' included, which holds no digit.
A number or a bigint passes whatever its sign, and a number whatever its decimal part : -1,
-1n and 1.5 are all accepted here, and it is the Cairo type receiving the value that refuses
what it cannot hold. A string is unsigned : it passes as decimal digits or as 0x hexadecimal
only, so '-1' and '1.5' do not — to the library, such a string is text. The signed integer
classes, CairoInt8 to CairoInt128, are the one place where a leading minus sign is read as a
sign.
Parameters
input
unknown
a value
Returns
input is BigNumberish
true if type of input is BigNumberish
Example
const res = num.isBigNumberish("ZERO");
// res = false
const res2 = num.isBigNumberish(-1);
// res2 = true
const res3 = num.isBigNumberish('-1');
// res3 = false (a string is unsigned : this one is text)
const res4 = num.isBigNumberish(1.5);
// res4 = true (a number is not checked for a decimal part)
const res5 = num.isBigNumberish('0x');
// res5 = false (hexadecimal in form, but no digit)