Skip to content

Latest commit

 

History

History
27 lines (18 loc) · 679 Bytes

integer.md

File metadata and controls

27 lines (18 loc) · 679 Bytes

Integer Number

Integer number primitive

integer/coerce

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

integer/ensure

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