Skip to content

Commit a72eab8

Browse files
committed
change sortByField to prevent deadlock
- returning a function fails the linter as it wants `return()=>` without space - removing the space fails eslint
1 parent 8e7022b commit a72eab8

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

lib/Stats.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,16 @@ class Stats {
8080
};
8181
};
8282

83-
const sortByField = (field) => {
83+
const sortByField = (field) => (a, b) => {
8484
if(!field) {
85-
return () => 0;
85+
return 0;
8686
}
8787

88-
return (a, b) => {
89-
if(a[field] === null && b[field] === null) return 0;
90-
if(a[field] === null) return 1;
91-
if(b[field] === null) return -1;
92-
if(a[field] === b[field]) return 0;
93-
return a[field] < b[field] ? -1 : 1;
94-
};
88+
if(a[field] === null && b[field] === null) return 0;
89+
if(a[field] === null) return 1;
90+
if(b[field] === null) return -1;
91+
if(a[field] === b[field]) return 0;
92+
return a[field] < b[field] ? -1 : 1;
9593
};
9694

9795
const formatError = (e) => {

0 commit comments

Comments
 (0)