UNPKG

@toreda/strong-types

Version:

Better TypeScript code in fewer lines.

20 lines (19 loc) 579 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.arrayValue = void 0; /** * Check whether provided `value` is an Array and return it if so, * otherwise return provided `fallback`. * @param value `value` to validate as an Array. * @param fallback Returned when `value` is not an Array. * @returns `value` if it's an Array, otherwise `fallback`. * * @category Collections */ function arrayValue(value, fallback) { if (!Array.isArray(value)) { return fallback; } return value; } exports.arrayValue = arrayValue;