@bemoje/array 0.0.10 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -34
- package/package.json +10 -10
- package/{dist/types → src}/index.d.ts +0 -1
- package/src/index.js +33 -0
- package/src/index.js.map +1 -0
- package/{dist/types → src}/lib/arrAverage.d.ts +0 -1
- package/src/lib/arrAverage.js +22 -0
- package/src/lib/arrAverage.js.map +1 -0
- package/{dist/types → src}/lib/arrEachToString.d.ts +0 -1
- package/src/lib/arrEachToString.js +19 -0
- package/src/lib/arrEachToString.js.map +1 -0
- package/{dist/types → src}/lib/arrEvery.d.ts +0 -1
- package/src/lib/arrEvery.js +28 -0
- package/src/lib/arrEvery.js.map +1 -0
- package/{dist/types → src}/lib/arrFindIndicesOf.d.ts +0 -1
- package/src/lib/arrFindIndicesOf.js +20 -0
- package/src/lib/arrFindIndicesOf.js.map +1 -0
- package/{dist/types → src}/lib/arrFindLast.d.ts +0 -1
- package/src/lib/arrFindLast.js +22 -0
- package/src/lib/arrFindLast.js.map +1 -0
- package/{dist/types → src}/lib/arrFindLastIndexOf.d.ts +0 -1
- package/src/lib/arrFindLastIndexOf.js +25 -0
- package/src/lib/arrFindLastIndexOf.js.map +1 -0
- package/{dist/types → src}/lib/arrFlatten.d.ts +0 -1
- package/src/lib/arrFlatten.js +34 -0
- package/src/lib/arrFlatten.js.map +1 -0
- package/{dist/types → src}/lib/arrIndicesOf.d.ts +0 -1
- package/src/lib/arrIndicesOf.js +27 -0
- package/src/lib/arrIndicesOf.js.map +1 -0
- package/{dist/types → src}/lib/arrLast.d.ts +0 -1
- package/src/lib/arrLast.js +21 -0
- package/src/lib/arrLast.js.map +1 -0
- package/{dist/types → src}/lib/arrMapMutable.d.ts +0 -1
- package/src/lib/arrMapMutable.js +22 -0
- package/src/lib/arrMapMutable.js.map +1 -0
- package/{dist/types → src}/lib/arrObjectsToTable.d.ts +0 -1
- package/src/lib/arrObjectsToTable.js +37 -0
- package/src/lib/arrObjectsToTable.js.map +1 -0
- package/{dist/types → src}/lib/arrObjectsUniqueKeys.d.ts +0 -1
- package/src/lib/arrObjectsUniqueKeys.js +29 -0
- package/src/lib/arrObjectsUniqueKeys.js.map +1 -0
- package/{dist/types → src}/lib/arrRemoveDuplicates.d.ts +0 -1
- package/src/lib/arrRemoveDuplicates.js +20 -0
- package/src/lib/arrRemoveDuplicates.js.map +1 -0
- package/{dist/types → src}/lib/arrShallowEquals.d.ts +0 -1
- package/src/lib/arrShallowEquals.js +25 -0
- package/src/lib/arrShallowEquals.js.map +1 -0
- package/{dist/types → src}/lib/arrShuffle.d.ts +0 -1
- package/src/lib/arrShuffle.js +34 -0
- package/src/lib/arrShuffle.js.map +1 -0
- package/{dist/types → src}/lib/arrSome.d.ts +0 -1
- package/src/lib/arrSome.js +26 -0
- package/src/lib/arrSome.js.map +1 -0
- package/{dist/types → src}/lib/arrSortNumeric.d.ts +0 -1
- package/src/lib/arrSortNumeric.js +22 -0
- package/src/lib/arrSortNumeric.js.map +1 -0
- package/{dist/types → src}/lib/arrSortedInsertionIndex.d.ts +0 -1
- package/src/lib/arrSortedInsertionIndex.js +36 -0
- package/src/lib/arrSortedInsertionIndex.js.map +1 -0
- package/{dist/types → src}/lib/arrSplit.d.ts +0 -1
- package/src/lib/arrSplit.js +19 -0
- package/src/lib/arrSplit.js.map +1 -0
- package/{dist/types → src}/lib/arrSum.d.ts +0 -1
- package/src/lib/arrSum.js +18 -0
- package/src/lib/arrSum.js.map +1 -0
- package/{dist/types → src}/lib/arrSwap.d.ts +0 -1
- package/src/lib/arrSwap.js +24 -0
- package/src/lib/arrSwap.js.map +1 -0
- package/{dist/types → src}/lib/arrTableAssertRowsSameLength.d.ts +0 -1
- package/src/lib/arrTableAssertRowsSameLength.js +37 -0
- package/src/lib/arrTableAssertRowsSameLength.js.map +1 -0
- package/{dist/types → src}/lib/arrTableEachToString.d.ts +0 -1
- package/src/lib/arrTableEachToString.js +20 -0
- package/src/lib/arrTableEachToString.js.map +1 -0
- package/{dist/types → src}/lib/arrTableToCsv.d.ts +0 -1
- package/src/lib/arrTableToCsv.js +34 -0
- package/src/lib/arrTableToCsv.js.map +1 -0
- package/{dist/types → src}/lib/arrTableToObjects.d.ts +0 -1
- package/src/lib/arrTableToObjects.js +51 -0
- package/src/lib/arrTableToObjects.js.map +1 -0
- package/{dist/types → src}/lib/types/ArrayPredicate.d.ts +0 -1
- package/src/lib/types/ArrayPredicate.js +3 -0
- package/src/lib/types/ArrayPredicate.js.map +1 -0
- package/{dist/types → src}/lib/types/ArrayValueCallback.d.ts +0 -1
- package/src/lib/types/ArrayValueCallback.js +3 -0
- package/src/lib/types/ArrayValueCallback.js.map +1 -0
- package/{dist/types → src}/lib/types/ArrayVoidCallback.d.ts +0 -1
- package/src/lib/types/ArrayVoidCallback.js +3 -0
- package/src/lib/types/ArrayVoidCallback.js.map +1 -0
- package/{dist/types → src}/lib/types/NestedArray.d.ts +0 -1
- package/src/lib/types/NestedArray.js +3 -0
- package/src/lib/types/NestedArray.js.map +1 -0
- package/LICENSE +0 -21
- package/dist/index.cjs.js +0 -6
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.esm.js +0 -6
- package/dist/index.esm.js.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/lib/arrAverage.d.ts.map +0 -1
- package/dist/types/lib/arrEachToString.d.ts.map +0 -1
- package/dist/types/lib/arrEvery.d.ts.map +0 -1
- package/dist/types/lib/arrFindIndicesOf.d.ts.map +0 -1
- package/dist/types/lib/arrFindLast.d.ts.map +0 -1
- package/dist/types/lib/arrFindLastIndexOf.d.ts.map +0 -1
- package/dist/types/lib/arrFlatten.d.ts.map +0 -1
- package/dist/types/lib/arrIndicesOf.d.ts.map +0 -1
- package/dist/types/lib/arrLast.d.ts.map +0 -1
- package/dist/types/lib/arrMapMutable.d.ts.map +0 -1
- package/dist/types/lib/arrObjectsToTable.d.ts.map +0 -1
- package/dist/types/lib/arrObjectsUniqueKeys.d.ts.map +0 -1
- package/dist/types/lib/arrRemoveDuplicates.d.ts.map +0 -1
- package/dist/types/lib/arrShallowEquals.d.ts.map +0 -1
- package/dist/types/lib/arrShuffle.d.ts.map +0 -1
- package/dist/types/lib/arrSome.d.ts.map +0 -1
- package/dist/types/lib/arrSortNumeric.d.ts.map +0 -1
- package/dist/types/lib/arrSortedInsertionIndex.d.ts.map +0 -1
- package/dist/types/lib/arrSplit.d.ts.map +0 -1
- package/dist/types/lib/arrSum.d.ts.map +0 -1
- package/dist/types/lib/arrSwap.d.ts.map +0 -1
- package/dist/types/lib/arrTableAssertRowsSameLength.d.ts.map +0 -1
- package/dist/types/lib/arrTableEachToString.d.ts.map +0 -1
- package/dist/types/lib/arrTableToCsv.d.ts.map +0 -1
- package/dist/types/lib/arrTableToObjects.d.ts.map +0 -1
- package/dist/types/lib/types/ArrayPredicate.d.ts.map +0 -1
- package/dist/types/lib/types/ArrayValueCallback.d.ts.map +0 -1
- package/dist/types/lib/types/ArrayVoidCallback.d.ts.map +0 -1
- package/dist/types/lib/types/NestedArray.d.ts.map +0 -1
- package/jest.config.ts +0 -13
- package/project.json +0 -30
- package/tsconfig.spec.json +0 -9
package/dist/index.cjs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/lib/arrSum.ts","../src/lib/arrAverage.ts","../src/lib/arrEachToString.ts","../src/lib/arrEvery.ts","../src/lib/arrFindIndicesOf.ts","../src/lib/arrFindLast.ts","../src/lib/arrFindLastIndexOf.ts","../src/lib/arrFlatten.ts","../src/lib/arrIndicesOf.ts","../src/lib/arrLast.ts","../src/lib/arrMapMutable.ts","../src/lib/arrObjectsUniqueKeys.ts","../src/lib/arrObjectsToTable.ts","../src/lib/arrRemoveDuplicates.ts","../src/lib/arrShallowEquals.ts","../src/lib/arrSwap.ts","../src/lib/arrShuffle.ts","../src/lib/arrSome.ts","../src/lib/arrSortedInsertionIndex.ts","../src/lib/arrSortNumeric.ts","../src/lib/arrSplit.ts","../src/lib/arrTableAssertRowsSameLength.ts","../src/lib/arrTableEachToString.ts","../src/lib/arrTableToCsv.ts","../src/lib/arrTableToObjects.ts"],"sourcesContent":["/**\n * Calculates the sum of an array of numbers.\n * @returns The sum of all numbers in the array.\n * @param array The array of numbers to sum.\n * @example ```ts\n * const numbers = [1, 2, 3, 4, 5];\n * arrSum(numbers);\n * //=> 15\n * ```\n */\nexport function arrSum(array: number[]): number {\n return array.reduce((acc, cur) => acc + cur, 0)\n}\n","import { arrSum } from './arrSum'\n\n/**\n * Calculates the average of an array of numbers.\n * @returns The average of all numbers in the array.\n * @throws an error if the input array is empty.\n * @param array The array of numbers.\n * @example ```ts\n * const numbers = [1, 2, 3, 4, 5];\n * arrAverage(numbers);\n * //=> 3\n * ```\n */\nexport function arrAverage(array: number[]): number {\n if (!array.length) throw new Error('Cannot take an average of zero values.')\n return arrSum(array) / array.length\n}\n","/**\n * Coerce each element of an array to string.\n * @template T - The type of elements in the input array.\n * @returns A new array where each element is the string representation of the corresponding element in the input array.\n * @param array The array to iterate over.\n * @example ```ts\n * const numbers = [1, 2, 3];\n * arrEachToString(numbers);\n * //=> ['1', '2', '3']\n * ```\n */\nexport function arrEachToString<T>(array: T[]): string[] {\n return array.map((element) => '' + element)\n}\n","import type { ArrayPredicate } from './types/ArrayPredicate'\n\n/**\n * Returns true if the predicate is satisfied for every element of the passed array; otherwise false.\n * @param input The array\n * @template T - The type of elements in the array.\n * @returns Returns `true` if all elements pass the predicate check, else `false`.\n * @param predicate A predicate callback function\n * @example ```ts\n * const numbers = [1, 2, 3, 4, 5];\n * const isEven = (num) => num % 2 === 0;\n * arrEvery(numbers, isEven);\n * //=> false\n * arrEvery(numbers, (num) => num > 0);\n * //=> true\n * ```\n */\nexport function arrEvery<T>(input: Array<T>, predicate: ArrayPredicate<T>): boolean {\n for (let i = 0, len = input.length; i < len; i++) {\n if (predicate(input[i], i, input) === false) {\n return false\n }\n }\n return true\n}\n","/**\n * Returns an array of indices where the predicate function returns true for the corresponding element in the input array.\n * @param input - The array to search.\n * @param predicate - The function to test each element of the array.\n * @returns An array of indices where the predicate function returns true.\n */\nexport function arrFindIndicesOf<T>(input: Array<T>, predicate: (value: T) => boolean): number[] {\n const result: number[] = []\n for (let i = 0; i < input.length; i++) {\n if (predicate(input[i])) {\n result.push(i)\n }\n }\n return result\n}\n","/**\n * Searches for the last element in an array that satisfies a provided testing function.\n * @typeParam T - The type of elements in the input array.\n * @param input - The array to search within.\n * @param predicate - The function to test each element for a condition.\n * @returns The last element in the array that satisfies the provided testing function. Otherwise, undefined if no elements satisfy the testing function.\n * @example const numbers = [1, 2, 3, 4, 5, 6];\n * arrFindLast(numbers, num => num % 2 === 0);\n * //=> 6\n */\nexport function arrFindLast<T>(input: Array<T>, predicate: (value: T) => boolean): T | undefined {\n for (let i = input.length - 1; i >= 0; i--) {\n if (predicate(input[i]) === true) {\n return input[i]\n }\n }\n}\n","/**\n * Searches for an element in an array in reverse order and returns the index of the last occurrence of the element for which the provided testing function returns true.\n * If no such element is found, it returns -1.\n * @param input - The array to search in.\n * @param predicate - The testing function. Takes a value and returns a boolean.\n * @returns The index of the last occurrence of the element in the array that passes the test. If no such element is found, it returns -1.\n * @example ```ts\n * const arr = [1, 2, 3, 4, 5, 4, 3];\n * arrFindLastIndexOf(arr, (value) => value === 4);\n * //=> 5\n * ```\n */\nexport function arrFindLastIndexOf<T>(input: Array<T>, predicate: (value: T) => boolean): number {\n for (let i = input.length - 1; i >= 0; i--) {\n if (predicate(input[i])) {\n return i\n }\n }\n return -1\n}\n","import type { NestedArray } from './types/NestedArray'\n\n/**\n * Flattens the passed array recursively to a specified depth. Immutable.\n * @param input the array to flatten\n * @template T - The type of the elements in the input array.\n * @param - The maximum depth to flatten. Defaults to the maximum safe integer.\n * @returns The flattened array.\n * @throws If the input is not an array.\n * @param maxDepth the maximum recursive flattening depth.\n * @example ```ts\n * const nestedArray = [[1, 2], [3, [4, 5]], [6]];\n * arrFlatten(nestedArray, 1);\n * //=> [1, 2, 3, [4, 5], 6]\n * ```\n */\nexport function arrFlatten<T>(input: NestedArray<T>, maxDepth = Number.MAX_SAFE_INTEGER): Array<T> {\n const accum: T[] = []\n function recurse(arr: NestedArray<T>, depth: number) {\n for (let i = 0; i < arr.length; i++) {\n if (Array.isArray(arr[i]) && depth < maxDepth) {\n recurse(arr[i] as T[], depth + 1)\n } else {\n accum.push(arr[i] as T)\n }\n }\n }\n recurse(input, 0)\n return accum\n}\n","/**\n * Returns all indexes at which an element is found.\n * @param input The array to search\n * @template T - The type of elements in the input array.\n * @returns An array of indices where the specified element can be found.\n * @param element The element to find\n * @example ```ts\n * const inputArray = [1, 2, 3, 2, 4, 2, 5];\n * const elementToFind = 2;\n * arrIndicesOf(inputArray, elementToFind);\n * //=> [1, 3, 5]\n * ```\n */\nexport function arrIndicesOf<T>(input: Array<T>, element: T): number[] {\n const result: number[] = []\n for (let i = 0; i < input.length; i++) {\n if (element === input[i]) {\n result.push(i)\n }\n }\n return result\n}\n","/**\n * Returns the last element of an array.\n * Throws an error if the array is empty.\n * @template T The type of elements in the array.\n * @param array The array to get the last element from.\n * @returns The last element of the array.\n * @throws If the array is empty.\n * @example const numbers = [1, 2, 3, 4, 5];\n * const lastNumber = arrLast(numbers);\n * //=> 5\n */\nexport function arrLast<T>(array: T[]): T {\n if (!array.length) throw new Error('Cannot get last element of empty array.')\n return array[array.length - 1]\n}\n","import type { ArrayValueCallback } from './types/ArrayValueCallback'\n\n/**\n * This function takes an array and a callback function as arguments. It applies the callback function to each element of the array, mutating the original array in the process.\n * @template T The type of elements in the input array.\n * @param input The array to be mapped over.\n * @param f The callback function to be applied to each element of the array. This function takes three arguments: the current element, its index, and the original array.\n * @returns The original array, mutated by the callback function.\n * @example ```ts\n * arrMapMutable([1, 2, 3], (value: number) => value * 2);;\n * //=> [2, 4, 6]\n * ```\n */\nexport function arrMapMutable<T>(input: Array<T>, f: ArrayValueCallback<T>): Array<T> {\n for (let i = 0; i < input.length; i++) {\n input[i] = f(input[i], i, input)\n }\n return input\n}\n","/**\n * Returns an array of all unique object keys found in an array of objects.\n * @template T - The type of values in the input objects.\n * @returns An array of unique keys present in the input objects.\n * @param objects The array of objects.\n * @example ```ts\n * const objects = [\n * { name: 'John', age: 25 },\n * { name: 'Jane', gender: 'female' },\n * { name: 'Bob', age: 30, gender: 'male' },\n * ];\n * arrObjectsUniqueKeys(objects);\n * //=> ['name', 'age', 'gender']\n * ```\n */\nexport function arrObjectsUniqueKeys<T>(objects: Record<string, T>[]): string[] {\n const keys = new Set<string>()\n for (const o of objects) {\n for (const key of Object.keys(o)) {\n keys.add(key)\n }\n }\n return Array.from(keys)\n}\n","import { arrObjectsUniqueKeys } from './arrObjectsUniqueKeys'\n\n/**\n * Convert an array of objects to a two-dimensional table.\n * @param objects The array of objects to convert to a table.\n * @template T - The type of the values in the objects.\n * @param options.headers An optional array of strings specifying the headers (property names) to use. If not provided, the function will use all unique keys found in the objects.\n * @param options.emptyCell An optional value to use for empty cells. If not provided, the function will use `undefined`.\n * @returns A 2D array (table) where each row represents an object and each column represents a property of the object.\n * @param options The options for converting the objects to a table.\n * @example ```ts\n * arrObjectsToTable(\n * [\n * { a: 1, b: 2 },\n * { a: 3, b: 4, c: 5 },\n * ],\n * { emptyCell:1 },\n * ) //=> [ [ 'a', 'b', 'c' ], [ 1, 2,1 ], [ 3, 4, 5 ] ]\n * ```\n */\nexport function arrObjectsToTable<T, E>(\n objects: Record<string, T | undefined>[],\n options: {\n headers?: string[]\n emptyCell?: E\n } = {},\n): Array<Array<string | T | E>> {\n const headers = options?.headers?.slice() || arrObjectsUniqueKeys(objects)\n const table: Array<Array<string | T | E>> = [headers]\n for (const o of objects) {\n const row = headers.map((header) => {\n const value = o[header]\n return value !== undefined ? value : (options.emptyCell as E)\n })\n table.push(row)\n }\n return table\n}\n","/**\n * Remove duplicates from an array\n * @remarks This function uses the JavaScript Set object to remove duplicate values from an array.\n * @typeparam T - The type of elements in the array.\n * @returns The new array with duplicates removed.\n * @param array The array from which to remove duplicates.\n * @example ```ts\n * const array = [1, 2, 2, 3, 4, 4, 5];\n * arrRemoveDuplicates(array);\n * //=> [1, 2, 3, 4, 5]\n * ```\n */\nexport function arrRemoveDuplicates<T>(array: T[]): T[] {\n return Array.from(new Set(array))\n}\n","import { arrEvery } from './arrEvery'\n\n/**\n * This function compares the length of the two arrays and then checks if each element at the corresponding index is equal.\n * @param input1 The first array to compare.\n * @template T - The type of the elements in the arrays.\n * @returns A boolean indicating whether the two arrays are shallowly equal.\n * @param input2 The second array to compare.\n * Checks if two arrays are shallowly equal.\n * @example ```ts\n * arrShallowEquals([1, 2, 3], [1, 2, 3]);\n * //=> true\n * arrShallowEquals([1, 2, 3], [1, 2, 4]);\n * //=> false\n * ```\n */\nexport function arrShallowEquals<T>(input1: T[], input2: T[]): boolean {\n if (input1.length !== input2.length) return false\n return arrEvery(input1, (value: T, i: number) => value === input2[i])\n}\n","/**\n * Swaps two elements in an array. This function takes an input array and swaps the elements at the specified indices.\n * @param to The index of the element to swap to.\n * @param from The index of the element to swap from.\n * @template T - The type of elements in the array.\n * @returns The modified array with swapped elements.\n * @throws Will throw an error if 'from' or 'to' is not a valid index in the array.\n * @param input The input array.\n * @example ```ts\n * const arr = [1, 2, 3, 4, 5]\n * arrSwap(arr, 1, 3) //=> [1, 4, 3, 2, 5]\n * ```\n */\nexport function arrSwap<T>(input: Array<T>, from: number, to: number): Array<T> {\n if (from === to) return input\n ;[input[from], input[to]] = [input[to], input[from]]\n return input\n}\n","import { randomIntBetween } from '@bemoje/number'\nimport { arrShallowEquals } from './arrShallowEquals'\nimport { arrSwap } from './arrSwap'\n\n/**\n * Shuffle items in an array in-place. Guarantees changes.\n * @remarks This function does not guarantee that the order of the elements will be different after shuffling.\n * @typeparam T - The type of the elements in the input array.\n * @returns The same array, but shuffled.\n * @param input The array to shuffle.\n * @example ```ts\n * const input = [1, 2, 3, 4, 5];\n * arrShuffle(input);\n * //=> [3, 1, 5, 2, 4]\n * ```\n */\nexport function arrShuffle<T>(input: Array<T>): Array<T> {\n if (input.length <= 1) return input\n const original = input.slice()\n let equal = true\n while (equal) {\n for (let i = 0; i < input.length; i++) {\n const newIndex = randomIntBetween(0, input.length - 1)\n arrSwap(input, i, newIndex)\n }\n equal = arrShallowEquals(input, original)\n }\n return input\n}\n","import type { ArrayPredicate } from './types/ArrayPredicate'\n\n/**\n * Checks if at least one element in the array satisfies the provided predicate.\n * @param predicate The predicate function to apply to each element.\n * @template T The type of elements in the input array.\n * @returns Returns `true` if at least one element in the array passes the test implemented by the provided function, otherwise `false`.\n * @param input The array to check.\n * @example ```ts\n * const numbers = [1, 2, 3, 4, 5];\n * const isEven = (num) => num % 2 === 0;\n * arrSome(numbers, isEven);\n * //=> true\n * ```\n */\nexport function arrSome<T>(input: Array<T>, predicate: ArrayPredicate<T>): boolean {\n for (let i = 0, len = input.length; i < len; i++) {\n if (predicate(input[i], i, input) === true) {\n return true\n }\n }\n return false\n}\n","/**\n * Returns an index in the sorted array where the specified value could be inserted while maintaining the sorted order of the array.\n * If the element is already in the array, returns the index after the last instance of the element.\n * @param array - The sorted array to search.\n * @param value - The value to locate in the array.\n * @param comparator - A function that defines the sort order. If omitted, the array elements are converted to strings, then sorted according to each character's Unicode code point value.\n * @returns The index at which the value could be inserted into array to maintain the array's sorted order.\n * @example ```ts\n * const array = [1, 2, 3, 5, 6];\n * const value = 4;\n * const comparator = (a, b) => a - b;\n * const index = arrSortedLowerBound(array, value, comparator);\n * console.log(index); // Output: 3\n * ```\n */\nexport function arrSortedInsertionIndex<T>(array: readonly T[], value: T, comparator: (a: T, b: T) => number): number {\n let first = 0\n let count = array.length\n while (count > 0) {\n const step = Math.trunc(count / 2)\n let it = first + step\n if (comparator(array[it]!, value) <= 0) {\n first = ++it\n count -= step + 1\n } else {\n count = step\n }\n }\n return first\n}\n","import { compareNumeric } from '@bemoje/sort'\n\n/**\n * Sorts an array of numbers, bigints, or booleans in ascending order.\n * @returns The sorted array.\n * @remarks This function uses the JavaScript `Array.prototype.sort()` method, which sorts elements in place.\n * Therefore, the original array will be modified.\n * @throws If any element in the input array is not a number, bigint, or boolean.\n * @param input The array to be sorted.\n * @example ```ts\n * const input = [5, 2n, true, 10, false];\n * arrSortNumeric(input);\n * //=> [false, true, 2n, 5, 10]\n * ```\n */\nexport function arrSortNumeric(input: Array<number | bigint | boolean>): Array<number | bigint | boolean> {\n return input.sort(compareNumeric)\n}\n","import { assertion, isPositiveInteger } from '@bemoje/validation'\r\n\r\nexport function arrSplit<T>(array: T[], n: number): T[][] {\r\n assertion(n, isPositiveInteger)\r\n const result: T[][] = []\r\n if (array.length === 0) return result\r\n if (n === 1) return [array]\r\n const chunkSize = Math.ceil(array.length / n)\r\n for (let i = 0; i < array.length; i += chunkSize) {\r\n result.push(array.slice(i, i + chunkSize))\r\n }\r\n return result\r\n}\r\n","/**\n * Asserts that all rows in a 2D array have the same length.\n * @param - Optional array of headers to compare the row length against.\n * @throws If any row in the array has a different length than the others.\n * @param headers Optional. An array of headers. If provided, each row must have the same length as this array.\n * @typeparam T - The type of elements in the rows.\n * @param rows The 2D array to check.\n * @example ```ts\n * const rows = [\n * [1, 2, 3],\n * [4, 5, 6],\n * [7, 8, 9],\n * ];\n * arrTableAssertRowsSameLength(rows);\n * //=> undefined\n * const rowsWithDifferentLength = [\n * [1, 2, 3],\n * [4, 5],\n * [7, 8, 9],\n * ];\n * arrTableAssertRowsSameLength(rowsWithDifferentLength);\n * //=> Error: Expected 3 columns, got 2\n * ```\n */\nexport function arrTableAssertRowsSameLength<T>(rows: T[][], headers?: string[]): void {\n const numHeaders = (headers || rows[0]).length\n for (const row of rows) {\n if (row.length !== numHeaders) {\n throw new Error(`Expected ${numHeaders} columns, got ${row.length}`)\n }\n }\n}\n","import { arrEachToString } from './arrEachToString'\n\n/**\n * Coerce each value of a 2D array table to string.\n * @template T - The type of the elements in the input array.\n * @returns The converted 2D array where each element is a string.\n * @param table The 2D array to convert.\n * @example ```ts\n * const input: number[][] = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];\n * arrTableEachToString(input);\n * //=> [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]\n * ```\n */\nexport function arrTableEachToString<T>(table: T[][]): string[][] {\n return table.map(arrEachToString)\n}\n","import { strReplaceAll } from '@bemoje/string'\r\n\r\n/**\r\n * Converts a 2D array to a CSV string.\r\n * @param input The input 2D array.\r\n * @remarks This function is useful for exporting data to CSV format.\r\n * @param replaceLinebreakWith The character used to replace line breaks in the CSV string. Defaults to '|'.\r\n * @typeparam T - The type of the elements in the input array.\r\n * @returns The CSV string representation of the input array.\r\n * @param delimiter The delimiter to use for separating values in the CSV string.\r\n * @example ```ts\r\n * const input = [\r\n * ['Name', 'Age', 'Country'],\r\n * ['John', '25', 'USA'],\r\n * ['Alice', '30', 'Canada'],\r\n * ['Bob', '35', 'UK'],\r\n * ];\r\n * arrTableToCsv(input);\r\n * //=> \"Name;Age;Country\\nJohn;25;USA\\nAlice;30;Canada\\nBob;35;UK\"\r\n * ```\r\n */\r\nexport function arrTableToCsv<T>(input: T[][], delimiter = ';', replaceLinebreakWith = '|'): string {\r\n return input\r\n .map((row) => {\r\n return row\r\n .map((item) => strReplaceAll(item + '', delimiter, '').replace(/\\r*\\n/g, replaceLinebreakWith))\r\n .join(delimiter)\r\n })\r\n .join('\\n')\r\n}\r\n","/**\n * Converts a 2D array representing a table into an array of objects.\n * @param rows The 2D array representing the table.\n * @template T - The type of the elements in the rows.\n * @param headers The headers to use as keys for the objects. If not provided, the first row of the table is used as headers.\n * @returns An array of objects, where each object represents a row in the table.\n * @throws Throws an error if the headers are not provided and the table is empty or only contains one row.\n * @param headers Optional array of headers for the table.\n * @example ```ts\n * const table = [\n * ['Name', 'Age', 'Country'],\n * ['John', 25, 'USA'],\n * ['Jane', 30, 'Canada'],\n * ];\n * const headers = ['Name', 'Age', 'Country'];\n * arrTableToObjects(table, headers) //=> [\n * // { Name: 'John', Age: 25, Country: 'USA' },\n * // { Name: 'Jane', Age: 30, Country: 'Canada' },\n * // ]\n * ```\n */\nexport function arrTableToObjects<T>(rows: T[][], headers?: string[], ignoreKeys?: Set<string>): Record<string, T>[] {\n if (headers) {\n if (!rows.length) return []\n } else {\n if (rows.length <= 1) return []\n headers = rows[0].map((header) => {\n return header === null || header === undefined ? '' : String(header)\n })\n rows = rows.slice(1)\n }\n const _headers = headers\n return rows.map((row: T[]) => {\n const o: Record<string, T> = {}\n for (let i = 0; i < _headers.length; i++) {\n const header = _headers[i]\n if (ignoreKeys && ignoreKeys.has(header)) continue\n o[header] = row[i]\n }\n return o\n })\n}\n"],"names":["arrSum","array","reduce","acc","cur","arrAverage","length","Error","arrEachToString","map","element","arrEvery","input","predicate","i","len","arrFindIndicesOf","result","push","arrFindLast","arrFindLastIndexOf","arrFlatten","maxDepth","Number","MAX_SAFE_INTEGER","recurse","arr","depth","Array","isArray","accum","arrIndicesOf","arrLast","arrMapMutable","f","arrObjectsUniqueKeys","objects","keys","Set","o","key","Object","add","from","arrObjectsToTable","options","headers","_a","slice","table","row","header","value","emptyCell","arrRemoveDuplicates","arrShallowEquals","input1","input2","arrSwap","to","arrShuffle","original","equal","newIndex","randomIntBetween","arrSome","arrSortedInsertionIndex","comparator","first","count","step","Math","trunc","it","arrSortNumeric","sort","compareNumeric","arrSplit","n","assertion","isPositiveInteger","chunkSize","ceil","arrTableAssertRowsSameLength","rows","numHeaders","arrTableEachToString","arrTableToCsv","delimiter","replaceLinebreakWith","item","strReplaceAll","replace","join","arrTableToObjects","ignoreKeys","_headers","has"],"mappings":";;;;4JAUM,QAAU,CAAAA,MAAMA,CAACC,KAAe,CAAA,CACpC,MAAO,CAAAA,KAAK,CAACC,MAAM,CAAC,CAACC,GAAG,CAAEC,GAAG,GAAKD,GAAG,CAAGC,GAAG,CAAE,CAAC,CAChD,CCCM,QAAU,CAAAC,UAAUA,CAACJ,KAAe,CAAA,CACxC,GAAI,CAACA,KAAK,CAACK,MAAM,CAAE,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 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* @bemoje/array v0.0.9
|
|
3
|
-
* (c) Benjamin Møller Jensen
|
|
4
|
-
* Released under the MIT License.
|
|
5
|
-
*/import{randomIntBetween}from"@bemoje/number";import{compareNumeric}from"@bemoje/sort";import{assertion,isPositiveInteger}from"@bemoje/validation";import{strReplaceAll}from"@bemoje/string";function arrSum(array){return array.reduce((acc,cur)=>acc+cur,0)}function arrAverage(array){if(!array.length)throw new Error("Cannot take an average of zero values.");return arrSum(array)/array.length}function arrEachToString(array){return array.map(element=>""+element)}function arrEvery(input,predicate){for(let i=0,len=input.length;i<len;i++)if(!1===predicate(input[i],i,input))return!1;return!0}function arrFindIndicesOf(input,predicate){const result=[];for(let i=0;i<input.length;i++)predicate(input[i])&&result.push(i);return result}function arrFindLast(input,predicate){for(let i=input.length-1;0<=i;i--)if(!0===predicate(input[i]))return input[i]}function arrFindLastIndexOf(input,predicate){for(let i=input.length-1;0<=i;i--)if(predicate(input[i]))return i;return-1}function arrFlatten(input,maxDepth=Number.MAX_SAFE_INTEGER){function recurse(arr,depth){for(let i=0;i<arr.length;i++)Array.isArray(arr[i])&&depth<maxDepth?recurse(arr[i],depth+1):accum.push(arr[i])}const accum=[];return recurse(input,0),accum}function arrIndicesOf(input,element){const result=[];for(let i=0;i<input.length;i++)element===input[i]&&result.push(i);return result}function arrLast(array){if(!array.length)throw new Error("Cannot get last element of empty array.");return array[array.length-1]}function arrMapMutable(input,f){for(let i=0;i<input.length;i++)input[i]=f(input[i],i,input);return input}function arrObjectsUniqueKeys(objects){const keys=new Set;for(const o of objects)for(const key of Object.keys(o))keys.add(key);return Array.from(keys)}function arrObjectsToTable(objects,options={}){var _a;const headers=(null===(_a=null===options||void 0===options?void 0:options.headers)||void 0===_a?void 0:_a.slice())||arrObjectsUniqueKeys(objects),table=[headers];for(const o of objects){const row=headers.map(header=>{const value=o[header];return value===void 0?options.emptyCell:value});table.push(row)}return table}function arrRemoveDuplicates(array){return Array.from(new Set(array))}function arrShallowEquals(input1,input2){return!(input1.length!==input2.length)&&arrEvery(input1,(value,i)=>value===input2[i])}function arrSwap(input,from,to){return from===to?input:([input[from],input[to]]=[input[to],input[from]],input)}function arrShuffle(input){if(1>=input.length)return input;const original=input.slice();for(let equal=!0;equal;){for(let i=0;i<input.length;i++){const newIndex=randomIntBetween(0,input.length-1);arrSwap(input,i,newIndex)}equal=arrShallowEquals(input,original)}return input}function arrSome(input,predicate){for(let i=0,len=input.length;i<len;i++)if(!0===predicate(input[i],i,input))return!0;return!1}function arrSortedInsertionIndex(array,value,comparator){let first=0,count=array.length;for(;0<count;){const step=Math.trunc(count/2);let it=first+step;0>=comparator(array[it],value)?(first=++it,count-=step+1):count=step}return first}function arrSortNumeric(input){return input.sort(compareNumeric)}function arrSplit(array,n){assertion(n,isPositiveInteger);const result=[];if(0===array.length)return result;if(1===n)return[array];const chunkSize=Math.ceil(array.length/n);for(let i=0;i<array.length;i+=chunkSize)result.push(array.slice(i,i+chunkSize));return result}function arrTableAssertRowsSameLength(rows,headers){const numHeaders=(headers||rows[0]).length;for(const row of rows)if(row.length!==numHeaders)throw new Error(`Expected ${numHeaders} columns, got ${row.length}`)}function arrTableEachToString(table){return table.map(arrEachToString)}function arrTableToCsv(input,delimiter=";",replaceLinebreakWith="|"){return input.map(row=>row.map(item=>strReplaceAll(item+"",delimiter,"").replace(/\r*\n/g,replaceLinebreakWith)).join(delimiter)).join("\n")}function arrTableToObjects(rows,headers,ignoreKeys){if(!headers){if(1>=rows.length)return[];headers=rows[0].map(header=>null===header||void 0===header?"":header+""),rows=rows.slice(1)}else if(!rows.length)return[];const _headers=headers;return rows.map(row=>{const o={};for(let i=0;i<_headers.length;i++){const header=_headers[i];ignoreKeys&&ignoreKeys.has(header)||(o[header]=row[i])}return o})}export{arrAverage,arrEachToString,arrEvery,arrFindIndicesOf,arrFindLast,arrFindLastIndexOf,arrFlatten,arrIndicesOf,arrLast,arrMapMutable,arrObjectsToTable,arrObjectsUniqueKeys,arrRemoveDuplicates,arrShallowEquals,arrShuffle,arrSome,arrSortNumeric,arrSortedInsertionIndex,arrSplit,arrSum,arrSwap,arrTableAssertRowsSameLength,arrTableEachToString,arrTableToCsv,arrTableToObjects};
|
|
6
|
-
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/lib/arrSum.ts","../src/lib/arrAverage.ts","../src/lib/arrEachToString.ts","../src/lib/arrEvery.ts","../src/lib/arrFindIndicesOf.ts","../src/lib/arrFindLast.ts","../src/lib/arrFindLastIndexOf.ts","../src/lib/arrFlatten.ts","../src/lib/arrIndicesOf.ts","../src/lib/arrLast.ts","../src/lib/arrMapMutable.ts","../src/lib/arrObjectsUniqueKeys.ts","../src/lib/arrObjectsToTable.ts","../src/lib/arrRemoveDuplicates.ts","../src/lib/arrShallowEquals.ts","../src/lib/arrSwap.ts","../src/lib/arrShuffle.ts","../src/lib/arrSome.ts","../src/lib/arrSortedInsertionIndex.ts","../src/lib/arrSortNumeric.ts","../src/lib/arrSplit.ts","../src/lib/arrTableAssertRowsSameLength.ts","../src/lib/arrTableEachToString.ts","../src/lib/arrTableToCsv.ts","../src/lib/arrTableToObjects.ts"],"sourcesContent":["/**\n * Calculates the sum of an array of numbers.\n * @returns The sum of all numbers in the array.\n * @param array The array of numbers to sum.\n * @example ```ts\n * const numbers = [1, 2, 3, 4, 5];\n * arrSum(numbers);\n * //=> 15\n * ```\n */\nexport function arrSum(array: number[]): number {\n return array.reduce((acc, cur) => acc + cur, 0)\n}\n","import { arrSum } from './arrSum'\n\n/**\n * Calculates the average of an array of numbers.\n * @returns The average of all numbers in the array.\n * @throws an error if the input array is empty.\n * @param array The array of numbers.\n * @example ```ts\n * const numbers = [1, 2, 3, 4, 5];\n * arrAverage(numbers);\n * //=> 3\n * ```\n */\nexport function arrAverage(array: number[]): number {\n if (!array.length) throw new Error('Cannot take an average of zero values.')\n return arrSum(array) / array.length\n}\n","/**\n * Coerce each element of an array to string.\n * @template T - The type of elements in the input array.\n * @returns A new array where each element is the string representation of the corresponding element in the input array.\n * @param array The array to iterate over.\n * @example ```ts\n * const numbers = [1, 2, 3];\n * arrEachToString(numbers);\n * //=> ['1', '2', '3']\n * ```\n */\nexport function arrEachToString<T>(array: T[]): string[] {\n return array.map((element) => '' + element)\n}\n","import type { ArrayPredicate } from './types/ArrayPredicate'\n\n/**\n * Returns true if the predicate is satisfied for every element of the passed array; otherwise false.\n * @param input The array\n * @template T - The type of elements in the array.\n * @returns Returns `true` if all elements pass the predicate check, else `false`.\n * @param predicate A predicate callback function\n * @example ```ts\n * const numbers = [1, 2, 3, 4, 5];\n * const isEven = (num) => num % 2 === 0;\n * arrEvery(numbers, isEven);\n * //=> false\n * arrEvery(numbers, (num) => num > 0);\n * //=> true\n * ```\n */\nexport function arrEvery<T>(input: Array<T>, predicate: ArrayPredicate<T>): boolean {\n for (let i = 0, len = input.length; i < len; i++) {\n if (predicate(input[i], i, input) === false) {\n return false\n }\n }\n return true\n}\n","/**\n * Returns an array of indices where the predicate function returns true for the corresponding element in the input array.\n * @param input - The array to search.\n * @param predicate - The function to test each element of the array.\n * @returns An array of indices where the predicate function returns true.\n */\nexport function arrFindIndicesOf<T>(input: Array<T>, predicate: (value: T) => boolean): number[] {\n const result: number[] = []\n for (let i = 0; i < input.length; i++) {\n if (predicate(input[i])) {\n result.push(i)\n }\n }\n return result\n}\n","/**\n * Searches for the last element in an array that satisfies a provided testing function.\n * @typeParam T - The type of elements in the input array.\n * @param input - The array to search within.\n * @param predicate - The function to test each element for a condition.\n * @returns The last element in the array that satisfies the provided testing function. Otherwise, undefined if no elements satisfy the testing function.\n * @example const numbers = [1, 2, 3, 4, 5, 6];\n * arrFindLast(numbers, num => num % 2 === 0);\n * //=> 6\n */\nexport function arrFindLast<T>(input: Array<T>, predicate: (value: T) => boolean): T | undefined {\n for (let i = input.length - 1; i >= 0; i--) {\n if (predicate(input[i]) === true) {\n return input[i]\n }\n }\n}\n","/**\n * Searches for an element in an array in reverse order and returns the index of the last occurrence of the element for which the provided testing function returns true.\n * If no such element is found, it returns -1.\n * @param input - The array to search in.\n * @param predicate - The testing function. Takes a value and returns a boolean.\n * @returns The index of the last occurrence of the element in the array that passes the test. If no such element is found, it returns -1.\n * @example ```ts\n * const arr = [1, 2, 3, 4, 5, 4, 3];\n * arrFindLastIndexOf(arr, (value) => value === 4);\n * //=> 5\n * ```\n */\nexport function arrFindLastIndexOf<T>(input: Array<T>, predicate: (value: T) => boolean): number {\n for (let i = input.length - 1; i >= 0; i--) {\n if (predicate(input[i])) {\n return i\n }\n }\n return -1\n}\n","import type { NestedArray } from './types/NestedArray'\n\n/**\n * Flattens the passed array recursively to a specified depth. Immutable.\n * @param input the array to flatten\n * @template T - The type of the elements in the input array.\n * @param - The maximum depth to flatten. Defaults to the maximum safe integer.\n * @returns The flattened array.\n * @throws If the input is not an array.\n * @param maxDepth the maximum recursive flattening depth.\n * @example ```ts\n * const nestedArray = [[1, 2], [3, [4, 5]], [6]];\n * arrFlatten(nestedArray, 1);\n * //=> [1, 2, 3, [4, 5], 6]\n * ```\n */\nexport function arrFlatten<T>(input: NestedArray<T>, maxDepth = Number.MAX_SAFE_INTEGER): Array<T> {\n const accum: T[] = []\n function recurse(arr: NestedArray<T>, depth: number) {\n for (let i = 0; i < arr.length; i++) {\n if (Array.isArray(arr[i]) && depth < maxDepth) {\n recurse(arr[i] as T[], depth + 1)\n } else {\n accum.push(arr[i] as T)\n }\n }\n }\n recurse(input, 0)\n return accum\n}\n","/**\n * Returns all indexes at which an element is found.\n * @param input The array to search\n * @template T - The type of elements in the input array.\n * @returns An array of indices where the specified element can be found.\n * @param element The element to find\n * @example ```ts\n * const inputArray = [1, 2, 3, 2, 4, 2, 5];\n * const elementToFind = 2;\n * arrIndicesOf(inputArray, elementToFind);\n * //=> [1, 3, 5]\n * ```\n */\nexport function arrIndicesOf<T>(input: Array<T>, element: T): number[] {\n const result: number[] = []\n for (let i = 0; i < input.length; i++) {\n if (element === input[i]) {\n result.push(i)\n }\n }\n return result\n}\n","/**\n * Returns the last element of an array.\n * Throws an error if the array is empty.\n * @template T The type of elements in the array.\n * @param array The array to get the last element from.\n * @returns The last element of the array.\n * @throws If the array is empty.\n * @example const numbers = [1, 2, 3, 4, 5];\n * const lastNumber = arrLast(numbers);\n * //=> 5\n */\nexport function arrLast<T>(array: T[]): T {\n if (!array.length) throw new Error('Cannot get last element of empty array.')\n return array[array.length - 1]\n}\n","import type { ArrayValueCallback } from './types/ArrayValueCallback'\n\n/**\n * This function takes an array and a callback function as arguments. It applies the callback function to each element of the array, mutating the original array in the process.\n * @template T The type of elements in the input array.\n * @param input The array to be mapped over.\n * @param f The callback function to be applied to each element of the array. This function takes three arguments: the current element, its index, and the original array.\n * @returns The original array, mutated by the callback function.\n * @example ```ts\n * arrMapMutable([1, 2, 3], (value: number) => value * 2);;\n * //=> [2, 4, 6]\n * ```\n */\nexport function arrMapMutable<T>(input: Array<T>, f: ArrayValueCallback<T>): Array<T> {\n for (let i = 0; i < input.length; i++) {\n input[i] = f(input[i], i, input)\n }\n return input\n}\n","/**\n * Returns an array of all unique object keys found in an array of objects.\n * @template T - The type of values in the input objects.\n * @returns An array of unique keys present in the input objects.\n * @param objects The array of objects.\n * @example ```ts\n * const objects = [\n * { name: 'John', age: 25 },\n * { name: 'Jane', gender: 'female' },\n * { name: 'Bob', age: 30, gender: 'male' },\n * ];\n * arrObjectsUniqueKeys(objects);\n * //=> ['name', 'age', 'gender']\n * ```\n */\nexport function arrObjectsUniqueKeys<T>(objects: Record<string, T>[]): string[] {\n const keys = new Set<string>()\n for (const o of objects) {\n for (const key of Object.keys(o)) {\n keys.add(key)\n }\n }\n return Array.from(keys)\n}\n","import { arrObjectsUniqueKeys } from './arrObjectsUniqueKeys'\n\n/**\n * Convert an array of objects to a two-dimensional table.\n * @param objects The array of objects to convert to a table.\n * @template T - The type of the values in the objects.\n * @param options.headers An optional array of strings specifying the headers (property names) to use. If not provided, the function will use all unique keys found in the objects.\n * @param options.emptyCell An optional value to use for empty cells. If not provided, the function will use `undefined`.\n * @returns A 2D array (table) where each row represents an object and each column represents a property of the object.\n * @param options The options for converting the objects to a table.\n * @example ```ts\n * arrObjectsToTable(\n * [\n * { a: 1, b: 2 },\n * { a: 3, b: 4, c: 5 },\n * ],\n * { emptyCell:1 },\n * ) //=> [ [ 'a', 'b', 'c' ], [ 1, 2,1 ], [ 3, 4, 5 ] ]\n * ```\n */\nexport function arrObjectsToTable<T, E>(\n objects: Record<string, T | undefined>[],\n options: {\n headers?: string[]\n emptyCell?: E\n } = {},\n): Array<Array<string | T | E>> {\n const headers = options?.headers?.slice() || arrObjectsUniqueKeys(objects)\n const table: Array<Array<string | T | E>> = [headers]\n for (const o of objects) {\n const row = headers.map((header) => {\n const value = o[header]\n return value !== undefined ? value : (options.emptyCell as E)\n })\n table.push(row)\n }\n return table\n}\n","/**\n * Remove duplicates from an array\n * @remarks This function uses the JavaScript Set object to remove duplicate values from an array.\n * @typeparam T - The type of elements in the array.\n * @returns The new array with duplicates removed.\n * @param array The array from which to remove duplicates.\n * @example ```ts\n * const array = [1, 2, 2, 3, 4, 4, 5];\n * arrRemoveDuplicates(array);\n * //=> [1, 2, 3, 4, 5]\n * ```\n */\nexport function arrRemoveDuplicates<T>(array: T[]): T[] {\n return Array.from(new Set(array))\n}\n","import { arrEvery } from './arrEvery'\n\n/**\n * This function compares the length of the two arrays and then checks if each element at the corresponding index is equal.\n * @param input1 The first array to compare.\n * @template T - The type of the elements in the arrays.\n * @returns A boolean indicating whether the two arrays are shallowly equal.\n * @param input2 The second array to compare.\n * Checks if two arrays are shallowly equal.\n * @example ```ts\n * arrShallowEquals([1, 2, 3], [1, 2, 3]);\n * //=> true\n * arrShallowEquals([1, 2, 3], [1, 2, 4]);\n * //=> false\n * ```\n */\nexport function arrShallowEquals<T>(input1: T[], input2: T[]): boolean {\n if (input1.length !== input2.length) return false\n return arrEvery(input1, (value: T, i: number) => value === input2[i])\n}\n","/**\n * Swaps two elements in an array. This function takes an input array and swaps the elements at the specified indices.\n * @param to The index of the element to swap to.\n * @param from The index of the element to swap from.\n * @template T - The type of elements in the array.\n * @returns The modified array with swapped elements.\n * @throws Will throw an error if 'from' or 'to' is not a valid index in the array.\n * @param input The input array.\n * @example ```ts\n * const arr = [1, 2, 3, 4, 5]\n * arrSwap(arr, 1, 3) //=> [1, 4, 3, 2, 5]\n * ```\n */\nexport function arrSwap<T>(input: Array<T>, from: number, to: number): Array<T> {\n if (from === to) return input\n ;[input[from], input[to]] = [input[to], input[from]]\n return input\n}\n","import { randomIntBetween } from '@bemoje/number'\nimport { arrShallowEquals } from './arrShallowEquals'\nimport { arrSwap } from './arrSwap'\n\n/**\n * Shuffle items in an array in-place. Guarantees changes.\n * @remarks This function does not guarantee that the order of the elements will be different after shuffling.\n * @typeparam T - The type of the elements in the input array.\n * @returns The same array, but shuffled.\n * @param input The array to shuffle.\n * @example ```ts\n * const input = [1, 2, 3, 4, 5];\n * arrShuffle(input);\n * //=> [3, 1, 5, 2, 4]\n * ```\n */\nexport function arrShuffle<T>(input: Array<T>): Array<T> {\n if (input.length <= 1) return input\n const original = input.slice()\n let equal = true\n while (equal) {\n for (let i = 0; i < input.length; i++) {\n const newIndex = randomIntBetween(0, input.length - 1)\n arrSwap(input, i, newIndex)\n }\n equal = arrShallowEquals(input, original)\n }\n return input\n}\n","import type { ArrayPredicate } from './types/ArrayPredicate'\n\n/**\n * Checks if at least one element in the array satisfies the provided predicate.\n * @param predicate The predicate function to apply to each element.\n * @template T The type of elements in the input array.\n * @returns Returns `true` if at least one element in the array passes the test implemented by the provided function, otherwise `false`.\n * @param input The array to check.\n * @example ```ts\n * const numbers = [1, 2, 3, 4, 5];\n * const isEven = (num) => num % 2 === 0;\n * arrSome(numbers, isEven);\n * //=> true\n * ```\n */\nexport function arrSome<T>(input: Array<T>, predicate: ArrayPredicate<T>): boolean {\n for (let i = 0, len = input.length; i < len; i++) {\n if (predicate(input[i], i, input) === true) {\n return true\n }\n }\n return false\n}\n","/**\n * Returns an index in the sorted array where the specified value could be inserted while maintaining the sorted order of the array.\n * If the element is already in the array, returns the index after the last instance of the element.\n * @param array - The sorted array to search.\n * @param value - The value to locate in the array.\n * @param comparator - A function that defines the sort order. If omitted, the array elements are converted to strings, then sorted according to each character's Unicode code point value.\n * @returns The index at which the value could be inserted into array to maintain the array's sorted order.\n * @example ```ts\n * const array = [1, 2, 3, 5, 6];\n * const value = 4;\n * const comparator = (a, b) => a - b;\n * const index = arrSortedLowerBound(array, value, comparator);\n * console.log(index); // Output: 3\n * ```\n */\nexport function arrSortedInsertionIndex<T>(array: readonly T[], value: T, comparator: (a: T, b: T) => number): number {\n let first = 0\n let count = array.length\n while (count > 0) {\n const step = Math.trunc(count / 2)\n let it = first + step\n if (comparator(array[it]!, value) <= 0) {\n first = ++it\n count -= step + 1\n } else {\n count = step\n }\n }\n return first\n}\n","import { compareNumeric } from '@bemoje/sort'\n\n/**\n * Sorts an array of numbers, bigints, or booleans in ascending order.\n * @returns The sorted array.\n * @remarks This function uses the JavaScript `Array.prototype.sort()` method, which sorts elements in place.\n * Therefore, the original array will be modified.\n * @throws If any element in the input array is not a number, bigint, or boolean.\n * @param input The array to be sorted.\n * @example ```ts\n * const input = [5, 2n, true, 10, false];\n * arrSortNumeric(input);\n * //=> [false, true, 2n, 5, 10]\n * ```\n */\nexport function arrSortNumeric(input: Array<number | bigint | boolean>): Array<number | bigint | boolean> {\n return input.sort(compareNumeric)\n}\n","import { assertion, isPositiveInteger } from '@bemoje/validation'\r\n\r\nexport function arrSplit<T>(array: T[], n: number): T[][] {\r\n assertion(n, isPositiveInteger)\r\n const result: T[][] = []\r\n if (array.length === 0) return result\r\n if (n === 1) return [array]\r\n const chunkSize = Math.ceil(array.length / n)\r\n for (let i = 0; i < array.length; i += chunkSize) {\r\n result.push(array.slice(i, i + chunkSize))\r\n }\r\n return result\r\n}\r\n","/**\n * Asserts that all rows in a 2D array have the same length.\n * @param - Optional array of headers to compare the row length against.\n * @throws If any row in the array has a different length than the others.\n * @param headers Optional. An array of headers. If provided, each row must have the same length as this array.\n * @typeparam T - The type of elements in the rows.\n * @param rows The 2D array to check.\n * @example ```ts\n * const rows = [\n * [1, 2, 3],\n * [4, 5, 6],\n * [7, 8, 9],\n * ];\n * arrTableAssertRowsSameLength(rows);\n * //=> undefined\n * const rowsWithDifferentLength = [\n * [1, 2, 3],\n * [4, 5],\n * [7, 8, 9],\n * ];\n * arrTableAssertRowsSameLength(rowsWithDifferentLength);\n * //=> Error: Expected 3 columns, got 2\n * ```\n */\nexport function arrTableAssertRowsSameLength<T>(rows: T[][], headers?: string[]): void {\n const numHeaders = (headers || rows[0]).length\n for (const row of rows) {\n if (row.length !== numHeaders) {\n throw new Error(`Expected ${numHeaders} columns, got ${row.length}`)\n }\n }\n}\n","import { arrEachToString } from './arrEachToString'\n\n/**\n * Coerce each value of a 2D array table to string.\n * @template T - The type of the elements in the input array.\n * @returns The converted 2D array where each element is a string.\n * @param table The 2D array to convert.\n * @example ```ts\n * const input: number[][] = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];\n * arrTableEachToString(input);\n * //=> [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]\n * ```\n */\nexport function arrTableEachToString<T>(table: T[][]): string[][] {\n return table.map(arrEachToString)\n}\n","import { strReplaceAll } from '@bemoje/string'\r\n\r\n/**\r\n * Converts a 2D array to a CSV string.\r\n * @param input The input 2D array.\r\n * @remarks This function is useful for exporting data to CSV format.\r\n * @param replaceLinebreakWith The character used to replace line breaks in the CSV string. Defaults to '|'.\r\n * @typeparam T - The type of the elements in the input array.\r\n * @returns The CSV string representation of the input array.\r\n * @param delimiter The delimiter to use for separating values in the CSV string.\r\n * @example ```ts\r\n * const input = [\r\n * ['Name', 'Age', 'Country'],\r\n * ['John', '25', 'USA'],\r\n * ['Alice', '30', 'Canada'],\r\n * ['Bob', '35', 'UK'],\r\n * ];\r\n * arrTableToCsv(input);\r\n * //=> \"Name;Age;Country\\nJohn;25;USA\\nAlice;30;Canada\\nBob;35;UK\"\r\n * ```\r\n */\r\nexport function arrTableToCsv<T>(input: T[][], delimiter = ';', replaceLinebreakWith = '|'): string {\r\n return input\r\n .map((row) => {\r\n return row\r\n .map((item) => strReplaceAll(item + '', delimiter, '').replace(/\\r*\\n/g, replaceLinebreakWith))\r\n .join(delimiter)\r\n })\r\n .join('\\n')\r\n}\r\n","/**\n * Converts a 2D array representing a table into an array of objects.\n * @param rows The 2D array representing the table.\n * @template T - The type of the elements in the rows.\n * @param headers The headers to use as keys for the objects. If not provided, the first row of the table is used as headers.\n * @returns An array of objects, where each object represents a row in the table.\n * @throws Throws an error if the headers are not provided and the table is empty or only contains one row.\n * @param headers Optional array of headers for the table.\n * @example ```ts\n * const table = [\n * ['Name', 'Age', 'Country'],\n * ['John', 25, 'USA'],\n * ['Jane', 30, 'Canada'],\n * ];\n * const headers = ['Name', 'Age', 'Country'];\n * arrTableToObjects(table, headers) //=> [\n * // { Name: 'John', Age: 25, Country: 'USA' },\n * // { Name: 'Jane', Age: 30, Country: 'Canada' },\n * // ]\n * ```\n */\nexport function arrTableToObjects<T>(rows: T[][], headers?: string[], ignoreKeys?: Set<string>): Record<string, T>[] {\n if (headers) {\n if (!rows.length) return []\n } else {\n if (rows.length <= 1) return []\n headers = rows[0].map((header) => {\n return header === null || header === undefined ? '' : String(header)\n })\n rows = rows.slice(1)\n }\n const _headers = headers\n return rows.map((row: T[]) => {\n const o: Record<string, T> = {}\n for (let i = 0; i < _headers.length; i++) {\n const header = _headers[i]\n if (ignoreKeys && ignoreKeys.has(header)) continue\n o[header] = row[i]\n }\n return o\n })\n}\n"],"names":["arrSum","array","reduce","acc","cur","arrAverage","length","Error","arrEachToString","map","element","arrEvery","input","predicate","i","len","arrFindIndicesOf","result","push","arrFindLast","arrFindLastIndexOf","arrFlatten","maxDepth","Number","MAX_SAFE_INTEGER","recurse","arr","depth","Array","isArray","accum","arrIndicesOf","arrLast","arrMapMutable","f","arrObjectsUniqueKeys","objects","keys","Set","o","key","Object","add","from","arrObjectsToTable","options","headers","_a","slice","table","row","header","value","emptyCell","arrRemoveDuplicates","arrShallowEquals","input1","input2","arrSwap","to","arrShuffle","original","equal","newIndex","randomIntBetween","arrSome","arrSortedInsertionIndex","comparator","first","count","step","Math","trunc","it","arrSortNumeric","sort","compareNumeric","arrSplit","n","assertion","isPositiveInteger","chunkSize","ceil","arrTableAssertRowsSameLength","rows","numHeaders","arrTableEachToString","arrTableToCsv","delimiter","replaceLinebreakWith","item","strReplaceAll","replace","join","arrTableToObjects","ignoreKeys","_headers","has"],"mappings":";;;;+LAUM,QAAU,CAAAA,MAAMA,CAACC,KAAe,CAAA,CACpC,MAAO,CAAAA,KAAK,CAACC,MAAM,CAAC,CAACC,GAAG,CAAEC,GAAG,GAAKD,GAAG,CAAGC,GAAG,CAAE,CAAC,CAChD,CCCM,QAAU,CAAAC,UAAUA,CAACJ,KAAe,CAAA,CACxC,GAAI,CAACA,KAAK,CAACK,MAAM,CAAE,KAAM,IAAI,CAAAC,KAAK,CAAC,wCAAwC,CAAC,CAC5E,MAAO,CAAAP,MAAM,CAACC,KAAK,CAAC,CAAGA,KAAK,CAACK,MAC/B,CCLM,QAAU,CAAAE,eAAeA,CAAIP,KAAU,CAAA,CAC3C,MAAO,CAAAA,KAAK,CAACQ,GAAG,CAAEC,OAAO,EAAK,EAAE,CAAGA,OAAO,CAC5C,CCIgB,QAAA,CAAAC,QAAQA,CAAIC,KAAe,CAAEC,SAA4B,CAAA,CACvE,IAAK,GAAI,CAAAC,CAAC,CAAG,CAAC,CAAEC,GAAG,CAAGH,KAAK,CAACN,MAAM,CAAEQ,CAAC,CAAGC,GAAG,CAAED,CAAC,EAAE,CAC9C,GAAI,KAAAD,SAAS,CAACD,KAAK,CAACE,CAAC,CAAC,CAAEA,CAAC,CAAEF,KAAK,CAAW,CACzC,SAGJ,QACF,CClBgB,QAAA,CA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;AAC7B,cAAc,oCAAoC,CAAA;AAClD,cAAc,4BAA4B,CAAA;AAC1C,cAAc,qBAAqB,CAAA;AACnC,cAAc,yBAAyB,CAAA;AACvC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrAverage.d.ts","sourceRoot":"","sources":["../../../src/lib/arrAverage.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAGlD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrEachToString.d.ts","sourceRoot":"","sources":["../../../src/lib/arrEachToString.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,MAAM,EAAE,CAEvD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrEvery.d.ts","sourceRoot":"","sources":["../../../src/lib/arrEvery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAE5D;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,CAOlF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrFindIndicesOf.d.ts","sourceRoot":"","sources":["../../../src/lib/arrFindIndicesOf.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,GAAG,MAAM,EAAE,CAQ/F"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrFindLast.d.ts","sourceRoot":"","sources":["../../../src/lib/arrFindLast.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,GAAG,CAAC,GAAG,SAAS,CAM/F"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrFindLastIndexOf.d.ts","sourceRoot":"","sources":["../../../src/lib/arrFindLastIndexOf.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,GAAG,MAAM,CAO/F"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrFlatten.d.ts","sourceRoot":"","sources":["../../../src/lib/arrFlatten.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAEtD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,QAAQ,SAA0B,GAAG,KAAK,CAAC,CAAC,CAAC,CAajG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrIndicesOf.d.ts","sourceRoot":"","sources":["../../../src/lib/arrIndicesOf.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,MAAM,EAAE,CAQrE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrLast.d.ts","sourceRoot":"","sources":["../../../src/lib/arrLast.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,CAGxC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrMapMutable.d.ts","sourceRoot":"","sources":["../../../src/lib/arrMapMutable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAEpE;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAKpF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrObjectsToTable.d.ts","sourceRoot":"","sources":["../../../src/lib/arrObjectsToTable.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,CAAC,EACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,SAAS,CAAC,EAAE,EACxC,OAAO,GAAE;IACP,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,SAAS,CAAC,EAAE,CAAC,CAAA;CACT,GACL,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAW9B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrObjectsUniqueKeys.d.ts","sourceRoot":"","sources":["../../../src/lib/arrObjectsUniqueKeys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,CAQ9E"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrRemoveDuplicates.d.ts","sourceRoot":"","sources":["../../../src/lib/arrRemoveDuplicates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAEtD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrShallowEquals.d.ts","sourceRoot":"","sources":["../../../src/lib/arrShallowEquals.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAGrE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrShuffle.d.ts","sourceRoot":"","sources":["../../../src/lib/arrShuffle.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAYvD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrSome.d.ts","sourceRoot":"","sources":["../../../src/lib/arrSome.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAE5D;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,CAOjF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrSortNumeric.d.ts","sourceRoot":"","sources":["../../../src/lib/arrSortNumeric.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAExG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrSortedInsertionIndex.d.ts","sourceRoot":"","sources":["../../../src/lib/arrSortedInsertionIndex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,CAcpH"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrSplit.d.ts","sourceRoot":"","sources":["../../../src/lib/arrSplit.ts"],"names":[],"mappings":"AAEA,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,EAAE,EAAE,CAUxD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrSum.d.ts","sourceRoot":"","sources":["../../../src/lib/arrSum.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAE9C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrSwap.d.ts","sourceRoot":"","sources":["../../../src/lib/arrSwap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAI9E"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrTableAssertRowsSameLength.d.ts","sourceRoot":"","sources":["../../../src/lib/arrTableAssertRowsSameLength.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,4BAA4B,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAOrF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrTableEachToString.d.ts","sourceRoot":"","sources":["../../../src/lib/arrTableEachToString.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,CAEhE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrTableToCsv.d.ts","sourceRoot":"","sources":["../../../src/lib/arrTableToCsv.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,SAAS,SAAM,EAAE,oBAAoB,SAAM,GAAG,MAAM,CAQlG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrTableToObjects.d.ts","sourceRoot":"","sources":["../../../src/lib/arrTableToObjects.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,EAAE,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAoBnH"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ArrayPredicate.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/ArrayPredicate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,OAAO,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ArrayValueCallback.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/ArrayValueCallback.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ArrayVoidCallback.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/ArrayVoidCallback.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,IAAI,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NestedArray.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/NestedArray.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA"}
|
package/jest.config.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
const pkg = require('./package.json')
|
|
3
|
-
const name = pkg.name.split('@')[1]
|
|
4
|
-
export default {
|
|
5
|
-
displayName: name,
|
|
6
|
-
preset: '../../jest.preset.js',
|
|
7
|
-
testEnvironment: 'node',
|
|
8
|
-
transform: {
|
|
9
|
-
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
|
|
10
|
-
},
|
|
11
|
-
moduleFileExtensions: ['ts', 'js', 'html'],
|
|
12
|
-
coverageDirectory: '../../coverage/pkg/' + name,
|
|
13
|
-
}
|
package/project.json
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "array",
|
|
3
|
-
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
-
"sourceRoot": "pkg/array/src",
|
|
5
|
-
"projectType": "library",
|
|
6
|
-
"targets": {
|
|
7
|
-
"lint": {
|
|
8
|
-
"executor": "@nx/linter:eslint",
|
|
9
|
-
"outputs": ["{options.outputFile}"],
|
|
10
|
-
"options": {
|
|
11
|
-
"lintFilePatterns": ["pkg/array/**/*.ts"]
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"test": {
|
|
15
|
-
"executor": "@nx/jest:jest",
|
|
16
|
-
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
|
17
|
-
"options": {
|
|
18
|
-
"jestConfig": "pkg/array/jest.config.ts",
|
|
19
|
-
"passWithNoTests": true
|
|
20
|
-
},
|
|
21
|
-
"configurations": {
|
|
22
|
-
"ci": {
|
|
23
|
-
"ci": true,
|
|
24
|
-
"codeCoverage": true
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
"tags": []
|
|
30
|
-
}
|
package/tsconfig.spec.json
DELETED