{"version":3,"file":"castArray-q6e5dBzI.cjs","names":["castArrayIfDefined"],"sources":["../src/functions/castArray/castArray.ts"],"sourcesContent":["import type { Many, Maybe } from '../../types';\nimport { castArrayIfDefined } from '../castArrayIfDefined';\n\n// NOTE: all JSDocs here are duplicated of one another since there's no way to inherit them at this time.\n// see https://github.com/microsoft/TypeScript/issues/407 for more info.\n\n/**\n * Casts the input value to an array if it is not already an array.\n * @param value The input value to cast to an array.\n * @returns An array containing the input value, or the input value itself if it is already an array.\n * @example\n * ```ts\n * castArray('foo'); // ['foo']\n * castArray(['foo']); // ['foo']\n * castArray(null); // []\n * castArray(undefined); // []\n * ```\n */\nexport function castArray<T>(value: null): T[];\n/**\n * Casts the input value to an array if it is not already an array.\n * @param value The input value to cast to an array.\n * @returns An array containing the input value, or the input value itself if it is already an array.\n * @example\n * ```ts\n * castArray('foo'); // ['foo']\n * castArray(['foo']); // ['foo']\n * castArray(null); // []\n * castArray(undefined); // []\n * ```\n */\nexport function castArray<T>(value: undefined): T[];\n/**\n * Casts the input value to an array if it is not already an array.\n * @param value The input value to cast to an array.\n * @returns An array containing the input value, or the input value itself if it is already an array.\n * @example\n * ```ts\n * castArray('foo'); // ['foo']\n * castArray(['foo']); // ['foo']\n * castArray(null); // []\n * castArray(undefined); // []\n * ```\n */\nexport function castArray<T>(value: readonly T[]): readonly T[];\n/**\n * Casts the input value to an array if it is not already an array.\n * @param value The input value to cast to an array.\n * @returns An array containing the input value, or the input value itself if it is already an array.\n * @example\n * ```ts\n * castArray('foo'); // ['foo']\n * castArray(['foo']); // ['foo']\n * castArray(null); // []\n * castArray(undefined); // []\n * ```\n */\nexport function castArray<T>(value: T[]): T[];\n/**\n * Casts the input value to an array if it is not already an array.\n * @param value The input value to cast to an array.\n * @returns An array containing the input value, or the input value itself if it is already an array.\n * @example\n * ```ts\n * castArray('foo'); // ['foo']\n * castArray(['foo']); // ['foo']\n * castArray(null); // []\n * castArray(undefined); // []\n * ```\n */\nexport function castArray<T>(\n  value: Maybe<\n    Many<NonNullable<T>, 'mutable'> | Many<NonNullable<T>, 'immutable'>\n  >\n): T[];\n/**\n * Casts the input value to an array if it is not already an array.\n * @param value The input value to cast to an array.\n * @returns An array containing the input value, or the input value itself if it is already an array.\n * @example\n * ```ts\n * castArray('foo'); // ['foo']\n * castArray(['foo']); // ['foo']\n * castArray(null); // []\n * castArray(undefined); // []\n * ```\n */\nexport function castArray<T>(value: NonNullable<T>): T[];\n/**\n * Implementation for all overloads.\n * @param value The input value to cast to an array.\n * @returns An array containing the input value, or the input value itself if it is already an array.\n * @example\n * ```ts\n * castArray('foo'); // ['foo']\n * castArray(['foo']); // ['foo']\n * castArray(null); // []\n * castArray(undefined); // []\n * ```\n */\nexport function castArray<T>(\n  value: Maybe<\n    Many<NonNullable<T>, 'mutable'> | Many<NonNullable<T>, 'immutable'>\n  >\n) {\n  return castArrayIfDefined(value ?? []);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAoGA,SAAgB,UACd,OAGA;AACA,QAAOA,8CAAmB,SAAS,EAAE,CAAC"}