77 * Expose `debug()` as the module.
88 */
99
10- exports = module . exports = debug ;
10+ exports = module . exports = debug . debug = debug ;
1111exports . coerce = coerce ;
1212exports . disable = disable ;
1313exports . enable = enable ;
@@ -238,6 +238,8 @@ module.exports = function(val, options){
238238 */
239239
240240function parse ( str ) {
241+ str = '' + str ;
242+ if ( str . length > 10000 ) return ;
241243 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 ) ;
242244 if ( ! match ) return ;
243245 var n = parseFloat ( match [ 1 ] ) ;
@@ -336,17 +338,10 @@ exports.formatArgs = formatArgs;
336338exports . save = save ;
337339exports . load = load ;
338340exports . 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 ( ) ;
350345
351346/**
352347 * Colors.
@@ -454,9 +449,9 @@ function log() {
454449function save ( namespaces ) {
455450 try {
456451 if ( null == namespaces ) {
457- storage . removeItem ( 'debug' ) ;
452+ exports . storage . removeItem ( 'debug' ) ;
458453 } else {
459- storage . debug = namespaces ;
454+ exports . storage . debug = namespaces ;
460455 }
461456 } catch ( e ) { }
462457}
@@ -471,7 +466,7 @@ function save(namespaces) {
471466function load ( ) {
472467 var r ;
473468 try {
474- r = storage . debug ;
469+ r = exports . storage . debug ;
475470 } catch ( e ) { }
476471 return r ;
477472}
0 commit comments