7
7
* Expose `debug()` as the module.
8
8
*/
9
9
10
- exports = module . exports = debug ;
10
+ exports = module . exports = debug . debug = debug ;
11
11
exports . coerce = coerce ;
12
12
exports . disable = disable ;
13
13
exports . enable = enable ;
@@ -238,6 +238,8 @@ module.exports = function(val, options){
238
238
*/
239
239
240
240
function parse ( str ) {
241
+ str = '' + str ;
242
+ if ( str . length > 10000 ) return ;
241
243
var match = / ^ ( (?: \d + ) ? \. ? \d + ) * ( m i l l i s e c o n d s ? | m s e c s ? | m s | s e c o n d s ? | s e c s ? | s | m i n u t e s ? | m i n s ? | m | h o u r s ? | h r s ? | h | d a y s ? | d | y e a r s ? | y r s ? | y ) ? $ / i. exec ( str ) ;
242
244
if ( ! match ) return ;
243
245
var n = parseFloat ( match [ 1 ] ) ;
@@ -336,17 +338,10 @@ exports.formatArgs = formatArgs;
336
338
exports . save = save ;
337
339
exports . load = load ;
338
340
exports . useColors = useColors ;
339
-
340
- /**
341
- * Use chrome.storage.local if we are in an app
342
- */
343
-
344
- var storage ;
345
-
346
- if ( typeof chrome !== 'undefined' && typeof chrome . storage !== 'undefined' )
347
- storage = chrome . storage . local ;
348
- else
349
- storage = localstorage ( ) ;
341
+ exports . storage = 'undefined' != typeof chrome
342
+ && 'undefined' != typeof chrome . storage
343
+ ? chrome . storage . local
344
+ : localstorage ( ) ;
350
345
351
346
/**
352
347
* Colors.
@@ -454,9 +449,9 @@ function log() {
454
449
function save ( namespaces ) {
455
450
try {
456
451
if ( null == namespaces ) {
457
- storage . removeItem ( 'debug' ) ;
452
+ exports . storage . removeItem ( 'debug' ) ;
458
453
} else {
459
- storage . debug = namespaces ;
454
+ exports . storage . debug = namespaces ;
460
455
}
461
456
} catch ( e ) { }
462
457
}
@@ -471,7 +466,7 @@ function save(namespaces) {
471
466
function load ( ) {
472
467
var r ;
473
468
try {
474
- r = storage . debug ;
469
+ r = exports . storage . debug ;
475
470
} catch ( e ) { }
476
471
return r ;
477
472
}
0 commit comments