ismx-nexo-node-app 0.4.122 → 0.4.123

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.
@@ -118,5 +118,18 @@ class ArrayUtils {
118
118
  return array.filter((_, index) => results[index]);
119
119
  });
120
120
  }
121
+ /**
122
+ * Returns a sorted copy of the provided array.
123
+ * The original array remains unchanged.
124
+ *
125
+ * @param {T[]} array - The array to sort.
126
+ * @param {(a: T, b: T) => number} [compareFn] - Optional comparison function that defines the sort order.
127
+ * If omitted, the array elements are sorted as strings in ascending order.
128
+ * @return {T[]} A new array containing the sorted elements.
129
+ * @template T
130
+ */
131
+ static sorted(array, compareFn) {
132
+ return [...array].sort(compareFn);
133
+ }
121
134
  }
122
135
  exports.default = ArrayUtils;
@@ -74,4 +74,15 @@ export default abstract class ArrayUtils {
74
74
  * @param predicate
75
75
  */
76
76
  static filterAsync<T>(array: T[], predicate: (value: T, index: number, array: T[]) => boolean | Promise<boolean>): Promise<T[]>;
77
+ /**
78
+ * Returns a sorted copy of the provided array.
79
+ * The original array remains unchanged.
80
+ *
81
+ * @param {T[]} array - The array to sort.
82
+ * @param {(a: T, b: T) => number} [compareFn] - Optional comparison function that defines the sort order.
83
+ * If omitted, the array elements are sorted as strings in ascending order.
84
+ * @return {T[]} A new array containing the sorted elements.
85
+ * @template T
86
+ */
87
+ static sorted<T>(array: T[], compareFn?: (a: T, b: T) => number): T[];
77
88
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ismx-nexo-node-app",
3
- "version": "0.4.122",
3
+ "version": "0.4.123",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build": "rm -rf ./dist && npx tsc",
@@ -111,4 +111,18 @@ export default abstract class ArrayUtils {
111
111
  return array.filter((_, index) => results[index]);
112
112
  }
113
113
 
114
+ /**
115
+ * Returns a sorted copy of the provided array.
116
+ * The original array remains unchanged.
117
+ *
118
+ * @param {T[]} array - The array to sort.
119
+ * @param {(a: T, b: T) => number} [compareFn] - Optional comparison function that defines the sort order.
120
+ * If omitted, the array elements are sorted as strings in ascending order.
121
+ * @return {T[]} A new array containing the sorted elements.
122
+ * @template T
123
+ */
124
+ static sorted<T>(array: T[], compareFn?: (a: T, b: T) => number): T[] {
125
+ return [ ...array ].sort(compareFn);
126
+ }
127
+
114
128
  }