@@ -10,6 +10,7 @@ exports.formatArgs = formatArgs;
1010exports . save = save ;
1111exports . load = load ;
1212exports . useColors = useColors ;
13+ exports . hrtime = hrtimeInit ( ) ;
1314exports . storage = 'undefined' != typeof chrome
1415 && 'undefined' != typeof chrome . storage
1516 ? chrome . storage . local
@@ -80,20 +81,28 @@ exports.formatters.j = function(v) {
8081 * @api public
8182 */
8283
83- function formatArgs ( args ) {
84+ function formatArgs ( args , section ) {
8485 var useColors = this . useColors ;
8586
8687 args [ 0 ] = ( useColors ? '%c' : '' )
8788 + this . namespace
8889 + ( useColors ? ' %c' : ' ' )
90+ + ( section ? ( section . title + ( useColors ? ' %c' : ' ' ) ) : '' )
8991 + args [ 0 ]
9092 + ( useColors ? '%c ' : ' ' )
91- + '+' + exports . humanize ( this . diff ) ;
93+ + '+' + exports . humanize ( this . diff )
94+ + ( section && section . complete ? ( '%c (delta ' + ( useColors ? '%c+' : '+' ) + exports . humanize ( section . deltaTime ) + ( useColors ? '%c)' : ')' ) ) : '' ) ;
9295
9396 if ( ! useColors ) return ;
9497
9598 var c = 'color: ' + this . color ;
96- args . splice ( 1 , 0 , c , 'color: inherit' )
99+ var inherit = 'color: inherit' ;
100+
101+ if ( section ) {
102+ args . splice ( 1 , 0 , c , inherit + '; font-weight: bold' , 'font-weight: normal' ) ;
103+ } else {
104+ args . splice ( 1 , 0 , c , inherit ) ;
105+ }
97106
98107 // the final "%c" is somewhat tricky, because there could be other
99108 // arguments passed either before or after the %c, so we need to
@@ -110,7 +119,11 @@ function formatArgs(args) {
110119 }
111120 } ) ;
112121
113- args . splice ( lastC , 0 , c ) ;
122+ if ( section && section . complete ) {
123+ args . splice ( lastC - 2 , 0 , c , inherit , c , inherit ) ;
124+ } else {
125+ args . splice ( lastC , 0 , c ) ;
126+ }
114127}
115128
116129/**
@@ -166,6 +179,22 @@ function load() {
166179 return r ;
167180}
168181
182+ /**
183+ * Browser implementation of hrtime().
184+ *
185+ * Follows the spec outlined in debug.begin() (see debug.js).
186+ *
187+ * If the browser has support for `window.performance.now()`,
188+ * then it is used. Otherwise, it falls back to `Date.now()`.
189+ */
190+ function hrtimeInit ( ) {
191+ var nowfn = window && window . performance && window . performance . now ? window . performance . now . bind ( window . performance ) : Date . now ;
192+ return function ( prev ) {
193+ var now = nowfn ( ) ;
194+ return prev ? ( now - prev ) : now ;
195+ } ;
196+ }
197+
169198/**
170199 * Enable namespaces listed in `localStorage.debug` initially.
171200 */
0 commit comments