Skip to content

Commit b40ea1d

Browse files
Flow.js : added flow notation for sort.js
1 parent f1042fc commit b40ea1d

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/sort.js

+6-10
Original file line numberDiff line numberDiff line change
@@ -94,25 +94,21 @@ module.exports = function sortDocs(comments: Array<Comment>, options: Object) {
9494
return fixed.concat(unfixed);
9595
};
9696

97-
function compare(a: string, b: string) {
98-
return a.localeCompare(b, undefined, { caseFirst: 'upper' });
99-
}
100-
101-
function compareCommentsByName(a, b) {
102-
var akey = a.name;
103-
var bkey = b.name;
97+
function compareCommentsByName(a: Comment, b: Comment): number {
98+
const akey: ?string = a.name;
99+
const bkey: ?string = b.name;
104100

105101
if (akey && bkey) {
106-
return compare(akey, bkey);
102+
return akey.localeCompare(bkey, undefined, { caseFirst: 'upper' });
107103
}
108104
return 0;
109105
}
110106

111-
function compareCommentsBySourceLocation(a, b) {
107+
function compareCommentsBySourceLocation(a: Comment, b: Comment): number {
112108
return a.context.sortKey.localeCompare(b.context.sortKey);
113109
}
114110

115-
function sortComments(comments, sortOrder) {
111+
function sortComments(comments: Array<Comment>, sortOrder: string) {
116112
return comments.sort(
117113
sortOrder === 'alpha'
118114
? compareCommentsByName

0 commit comments

Comments
 (0)