Issue.js
2.06 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var IssueSeverity_1 = require("./IssueSeverity");
var IssueOrigin_1 = require("./IssueOrigin");
function isIssue(value) {
return (!!value &&
typeof value === 'object' &&
IssueOrigin_1.isIssueOrigin(value.origin) &&
IssueSeverity_1.isIssueSeverity(value.severity) &&
!!value.code &&
!!value.message);
}
exports.isIssue = isIssue;
function compareOptionalStrings(stringA, stringB) {
if (stringA === stringB) {
return 0;
}
if (stringA === undefined || stringA === null) {
return -1;
}
if (stringB === undefined || stringB === null) {
return 1;
}
return stringA.toString().localeCompare(stringB.toString());
}
function compareNumbers(numberA, numberB) {
if (numberA === numberB) {
return 0;
}
if (numberA === undefined || numberA === null) {
return -1;
}
if (numberB === undefined || numberB === null) {
return 1;
}
return Math.sign(numberA - numberB);
}
function compareIssues(issueA, issueB) {
return (IssueOrigin_1.compareIssueOrigins(issueA.origin, issueB.origin) ||
compareOptionalStrings(issueA.file, issueB.file) ||
IssueSeverity_1.compareIssueSeverities(issueA.severity, issueB.severity) ||
compareNumbers(issueA.line, issueB.line) ||
compareNumbers(issueA.character, issueB.character) ||
compareOptionalStrings(issueA.code, issueB.code) ||
compareOptionalStrings(issueA.message, issueB.message) ||
compareOptionalStrings(issueA.stack, issueB.stack) ||
0 /* EqualTo */);
}
function equalsIssues(issueA, issueB) {
return compareIssues(issueA, issueB) === 0;
}
function deduplicateAndSortIssues(issues) {
var sortedIssues = issues.filter(isIssue).sort(compareIssues);
return sortedIssues.filter(function (issue, index) {
return index === 0 || !equalsIssues(issue, sortedIssues[index - 1]);
});
}
exports.deduplicateAndSortIssues = deduplicateAndSortIssues;
//# sourceMappingURL=Issue.js.map