{"version":3,"file":"flatten.cjs","names":[],"sources":["../../src/array/flatten.ts"],"sourcesContent":["/**\n * Flattens an array to a specified depth\n * @param array The array to flatten\n * @param depth The depth to flatten to (default: 1)\n * @returns A new flattened array\n * @example\n * flatten([1, [2, 3], [4, [5]]]); // [1, 2, 3, 4, [5]]\n * flatten([1, [2, 3], [4, [5]]], 2); // [1, 2, 3, 4, 5]\n */\nexport function flatten<T>(array: readonly unknown[], depth: number = 1): T[] {\n  if (!Array.isArray(array)) {\n    return [];\n  }\n\n  if (depth <= 0) {\n    return array as T[];\n  }\n\n  const result: T[] = [];\n\n  for (const item of array) {\n    if (Array.isArray(item) && depth > 0) {\n      result.push(...flatten<T>(item, depth - 1));\n    } else {\n      result.push(item as T);\n    }\n  }\n\n  return result;\n}\n"],"mappings":";;;;;;;;;;;AASA,SAAgB,QAAW,OAA2B,QAAgB,GAAQ;CAC5E,IAAI,CAAC,MAAM,QAAQ,KAAK,GACtB,OAAO,CAAC;CAGV,IAAI,SAAS,GACX,OAAO;CAGT,MAAM,SAAc,CAAC;CAErB,KAAK,MAAM,QAAQ,OACjB,IAAI,MAAM,QAAQ,IAAI,KAAK,QAAQ,GACjC,OAAO,KAAK,GAAG,QAAW,MAAM,QAAQ,CAAC,CAAC;MAE1C,OAAO,KAAK,IAAS;CAIzB,OAAO;AACT"}