1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.unique = unique;
|
7 | exports.objectSortedEntries = objectSortedEntries;
|
8 | exports.objectSortedEntriesDeep = objectSortedEntriesDeep;
|
9 |
|
10 | function unique(array) {
|
11 | return [...new Set(array)];
|
12 | }
|
13 |
|
14 | function objectSortedEntries(obj) {
|
15 | return Object.entries(obj).sort(([keyA], [keyB]) => keyA.localeCompare(keyB));
|
16 | }
|
17 |
|
18 | function objectSortedEntriesDeep(object) {
|
19 | let sortedEntries = objectSortedEntries(object);
|
20 |
|
21 | for (let i = 0; i < sortedEntries.length; i++) {
|
22 | sortedEntries[i][1] = sortEntry(sortedEntries[i][1]);
|
23 | }
|
24 |
|
25 | return sortedEntries;
|
26 | }
|
27 |
|
28 | function sortEntry(entry) {
|
29 | if (Array.isArray(entry)) {
|
30 | return entry.map(sortEntry);
|
31 | }
|
32 |
|
33 | if (typeof entry === 'object' && entry != null) {
|
34 | return objectSortedEntriesDeep(entry);
|
35 | }
|
36 |
|
37 | return entry;
|
38 | } |
\ | No newline at end of file |