sfcode An Online Competing and Development Environment

Safe Integer Number

Safe integer number primitive

# <tt>safe-integer/coerce</tt>

Follows `integer/coerce` but returns `null` in place of values which are beyond `Number.MIN_SAFE_INTEGER` and `Number.MAX_SAFE_INTEGER` range.

const coerceToSafeInteger = require("type/safe-integer/coerce");
coerceToInteger("12.95"); // 12
coerceToInteger(9007199254740992); // null
coerceToInteger(null); // null

# <tt>safe-integer/ensure</tt>

If given argument is a safe integer coercible value (via `safe-integer/coerce`) returns result number. Otherwise `TypeError` is thrown.

const ensureSafeInteger = require("type/safe-integer/ensure");
ensureSafeInteger(12.93); // "12"
ensureSafeInteger(9007199254740992); // Thrown TypeError: null is not a safe integer