File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,6 +24,13 @@ class Stats {
2424 return this . compilation . errors . length > 0 ;
2525 }
2626
27+ normalizeFieldKey ( field ) {
28+ if ( field [ 0 ] === "!" ) {
29+ return field . substr ( 1 ) ;
30+ }
31+ return field ;
32+ }
33+
2734 toJson ( options , forToString ) {
2835 if ( typeof options === "boolean" || typeof options === "string" ) {
2936 options = Stats . presetToOptions ( options ) ;
@@ -85,11 +92,13 @@ class Stats {
8592 return 0 ;
8693 }
8794
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 ;
95+ const fieldKey = this . normalizeFieldKey ( field ) ;
96+
97+ if ( a [ fieldKey ] === null && b [ fieldKey ] === null ) return 0 ;
98+ if ( a [ fieldKey ] === null ) return 1 ;
99+ if ( b [ fieldKey ] === null ) return - 1 ;
100+ if ( a [ fieldKey ] === b [ fieldKey ] ) return 0 ;
101+ return a [ fieldKey ] < b [ fieldKey ] ? - 1 : 1 ;
93102 } ;
94103
95104 const formatError = ( e ) => {
You can’t perform that action at this time.
0 commit comments