@8ms/helpers 2.3.27 → 2.3.28
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/dist/lodash/index.d.mts +1 -1
- package/dist/lodash/index.mjs +2 -1
- package/package.json +1 -1
package/dist/lodash/index.d.mts
CHANGED
|
@@ -31,7 +31,7 @@ declare const merge: <T extends object>(target: T, ...sources: any[]) => T;
|
|
|
31
31
|
//#region src/lodash/orderBy.d.ts
|
|
32
32
|
type OrderDirection = "asc" | "desc";
|
|
33
33
|
type Iteratee<T> = ((item: T) => unknown) | string;
|
|
34
|
-
declare const orderBy: <T>(collection: T[], iteratees: Iteratee<T> | Iteratee<T>[], orders?: OrderDirection | OrderDirection[]) => T[];
|
|
34
|
+
declare const orderBy: <T>(collection: T[] | Record<string, T>, iteratees: Iteratee<T> | Iteratee<T>[], orders?: OrderDirection | OrderDirection[]) => T[];
|
|
35
35
|
//#endregion
|
|
36
36
|
//#region src/lodash/unescape.d.ts
|
|
37
37
|
declare const unescape: (str: string) => string;
|
package/dist/lodash/index.mjs
CHANGED
|
@@ -118,13 +118,14 @@ const merge = (target, ...sources) => {
|
|
|
118
118
|
//#endregion
|
|
119
119
|
//#region src/lodash/orderBy.ts
|
|
120
120
|
const orderBy = (collection, iteratees, orders = "asc") => {
|
|
121
|
+
const arr = Array.isArray(collection) ? collection : Object.values(collection);
|
|
121
122
|
const keys = Array.isArray(iteratees) ? iteratees : [iteratees];
|
|
122
123
|
const dirs = Array.isArray(orders) ? orders : [orders];
|
|
123
124
|
const getValue = (item, key) => {
|
|
124
125
|
if (typeof key === "function") return key(item);
|
|
125
126
|
return key.split(".").reduce((acc, part) => acc?.[part], item);
|
|
126
127
|
};
|
|
127
|
-
return [...
|
|
128
|
+
return [...arr].sort((a, b) => {
|
|
128
129
|
for (let i = 0; i < keys.length; i++) {
|
|
129
130
|
const dir = dirs[i] === "desc" ? -1 : 1;
|
|
130
131
|
const aVal = getValue(a, keys[i]);
|