@bemoje/array 0.3.3 → 1.0.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.
Files changed (141) hide show
  1. package/README.md +2 -33
  2. package/{cjs/lib → dist}/arrAverage.d.ts +0 -1
  3. package/{cjs/lib → dist}/arrEachToString.d.ts +0 -1
  4. package/{cjs/lib → dist}/arrFindIndicesOf.d.ts +0 -1
  5. package/dist/arrGetOrDefault.d.ts +4 -0
  6. package/{cjs/lib → dist}/arrHasDuplicates.d.ts +0 -1
  7. package/{cjs/lib → dist}/arrIndicesOf.d.ts +0 -1
  8. package/{cjs/lib → dist}/arrLast.d.ts +0 -1
  9. package/{cjs/lib → dist}/arrMapMutable.d.ts +1 -3
  10. package/{cjs/lib → dist}/arrObjectsToTable.d.ts +0 -1
  11. package/{cjs/lib → dist}/arrObjectsUniqueKeys.d.ts +0 -1
  12. package/{cjs/lib → dist}/arrRemove.d.ts +0 -1
  13. package/{cjs/lib → dist}/arrRemoveDuplicates.d.ts +0 -1
  14. package/{cjs/lib → dist}/arrRemoveMutable.d.ts +0 -1
  15. package/{cjs/lib → dist}/arrShuffle.d.ts +0 -1
  16. package/{cjs/lib → dist}/arrSortNumeric.d.ts +0 -1
  17. package/{cjs/lib → dist}/arrSortedInsertionIndex.d.ts +0 -1
  18. package/{cjs/lib → dist}/arrSum.d.ts +0 -1
  19. package/{cjs/lib → dist}/arrSwap.d.ts +0 -1
  20. package/{cjs/lib → dist}/arrTableAssertRowsSameLength.d.ts +0 -1
  21. package/{cjs/lib → dist}/arrTableEachToString.d.ts +0 -1
  22. package/dist/arrTableIterateAsObjects.d.ts +4 -0
  23. package/{cjs/lib → dist}/arrTableRemoveColumns.d.ts +0 -1
  24. package/{cjs/lib → dist}/arrTableToCsv.d.ts +0 -1
  25. package/{cjs/lib → dist}/arrTableToObjects.d.ts +0 -1
  26. package/dist/arrayToString.d.ts +4 -0
  27. package/dist/index.d.ts +56 -0
  28. package/dist/index.mjs +442 -0
  29. package/dist/index.mjs.map +7 -0
  30. package/package.json +24 -18
  31. package/LICENSE +0 -21
  32. package/cjs/index.d.ts +0 -33
  33. package/cjs/index.d.ts.map +0 -1
  34. package/cjs/index.js +0 -36
  35. package/cjs/index.js.map +0 -1
  36. package/cjs/lib/arrAverage.d.ts.map +0 -1
  37. package/cjs/lib/arrAverage.js +0 -22
  38. package/cjs/lib/arrAverage.js.map +0 -1
  39. package/cjs/lib/arrEachToString.d.ts.map +0 -1
  40. package/cjs/lib/arrEachToString.js +0 -19
  41. package/cjs/lib/arrEachToString.js.map +0 -1
  42. package/cjs/lib/arrEvery.d.ts +0 -18
  43. package/cjs/lib/arrEvery.d.ts.map +0 -1
  44. package/cjs/lib/arrEvery.js +0 -28
  45. package/cjs/lib/arrEvery.js.map +0 -1
  46. package/cjs/lib/arrFindIndicesOf.d.ts.map +0 -1
  47. package/cjs/lib/arrFindIndicesOf.js +0 -20
  48. package/cjs/lib/arrFindIndicesOf.js.map +0 -1
  49. package/cjs/lib/arrFindLast.d.ts +0 -12
  50. package/cjs/lib/arrFindLast.d.ts.map +0 -1
  51. package/cjs/lib/arrFindLast.js +0 -23
  52. package/cjs/lib/arrFindLast.js.map +0 -1
  53. package/cjs/lib/arrFindLastIndexOf.d.ts +0 -14
  54. package/cjs/lib/arrFindLastIndexOf.d.ts.map +0 -1
  55. package/cjs/lib/arrFindLastIndexOf.js +0 -25
  56. package/cjs/lib/arrFindLastIndexOf.js.map +0 -1
  57. package/cjs/lib/arrFlatten.d.ts +0 -17
  58. package/cjs/lib/arrFlatten.d.ts.map +0 -1
  59. package/cjs/lib/arrFlatten.js +0 -34
  60. package/cjs/lib/arrFlatten.js.map +0 -1
  61. package/cjs/lib/arrHasDuplicates.d.ts.map +0 -1
  62. package/cjs/lib/arrHasDuplicates.js +0 -20
  63. package/cjs/lib/arrHasDuplicates.js.map +0 -1
  64. package/cjs/lib/arrIndicesOf.d.ts.map +0 -1
  65. package/cjs/lib/arrIndicesOf.js +0 -27
  66. package/cjs/lib/arrIndicesOf.js.map +0 -1
  67. package/cjs/lib/arrLast.d.ts.map +0 -1
  68. package/cjs/lib/arrLast.js +0 -21
  69. package/cjs/lib/arrLast.js.map +0 -1
  70. package/cjs/lib/arrMapMutable.d.ts.map +0 -1
  71. package/cjs/lib/arrMapMutable.js +0 -22
  72. package/cjs/lib/arrMapMutable.js.map +0 -1
  73. package/cjs/lib/arrObjectsToTable.d.ts.map +0 -1
  74. package/cjs/lib/arrObjectsToTable.js +0 -36
  75. package/cjs/lib/arrObjectsToTable.js.map +0 -1
  76. package/cjs/lib/arrObjectsUniqueKeys.d.ts.map +0 -1
  77. package/cjs/lib/arrObjectsUniqueKeys.js +0 -29
  78. package/cjs/lib/arrObjectsUniqueKeys.js.map +0 -1
  79. package/cjs/lib/arrRemove.d.ts.map +0 -1
  80. package/cjs/lib/arrRemove.js +0 -11
  81. package/cjs/lib/arrRemove.js.map +0 -1
  82. package/cjs/lib/arrRemoveDuplicates.d.ts.map +0 -1
  83. package/cjs/lib/arrRemoveDuplicates.js +0 -20
  84. package/cjs/lib/arrRemoveDuplicates.js.map +0 -1
  85. package/cjs/lib/arrRemoveMutable.d.ts.map +0 -1
  86. package/cjs/lib/arrRemoveMutable.js +0 -15
  87. package/cjs/lib/arrRemoveMutable.js.map +0 -1
  88. package/cjs/lib/arrShallowEquals.d.ts +0 -16
  89. package/cjs/lib/arrShallowEquals.d.ts.map +0 -1
  90. package/cjs/lib/arrShallowEquals.js +0 -25
  91. package/cjs/lib/arrShallowEquals.js.map +0 -1
  92. package/cjs/lib/arrShuffle.d.ts.map +0 -1
  93. package/cjs/lib/arrShuffle.js +0 -33
  94. package/cjs/lib/arrShuffle.js.map +0 -1
  95. package/cjs/lib/arrSome.d.ts +0 -16
  96. package/cjs/lib/arrSome.d.ts.map +0 -1
  97. package/cjs/lib/arrSome.js +0 -26
  98. package/cjs/lib/arrSome.js.map +0 -1
  99. package/cjs/lib/arrSortNumeric.d.ts.map +0 -1
  100. package/cjs/lib/arrSortNumeric.js +0 -27
  101. package/cjs/lib/arrSortNumeric.js.map +0 -1
  102. package/cjs/lib/arrSortedInsertionIndex.d.ts.map +0 -1
  103. package/cjs/lib/arrSortedInsertionIndex.js +0 -36
  104. package/cjs/lib/arrSortedInsertionIndex.js.map +0 -1
  105. package/cjs/lib/arrSum.d.ts.map +0 -1
  106. package/cjs/lib/arrSum.js +0 -18
  107. package/cjs/lib/arrSum.js.map +0 -1
  108. package/cjs/lib/arrSwap.d.ts.map +0 -1
  109. package/cjs/lib/arrSwap.js +0 -24
  110. package/cjs/lib/arrSwap.js.map +0 -1
  111. package/cjs/lib/arrTableAssertRowsSameLength.d.ts.map +0 -1
  112. package/cjs/lib/arrTableAssertRowsSameLength.js +0 -37
  113. package/cjs/lib/arrTableAssertRowsSameLength.js.map +0 -1
  114. package/cjs/lib/arrTableEachToString.d.ts.map +0 -1
  115. package/cjs/lib/arrTableEachToString.js +0 -20
  116. package/cjs/lib/arrTableEachToString.js.map +0 -1
  117. package/cjs/lib/arrTableRemoveColumns.d.ts.map +0 -1
  118. package/cjs/lib/arrTableRemoveColumns.js +0 -18
  119. package/cjs/lib/arrTableRemoveColumns.js.map +0 -1
  120. package/cjs/lib/arrTableToCsv.d.ts.map +0 -1
  121. package/cjs/lib/arrTableToCsv.js +0 -33
  122. package/cjs/lib/arrTableToCsv.js.map +0 -1
  123. package/cjs/lib/arrTableToObjects.d.ts.map +0 -1
  124. package/cjs/lib/arrTableToObjects.js +0 -51
  125. package/cjs/lib/arrTableToObjects.js.map +0 -1
  126. package/cjs/lib/types/ArrayPredicate.d.ts +0 -11
  127. package/cjs/lib/types/ArrayPredicate.d.ts.map +0 -1
  128. package/cjs/lib/types/ArrayPredicate.js +0 -3
  129. package/cjs/lib/types/ArrayPredicate.js.map +0 -1
  130. package/cjs/lib/types/ArrayValueCallback.d.ts +0 -2
  131. package/cjs/lib/types/ArrayValueCallback.d.ts.map +0 -1
  132. package/cjs/lib/types/ArrayValueCallback.js +0 -3
  133. package/cjs/lib/types/ArrayValueCallback.js.map +0 -1
  134. package/cjs/lib/types/ArrayVoidCallback.d.ts +0 -2
  135. package/cjs/lib/types/ArrayVoidCallback.d.ts.map +0 -1
  136. package/cjs/lib/types/ArrayVoidCallback.js +0 -3
  137. package/cjs/lib/types/ArrayVoidCallback.js.map +0 -1
  138. package/cjs/lib/types/NestedArray.d.ts +0 -2
  139. package/cjs/lib/types/NestedArray.d.ts.map +0 -1
  140. package/cjs/lib/types/NestedArray.js +0 -3
  141. package/cjs/lib/types/NestedArray.js.map +0 -1
package/README.md CHANGED
@@ -1,34 +1,3 @@
1
- # @bemoje/array
1
+ # @mono/array
2
2
 
3
-
4
-
5
- ![npm (scoped)](https://img.shields.io/npm/v/%40bemoje/trie-map)
6
- ![npm bundle size (scoped)](https://img.shields.io/bundlephobia/minzip/%40bemoje/array)
7
- ![npm](https://img.shields.io/npm/dt/%40bemoje/array)
8
- ![NPM](https://img.shields.io/npm/l/%40bemoje%2Farray)
9
-
10
- ![GitHub last commit (by committer)](https://img.shields.io/github/last-commit/bemoje/tsmono)
11
- ![GitHub closed pull requests](https://img.shields.io/github/issues-pr-closed/bemoje/tsmono)
12
- ![GitHub top language](https://img.shields.io/github/languages/top/bemoje/tsmono)
13
-
14
-
15
- ## Documentation
16
- [Documentation Website](https://bemoje.github.io/tsmono/modules/array.html)
17
-
18
- ## Installation
19
- This library is published in the NPM registry and can be installed using any compatible package manager.
20
-
21
- #### NPM
22
- ```sh
23
- npm install @bemoje/array
24
- ```
25
-
26
-
27
- ## Issues
28
- Please let me know of any bugs or [issues](https://github.com/bemoje/tsmono/issues).
29
-
30
- ## Contribute
31
- Contributors are welcome to open a [pull request](https://github.com/bemoje/tsmono/pulls).
32
-
33
- ## License
34
- Released under the [undefined License](./LICENSE).
3
+ Array manipulation and table processing utilities.
@@ -10,4 +10,3 @@
10
10
  * ```
11
11
  */
12
12
  export declare function arrAverage(array: number[]): number;
13
- //# sourceMappingURL=arrAverage.d.ts.map
@@ -10,4 +10,3 @@
10
10
  * ```
11
11
  */
12
12
  export declare function arrEachToString<T>(array: T[]): string[];
13
- //# sourceMappingURL=arrEachToString.d.ts.map
@@ -5,4 +5,3 @@
5
5
  * @returns An array of indices where the predicate function returns true.
6
6
  */
7
7
  export declare function arrFindIndicesOf<T>(input: Array<T>, predicate: (value: T) => boolean): number[];
8
- //# sourceMappingURL=arrFindIndicesOf.d.ts.map
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Get array element at index or create it using factory function if it doesn't exist.
3
+ */
4
+ export declare function arrGetOrDefault<V>(array: V[], index: number, factory: (index: number) => V): V;
@@ -5,4 +5,3 @@
5
5
  * @typeParam T - The type of elements in the array.
6
6
  */
7
7
  export declare function arrHasDuplicates<T>(arr: T[]): boolean;
8
- //# sourceMappingURL=arrHasDuplicates.d.ts.map
@@ -12,4 +12,3 @@
12
12
  * ```
13
13
  */
14
14
  export declare function arrIndicesOf<T>(input: Array<T>, element: T): number[];
15
- //# sourceMappingURL=arrIndicesOf.d.ts.map
@@ -10,4 +10,3 @@
10
10
  * //=> 5
11
11
  */
12
12
  export declare function arrLast<T>(array: T[]): T;
13
- //# sourceMappingURL=arrLast.d.ts.map
@@ -1,4 +1,3 @@
1
- import { ArrayValueCallback } from './types/ArrayValueCallback';
2
1
  /**
3
2
  * 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.
4
3
  * @template T The type of elements in the input array.
@@ -10,5 +9,4 @@ import { ArrayValueCallback } from './types/ArrayValueCallback';
10
9
  * //=> [2, 4, 6]
11
10
  * ```
12
11
  */
13
- export declare function arrMapMutable<T>(input: Array<T>, f: ArrayValueCallback<T>): Array<T>;
14
- //# sourceMappingURL=arrMapMutable.d.ts.map
12
+ export declare function arrMapMutable<T>(input: Array<T>, f: (value: T, index: number, array: T[]) => T): Array<T>;
@@ -20,4 +20,3 @@ export declare function arrObjectsToTable<T, E>(objects: Record<string, T | unde
20
20
  headers?: string[];
21
21
  emptyCell?: E;
22
22
  }): Array<Array<string | T | E>>;
23
- //# sourceMappingURL=arrObjectsToTable.d.ts.map
@@ -14,4 +14,3 @@
14
14
  * ```
15
15
  */
16
16
  export declare function arrObjectsUniqueKeys<T>(objects: Record<string, T>[]): string[];
17
- //# sourceMappingURL=arrObjectsUniqueKeys.d.ts.map
@@ -2,4 +2,3 @@
2
2
  * Remove a given element from a copy of a given array and return the resulting array.
3
3
  */
4
4
  export declare function arrRemove<T>(arr: T[], elementToRemove: T): T[];
5
- //# sourceMappingURL=arrRemove.d.ts.map
@@ -11,4 +11,3 @@
11
11
  * ```
12
12
  */
13
13
  export declare function arrRemoveDuplicates<T>(array: T[]): T[];
14
- //# sourceMappingURL=arrRemoveDuplicates.d.ts.map
@@ -2,4 +2,3 @@
2
2
  * Remove elements in-place from an array.
3
3
  */
4
4
  export declare function arrRemoveMutable<T>(arr: T[], elementToRemove: T): void;
5
- //# sourceMappingURL=arrRemoveMutable.d.ts.map
@@ -11,4 +11,3 @@
11
11
  * ```
12
12
  */
13
13
  export declare function arrShuffle<T>(input: Array<T>): Array<T>;
14
- //# sourceMappingURL=arrShuffle.d.ts.map
@@ -12,4 +12,3 @@
12
12
  * ```
13
13
  */
14
14
  export declare function arrSortNumeric(input: Array<number | bigint | boolean>): Array<number | bigint | boolean>;
15
- //# sourceMappingURL=arrSortNumeric.d.ts.map
@@ -14,4 +14,3 @@
14
14
  * ```
15
15
  */
16
16
  export declare function arrSortedInsertionIndex<T>(array: readonly T[], value: T, comparator: (a: T, b: T) => number): number;
17
- //# sourceMappingURL=arrSortedInsertionIndex.d.ts.map
@@ -9,4 +9,3 @@
9
9
  * ```
10
10
  */
11
11
  export declare function arrSum(array: number[]): number;
12
- //# sourceMappingURL=arrSum.d.ts.map
@@ -12,4 +12,3 @@
12
12
  * ```
13
13
  */
14
14
  export declare function arrSwap<T>(input: Array<T>, from: number, to: number): Array<T>;
15
- //# sourceMappingURL=arrSwap.d.ts.map
@@ -23,4 +23,3 @@
23
23
  * ```
24
24
  */
25
25
  export declare function arrTableAssertRowsSameLength<T>(rows: T[][], headers?: string[]): void;
26
- //# sourceMappingURL=arrTableAssertRowsSameLength.d.ts.map
@@ -10,4 +10,3 @@
10
10
  * ```
11
11
  */
12
12
  export declare function arrTableEachToString<T>(table: T[][]): string[][];
13
- //# sourceMappingURL=arrTableEachToString.d.ts.map
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Generator that iterates through a 2D array table, yielding objects with header keys and row values.
3
+ */
4
+ export declare function arrTableIterateAsObjects<T>(rows: T[][], headers: string[], ignoreHeaders?: Set<string>): Generator<Record<string, T>, void, unknown>;
@@ -5,4 +5,3 @@
5
5
  * @returns A new 2D array (table) with the specified columns removed.
6
6
  */
7
7
  export declare function arrTableRemoveColumns(table: string[][], ...removeColumnNames: string[]): string[][];
8
- //# sourceMappingURL=arrTableRemoveColumns.d.ts.map
@@ -18,4 +18,3 @@
18
18
  * ```
19
19
  */
20
20
  export declare function arrTableToCsv<T>(input: T[][], delimiter?: string, replaceLinebreakWith?: string): string;
21
- //# sourceMappingURL=arrTableToCsv.d.ts.map
@@ -20,4 +20,3 @@
20
20
  * ```
21
21
  */
22
22
  export declare function arrTableToObjects<T>(rows: T[][], headers?: string[], ignoreKeys?: Set<string>): Record<string, T>[];
23
- //# sourceMappingURL=arrTableToObjects.d.ts.map
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Short and condensed string representation of an array, easy to read for error outputs or similar.
3
+ */
4
+ export declare function arrayToString<T>(array: T[]): string;
@@ -0,0 +1,56 @@
1
+ export * from './arrAverage';
2
+ export * from './arrEachToString';
3
+ export * from './arrFindIndicesOf';
4
+ export * from './arrGetOrDefault';
5
+ export * from './arrHasDuplicates';
6
+ export * from './arrIndicesOf';
7
+ export * from './arrLast';
8
+ export * from './arrMapMutable';
9
+ export * from './arrObjectsToTable';
10
+ export * from './arrObjectsUniqueKeys';
11
+ export * from './arrRemove';
12
+ export * from './arrRemoveDuplicates';
13
+ export * from './arrRemoveMutable';
14
+ export * from './arrShuffle';
15
+ export * from './arrSortNumeric';
16
+ export * from './arrSortedInsertionIndex';
17
+ export * from './arrSum';
18
+ export * from './arrSwap';
19
+ export * from './arrTableAssertRowsSameLength';
20
+ export * from './arrTableEachToString';
21
+ export * from './arrTableIterateAsObjects';
22
+ export * from './arrTableRemoveColumns';
23
+ export * from './arrTableToCsv';
24
+ export * from './arrTableToObjects';
25
+ export * from './arrayToString';
26
+ declare const _default: {
27
+ arrayToString<T>(array: T[]): string;
28
+ arrTableToObjects<T>(rows: T[][], headers?: string[], ignoreKeys?: Set<string>): Record<string, T>[];
29
+ arrTableToCsv<T>(input: T[][], delimiter?: string, replaceLinebreakWith?: string): string;
30
+ arrTableRemoveColumns(table: string[][], ...removeColumnNames: string[]): string[][];
31
+ arrTableIterateAsObjects<T>(rows: T[][], headers: string[], ignoreHeaders?: Set<string>): Generator<Record<string, T>, void, unknown>;
32
+ arrTableEachToString<T>(table: T[][]): string[][];
33
+ arrTableAssertRowsSameLength<T>(rows: T[][], headers?: string[]): void;
34
+ arrSwap<T>(input: Array<T>, from: number, to: number): Array<T>;
35
+ arrSum(array: number[]): number;
36
+ arrSortedInsertionIndex<T>(array: readonly T[], value: T, comparator: (a: T, b: T) => number): number;
37
+ arrSortNumeric(input: Array<number | bigint | boolean>): Array<number | bigint | boolean>;
38
+ arrShuffle<T>(input: Array<T>): Array<T>;
39
+ arrRemoveMutable<T>(arr: T[], elementToRemove: T): void;
40
+ arrRemoveDuplicates<T>(array: T[]): T[];
41
+ arrRemove<T>(arr: T[], elementToRemove: T): T[];
42
+ arrObjectsUniqueKeys<T>(objects: Record<string, T>[]): string[];
43
+ arrObjectsToTable<T, E>(objects: Record<string, T | undefined>[], options?: {
44
+ headers?: string[];
45
+ emptyCell?: E;
46
+ }): Array<Array<string | T | E>>;
47
+ arrMapMutable<T>(input: Array<T>, f: (value: T, index: number, array: T[]) => T): Array<T>;
48
+ arrLast<T>(array: T[]): T;
49
+ arrIndicesOf<T>(input: Array<T>, element: T): number[];
50
+ arrHasDuplicates<T>(arr: T[]): boolean;
51
+ arrGetOrDefault<V>(array: V[], index: number, factory: (index: number) => V): V;
52
+ arrFindIndicesOf<T>(input: Array<T>, predicate: (value: T) => boolean): number[];
53
+ arrEachToString<T>(array: T[]): string[];
54
+ arrAverage(array: number[]): number;
55
+ };
56
+ export default _default;