shelving 1.47.1 → 1.47.2
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/package.json +1 -1
- package/util/sort.d.ts +4 -4
- package/util/sort.js +7 -7
package/package.json
CHANGED
package/util/sort.d.ts
CHANGED
|
@@ -32,13 +32,13 @@ export declare function rankAsc(left: unknown, right: unknown): number;
|
|
|
32
32
|
/** Rank two values in descending order. */
|
|
33
33
|
export declare const rankDesc: (left: unknown, right: unknown) => number;
|
|
34
34
|
/** Rank the keys of two entries in ascending order. */
|
|
35
|
-
export declare const
|
|
35
|
+
export declare const rankKeyAsc: ([l]: Entry<unknown>, [r]: Entry<unknown>) => number;
|
|
36
36
|
/** Rank the keys of two entries in descending order. */
|
|
37
|
-
export declare const
|
|
37
|
+
export declare const rankKeyDesc: ([l]: Entry<unknown>, [r]: Entry<unknown>) => number;
|
|
38
38
|
/** Rank the values of two entries in ascending order. */
|
|
39
|
-
export declare const
|
|
39
|
+
export declare const rankValueAsc: ([, l]: Entry<unknown>, [, r]: Entry<unknown>) => number;
|
|
40
40
|
/** Rank the values of two entries in descending order. */
|
|
41
|
-
export declare const
|
|
41
|
+
export declare const rankValueDesc: ([, l]: Entry<unknown>, [, r]: Entry<unknown>) => number;
|
|
42
42
|
/** Sort an iterable set of items using a ranker (defaults to sorting in ascending order). */
|
|
43
43
|
export declare function sortItems<T>(input: Iterable<T>, ranker?: Ranker<T>): ImmutableArray<T>;
|
|
44
44
|
/** Sort an array using a ranker (defaults to sorting in ascending order) */
|
package/util/sort.js
CHANGED
|
@@ -75,13 +75,13 @@ export function rankAsc(left, right) {
|
|
|
75
75
|
/** Rank two values in descending order. */
|
|
76
76
|
export const rankDesc = (left, right) => 0 - rankAsc(left, right);
|
|
77
77
|
/** Rank the keys of two entries in ascending order. */
|
|
78
|
-
export const
|
|
78
|
+
export const rankKeyAsc = ([l], [r]) => rankAsc(l, r);
|
|
79
79
|
/** Rank the keys of two entries in descending order. */
|
|
80
|
-
export const
|
|
80
|
+
export const rankKeyDesc = ([l], [r]) => rankDesc(l, r);
|
|
81
81
|
/** Rank the values of two entries in ascending order. */
|
|
82
|
-
export const
|
|
82
|
+
export const rankValueAsc = ([, l], [, r]) => rankAsc(l, r);
|
|
83
83
|
/** Rank the values of two entries in descending order. */
|
|
84
|
-
export const
|
|
84
|
+
export const rankValueDesc = ([, l], [, r]) => rankDesc(l, r);
|
|
85
85
|
/**
|
|
86
86
|
* Quick sort algorithm.
|
|
87
87
|
* DH: We implement our own sorting algorithm so that:
|
|
@@ -144,18 +144,18 @@ export function sortArray(input, ranker = rankAsc) {
|
|
|
144
144
|
* Sort an iterable set of entries (defaults to sorting by key in ascending order).
|
|
145
145
|
* - Always returns an array
|
|
146
146
|
*/
|
|
147
|
-
export function sortEntries(input, ranker =
|
|
147
|
+
export function sortEntries(input, ranker = rankKeyAsc) {
|
|
148
148
|
const array = Array.from(input);
|
|
149
149
|
_quicksort(array, ranker);
|
|
150
150
|
return array;
|
|
151
151
|
}
|
|
152
152
|
/** Sort a map-like object using a ranker (defaults to sorting by key in ascending order). */
|
|
153
|
-
export function sortObject(input, ranker =
|
|
153
|
+
export function sortObject(input, ranker = rankKeyAsc) {
|
|
154
154
|
const array = Object.entries(input);
|
|
155
155
|
return _quicksort(array, ranker) ? Object.fromEntries(array) : input;
|
|
156
156
|
}
|
|
157
157
|
/** Sort a map using a ranker (defaults to sorting by key in ascending order). */
|
|
158
|
-
export function sortMap(input, ranker =
|
|
158
|
+
export function sortMap(input, ranker = rankKeyAsc) {
|
|
159
159
|
const array = Array.from(input);
|
|
160
160
|
return _quicksort(array, ranker) ? new Map(array) : input;
|
|
161
161
|
}
|