|
3 | 3 | * @author Robin Thomas |
4 | 4 | */ |
5 | 5 |
|
6 | | -/** |
7 | | - * @typedef {import("@humanwhocodes/momoa").MemberNode} MemberNode |
8 | | - * @typedef {import("@humanwhocodes/momoa").ObjectNode} ObjectNode |
9 | | - * @typedef {(a: string, b:string) => boolean} Comparator |
10 | | - */ |
11 | | - |
12 | 6 | import naturalCompare from "natural-compare"; |
13 | 7 |
|
14 | 8 | const comparators = { |
15 | 9 | ascending: { |
16 | 10 | alphanumeric: { |
17 | | - sensitive: /** @type {Comparator} **/ (a, b) => a <= b, |
18 | | - insensitive: /** @type {Comparator} **/ (a, b) => |
19 | | - a.toLowerCase() <= b.toLowerCase(), |
| 11 | + sensitive: (a, b) => a <= b, |
| 12 | + insensitive: (a, b) => a.toLowerCase() <= b.toLowerCase(), |
20 | 13 | }, |
21 | 14 | natural: { |
22 | | - sensitive: /** @type {Comparator} **/ (a, b) => |
23 | | - naturalCompare(a, b) <= 0, |
24 | | - insensitive: /** @type {Comparator} **/ (a, b) => |
| 15 | + sensitive: (a, b) => naturalCompare(a, b) <= 0, |
| 16 | + insensitive: (a, b) => |
25 | 17 | naturalCompare(a.toLowerCase(), b.toLowerCase()) <= 0, |
26 | 18 | }, |
27 | 19 | }, |
28 | 20 | descending: { |
29 | 21 | alphanumeric: { |
30 | | - sensitive: /** @type {Comparator} **/ (a, b) => |
| 22 | + sensitive: (a, b) => |
31 | 23 | comparators.ascending.alphanumeric.sensitive(b, a), |
32 | | - insensitive: /** @type {Comparator} **/ (a, b) => |
| 24 | + insensitive: (a, b) => |
33 | 25 | comparators.ascending.alphanumeric.insensitive(b, a), |
34 | 26 | }, |
35 | 27 | natural: { |
36 | | - sensitive: /** @type {Comparator} **/ (a, b) => |
37 | | - comparators.ascending.natural.sensitive(b, a), |
38 | | - insensitive: /** @type {Comparator} **/ (a, b) => |
| 28 | + sensitive: (a, b) => comparators.ascending.natural.sensitive(b, a), |
| 29 | + insensitive: (a, b) => |
39 | 30 | comparators.ascending.natural.insensitive(b, a), |
40 | 31 | }, |
41 | 32 | }, |
42 | 33 | }; |
43 | 34 |
|
44 | | -/** |
45 | | - * @param {MemberNode} member |
46 | | - */ |
47 | 35 | function getKey(member) { |
48 | 36 | return member.name.type === `Identifier` |
49 | 37 | ? member.name.name |
@@ -118,9 +106,6 @@ export default { |
118 | 106 | } |
119 | 107 |
|
120 | 108 | return { |
121 | | - /** |
122 | | - * @param {ObjectNode} node |
123 | | - */ |
124 | 109 | Object(node) { |
125 | 110 | let prevMember; |
126 | 111 | let prevName; |
|
0 commit comments