xref: /expo/packages/@expo/fingerprint/build/Sort.js (revision 5697f03e)
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.sortSources = void 0;
4function sortSources(sources) {
5    const typeOrder = {
6        file: 0,
7        dir: 1,
8        contents: 2,
9    };
10    return sources.sort((a, b) => {
11        const typeResult = typeOrder[a.type] - typeOrder[b.type];
12        if (typeResult === 0) {
13            if (a.type === 'file' && b.type === 'file') {
14                return a.filePath.localeCompare(b.filePath);
15            }
16            else if (a.type === 'dir' && b.type === 'dir') {
17                return a.filePath.localeCompare(b.filePath);
18            }
19            else if (a.type === 'contents' && b.type === 'contents') {
20                return a.id.localeCompare(b.id);
21            }
22        }
23        return typeResult;
24    });
25}
26exports.sortSources = sortSources;
27//# sourceMappingURL=Sort.js.map