{"version":3,"file":"arrays.cjs","sources":["../../src/shared/arrays.ts"],"sourcesContent":["import { isEqual } from 'ohash'\n\n/**\n * The function `areEqual` compares two arrays and returns true if they are equal in length and have\n * the same elements at corresponding indexes.\n * @param {any[]} arrayA - An array of any type of elements.\n * @param {any[]} arrayB - It looks like you haven't provided the value for `arrayB`. Could you please\n * provide the arrayB value so that I can assist you further?\n * @returns The function `areEqual` is returning a boolean value, either `true` if the two input arrays\n * `arrayA` and `arrayB` are equal, or `false` if they are not equal.\n */\nexport function areEqual(arrayA: any[], arrayB: any[]): boolean {\n if (arrayA.length !== arrayB.length)\n return false\n\n for (let index = 0; index < arrayA.length; index++) {\n if (arrayA[index] !== arrayB[index])\n return false\n }\n\n return true\n}\n\n/**\n * Splits an array into chunks of a given size.\n * @param arr The array to split.\n * @param size The size of each chunk.\n * @returns An array of arrays, where each sub-array has `size` elements from the original array.\n * @example ```ts\n * const arr = [1, 2, 3, 4, 5, 6, 7, 8];\n * const chunks = chunk(arr, 3);\n * // chunks = [[1, 2, 3], [4, 5, 6], [7, 8]]\n * ```\n */\nexport function chunk(arr: T[], size: number): T[][] {\n const result = []\n for (let i = 0; i < arr.length; i += size)\n result.push(arr.slice(i, i + size))\n\n return result\n}\n\n/**\n * The function `findValuesBetween` takes an array and two values, then returns a subarray containing\n * elements between the first occurrence of the start value and the first occurrence of the end value\n * in the array.\n * @param {T[]} array - The `array` parameter is an array of values of type `T`.\n * @param {T} start - The `start` parameter is the value that marks the beginning of the range you want\n * to find in the array.\n * @param {T} end - The `end` parameter in the `findValuesBetween` function represents the end value\n * that you want to find in the array. This function will return a subarray of values that are between\n * the `start` and `end` values in the original array.\n * @returns The `findValuesBetween` function returns an array of values from the input array that are\n * between the `start` and `end` values (inclusive). If either the `start` or `end` values are not\n * found in the input array, an empty array is returned.\n */\nexport function findValuesBetween(array: T[], start: T, end: T) {\n const startIndex = array.findIndex(i => isEqual(i, start))\n const endIndex = array.findIndex(i => isEqual(i, end))\n if (startIndex === -1 || endIndex === -1)\n return []\n\n const [minIndex, maxIndex] = [startIndex, endIndex].sort((a, b) => a - b)\n\n return array.slice(minIndex, maxIndex + 1)\n}\n"],"names":["isEqual"],"mappings":";;;;AAWgB,SAAA,QAAA,CAAS,QAAe,MAAwB,EAAA;AAC9D,EAAI,IAAA,MAAA,CAAO,WAAW,MAAO,CAAA,MAAA;AAC3B,IAAO,OAAA,KAAA;AAET,EAAA,KAAA,IAAS,KAAQ,GAAA,CAAA,EAAG,KAAQ,GAAA,MAAA,CAAO,QAAQ,KAAS,EAAA,EAAA;AAClD,IAAA,IAAI,MAAO,CAAA,KAAK,CAAM,KAAA,MAAA,CAAO,KAAK,CAAA;AAChC,MAAO,OAAA,KAAA;AAAA;AAGX,EAAO,OAAA,IAAA;AACT;AAmCgB,SAAA,iBAAA,CAAqB,KAAY,EAAA,KAAA,EAAU,GAAQ,EAAA;AACjE,EAAA,MAAM,aAAa,KAAM,CAAA,SAAA,CAAU,OAAKA,aAAQ,CAAA,CAAA,EAAG,KAAK,CAAC,CAAA;AACzD,EAAA,MAAM,WAAW,KAAM,CAAA,SAAA,CAAU,OAAKA,aAAQ,CAAA,CAAA,EAAG,GAAG,CAAC,CAAA;AACrD,EAAI,IAAA,UAAA,KAAe,MAAM,QAAa,KAAA,EAAA;AACpC,IAAA,OAAO,EAAC;AAEV,EAAA,MAAM,CAAC,QAAA,EAAU,QAAQ,CAAA,GAAI,CAAC,UAAA,EAAY,QAAQ,CAAA,CAAE,IAAK,CAAA,CAAC,CAAG,EAAA,CAAA,KAAM,IAAI,CAAC,CAAA;AAExE,EAAA,OAAO,KAAM,CAAA,KAAA,CAAM,QAAU,EAAA,QAAA,GAAW,CAAC,CAAA;AAC3C;;;;;"}