Skip to content

Commit 424a0ae

Browse files
committed
the first "if" part always gets override by the default, is that intended @sokra?
1 parent bd386ec commit 424a0ae

1 file changed

Lines changed: 2 additions & 15 deletions

File tree

lib/Stats.js

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,30 +81,17 @@ class Stats {
8181
};
8282

8383
const sortByField = (field) => {
84-
let callback;
8584
if(!field) {
86-
callback = () => 0;
87-
return callback;
85+
return () => 0;
8886
}
8987

90-
if(field[0] === "!") {
91-
field = field.substr(1);
92-
callback = (a, b) => {
93-
if(a[field] === null && b[field] === null) return 0;
94-
if(a[field] === null) return 1;
95-
if(b[field] === null) return -1;
96-
if(a[field] === b[field]) return 0;
97-
return a[field] < b[field] ? 1 : -1;
98-
};
99-
}
100-
callback = (a, b) => {
88+
return (a, b) => {
10189
if(a[field] === null && b[field] === null) return 0;
10290
if(a[field] === null) return 1;
10391
if(b[field] === null) return -1;
10492
if(a[field] === b[field]) return 0;
10593
return a[field] < b[field] ? -1 : 1;
10694
};
107-
return callback;
10895
};
10996

11097
const formatError = (e) => {

0 commit comments

Comments
 (0)