sfcode An Online Competing and Development Environment

Integer Number

Integer number primitive

# <tt>integer/coerce</tt>

Follows `finite/coerce` additionally stripping decimal part from the number

const coerceToInteger = require("type/integer/coerce");
coerceToInteger("12.95"); // 12
coerceToInteger(Infinity); // null
coerceToInteger(null); // null

# <tt>integer/ensure</tt>

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

const ensureInteger = require("type/integer/ensure");
ensureInteger(12.93); // "12"
ensureInteger(null); // Thrown TypeError: null is not an integer