UNPKG

@toreda/strong-types

Version:

Better TypeScript code in fewer lines.

21 lines (20 loc) 627 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.arrayNullValue = void 0; /** * Check if `value` is an array and return it when true. Otherwise returns * `fallback`. Guarantees return type without additional checks. * * @param value `value` to validate as an Array. * @param fallback Returned when `value` not an Array. * @returns `value` if it's an Array, otherwise `fallback`. * * @category Collections */ function arrayNullValue(value, fallback) { if (!Array.isArray(value)) { return fallback; } return value; } exports.arrayNullValue = arrayNullValue;