Skip to content

Latest commit

 

History

History
27 lines (18 loc) · 632 Bytes

big-int.md

File metadata and controls

27 lines (18 loc) · 632 Bytes

BigInt

bigint primitive

big-int/coerce

BigInt coercion. If value can be coerced by BigInt its result is returned. For all other values null is returned

const coerceToBigInt = require("type/big-int/coerce");

coerceToBigInt(12); // 12n
coerceToBigInt(undefined); // null

big-int/ensure

If given argument is a bigint coercible value (via big-int/coerce) returns result bigint. Otherwise TypeError is thrown.

const ensureBigInt = require("type/big-int/ensure");

ensureBigInt(12); // 12n
ensureBigInt(null); // Thrown TypeError: null is not a bigint