sfcode An Online Competing and Development Environment

Array length

number primitive that conforms as valid array length

# <tt>array-length/coerce</tt>

Follows `safe-integer/coerce` but returns `null` in place of values which are below `0`

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

# <tt>array-length/ensure</tt>

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

const ensureArrayLength = require("type/array-length/ensure");
ensureArrayLength(12.93); // "12"
ensureArrayLength(9007199254740992); // Thrown TypeError: null is not a valid array length