2a09d1a4
liuqimichale
添加宜春 天水 宣化
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
module.exports = function compareLocations(a, b) {
if(typeof a === "string") {
if(typeof b === "string") {
if(a < b) return -1;
if(a > b) return 1;
return 0;
} else if(typeof b === "object") {
return 1;
} else {
return 0;
}
} else if(typeof a === "object") {
if(typeof b === "string") {
return -1;
} else if(typeof b === "object") {
if(a.start && b.start) {
const ap = a.start;
const bp = b.start;
if(ap.line < bp.line) return -1;
if(ap.line > bp.line) return 1;
if(ap.column < bp.column) return -1;
if(ap.column > bp.column) return 1;
}
if(a.index < b.index) return -1;
if(a.index > b.index) return 1;
return 0;
} else {
return 0;
}
}
};
|