@@ -4903,6 +4903,16 @@ exports.save = save;
49034903exports . load = load ;
49044904exports . useColors = useColors ;
49054905exports . storage = localstorage ( ) ;
4906+ exports . destroy = ( ( ) => {
4907+ let warned = false ;
4908+
4909+ return ( ) => {
4910+ if ( ! warned ) {
4911+ warned = true ;
4912+ console . warn ( 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.' ) ;
4913+ }
4914+ } ;
4915+ } ) ( ) ;
49064916
49074917/**
49084918 * Colors.
@@ -5172,16 +5182,12 @@ function setup(env) {
51725182 createDebug . enable = enable ;
51735183 createDebug . enabled = enabled ;
51745184 createDebug . humanize = __webpack_require__ ( 4377 ) ;
5185+ createDebug . destroy = destroy ;
51755186
51765187 Object . keys ( env ) . forEach ( key => {
51775188 createDebug [ key ] = env [ key ] ;
51785189 } ) ;
51795190
5180- /**
5181- * Active `debug` instances.
5182- */
5183- createDebug . instances = [ ] ;
5184-
51855191 /**
51865192 * The currently active debug mode names, and names to skip.
51875193 */
@@ -5223,6 +5229,7 @@ function setup(env) {
52235229 */
52245230 function createDebug ( namespace ) {
52255231 let prevTime ;
5232+ let enableOverride = null ;
52265233
52275234 function debug ( ...args ) {
52285235 // Disabled?
@@ -5252,7 +5259,7 @@ function setup(env) {
52525259 args [ 0 ] = args [ 0 ] . replace ( / % ( [ a - z A - Z % ] ) / g, ( match , format ) => {
52535260 // If we encounter an escaped % then don't increase the array index
52545261 if ( match === '%%' ) {
5255- return match ;
5262+ return '%' ;
52565263 }
52575264 index ++ ;
52585265 const formatter = createDebug . formatters [ format ] ;
@@ -5275,31 +5282,28 @@ function setup(env) {
52755282 }
52765283
52775284 debug . namespace = namespace ;
5278- debug . enabled = createDebug . enabled ( namespace ) ;
52795285 debug . useColors = createDebug . useColors ( ) ;
52805286 debug . color = createDebug . selectColor ( namespace ) ;
5281- debug . destroy = destroy ;
52825287 debug . extend = extend ;
5288+ debug . destroy = createDebug . destroy ; // XXX Temporary. Will be removed in the next major release.
5289+
5290+ Object . defineProperty ( debug , 'enabled' , {
5291+ enumerable : true ,
5292+ configurable : false ,
5293+ get : ( ) => enableOverride === null ? createDebug . enabled ( namespace ) : enableOverride ,
5294+ set : v => {
5295+ enableOverride = v ;
5296+ }
5297+ } ) ;
52835298
52845299 // Env-specific initialization logic for debug instances
52855300 if ( typeof createDebug . init === 'function' ) {
52865301 createDebug . init ( debug ) ;
52875302 }
52885303
5289- createDebug . instances . push ( debug ) ;
5290-
52915304 return debug ;
52925305 }
52935306
5294- function destroy ( ) {
5295- const index = createDebug . instances . indexOf ( this ) ;
5296- if ( index !== - 1 ) {
5297- createDebug . instances . splice ( index , 1 ) ;
5298- return true ;
5299- }
5300- return false ;
5301- }
5302-
53035307 function extend ( namespace , delimiter ) {
53045308 const newDebug = createDebug ( this . namespace + ( typeof delimiter === 'undefined' ? ':' : delimiter ) + namespace ) ;
53055309 newDebug . log = this . log ;
@@ -5337,11 +5341,6 @@ function setup(env) {
53375341 createDebug . names . push ( new RegExp ( '^' + namespaces + '$' ) ) ;
53385342 }
53395343 }
5340-
5341- for ( i = 0 ; i < createDebug . instances . length ; i ++ ) {
5342- const instance = createDebug . instances [ i ] ;
5343- instance . enabled = createDebug . enabled ( instance . namespace ) ;
5344- }
53455344 }
53465345
53475346 /**
@@ -5416,6 +5415,14 @@ function setup(env) {
54165415 return val ;
54175416 }
54185417
5418+ /**
5419+ * XXX DO NOT USE. This is a temporary stub function.
5420+ * XXX It WILL be removed in the next major release.
5421+ */
5422+ function destroy ( ) {
5423+ console . warn ( 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.' ) ;
5424+ }
5425+
54195426 createDebug . enable ( createDebug . load ( ) ) ;
54205427
54215428 return createDebug ;
@@ -5463,6 +5470,10 @@ exports.formatArgs = formatArgs;
54635470exports . save = save ;
54645471exports . load = load ;
54655472exports . useColors = useColors ;
5473+ exports . destroy = util . deprecate (
5474+ ( ) => { } ,
5475+ 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
5476+ ) ;
54665477
54675478/**
54685479 * Colors.
@@ -5692,7 +5703,9 @@ const {formatters} = module.exports;
56925703formatters . o = function ( v ) {
56935704 this . inspectOpts . colors = this . useColors ;
56945705 return util . inspect ( v , this . inspectOpts )
5695- . replace ( / \s * \n \s * / g, ' ' ) ;
5706+ . split ( '\n' )
5707+ . map ( str => str . trim ( ) )
5708+ . join ( ' ' ) ;
56965709} ;
56975710
56985711/**
0 commit comments