From 6830d9fbeeebdf46700b6ad0426f36d009114c7e Mon Sep 17 00:00:00 2001 From: Jovan Alleyne Date: Wed, 8 Apr 2015 15:25:48 -0400 Subject: [PATCH 001/257] Catch JSON stringily errors. There is a chance that there may be circular references in the Object which will cause the debug message to throw an exception. If the exception is not handled on the application level this will cause node to crash. As a debug library, errors in here should not have such a serious impact on the application. --- browser.js | 6 +++++- dist/debug.js | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/browser.js b/browser.js index 55f4cf92..ab495871 100644 --- a/browser.js +++ b/browser.js @@ -59,7 +59,11 @@ function useColors() { */ exports.formatters.j = function(v) { - return JSON.stringify(v); + try { + return JSON.stringify(v); + }catch( err){ + return '[UnexpectedJSONParseError]: ' + err.message; + } }; diff --git a/dist/debug.js b/dist/debug.js index 97d6f787..e6732b86 100644 --- a/dist/debug.js +++ b/dist/debug.js @@ -384,7 +384,11 @@ function useColors() { */ exports.formatters.j = function(v) { - return JSON.stringify(v); + try { + return JSON.stringify(v); + }catch( err){ + return '[UnexpectedJSONParseError]: ' + err.message; + } }; From 1c6ae9c035d83bdbe8bfb57103c8c26cea967941 Mon Sep 17 00:00:00 2001 From: Sergey Nuzdhin Date: Mon, 28 Sep 2015 14:22:55 +0200 Subject: [PATCH 002/257] Add LICENSE file --- LICENSE | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..658c933d --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +(The MIT License) + +Copyright (c) 2014 TJ Holowaychuk + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the 'Software'), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial +portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT +LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + From 3fac2324cdbef3f620573873ca9df5d25c126090 Mon Sep 17 00:00:00 2001 From: Matt Lyons Date: Thu, 15 Oct 2015 17:15:23 -0700 Subject: [PATCH 003/257] Extend documentation on DEBUG_FD and DEBUG_COLORS Move 'stderr vs stdout' and 'Save debug output to a file' to their own heading. Fix #205 --- Readme.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index cd9d61b9..03f48311 100644 --- a/Readme.md +++ b/Readme.md @@ -114,10 +114,14 @@ setInterval(function(){ Colored output looks something like: ![](https://cloud.githubusercontent.com/assets/71256/3139768/b98c5fd8-e8ef-11e3-862a-f7253b6f47c6.png) + +## Output streams + ### stderr vs stdout - -You can set an alternative logging method per-namespace by overriding the `log` method on a per-namespace or globally: + By default `debug` will log to stderr, however this can be changed by setting the environment variable `DEBUG_FD` to `1` for stdout and `2` for stderr (the default value). + +You can also set an alternative logging method per-namespace by overriding the `log` method on a per-namespace or globally: Example _stdout.js_: @@ -151,6 +155,12 @@ Example: $ DEBUG_FD=3 node your-app.js 3> whatever.log ``` +### Terminal colors + + By default colors will only be used in a TTY. However this can be overridden by setting the environment variable `USE_COLORS` to `1`. + + Note: Certain IDEs (such as WebStorm) don't support colors on stderr. In these cases you must set `USE_COLORS` to `1` and additionally change `DEBUG_FD` to `1`. + ## Authors - TJ Holowaychuk From 679cc151bdf7a1eb8a9a1ce66137984baf880cc7 Mon Sep 17 00:00:00 2001 From: unreadable Date: Thu, 17 Dec 2015 01:00:25 +0200 Subject: [PATCH 004/257] Add a note for PowerShell users. --- Readme.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Readme.md b/Readme.md index cd9d61b9..bae742d4 100644 --- a/Readme.md +++ b/Readme.md @@ -58,6 +58,12 @@ setInterval(function(){ ```cmd set DEBUG=*,-not_this ``` + + Note that PowerShell using different syntax to set environment variables. + + ```cmd + $env:DEBUG = "DEBUG=*,-not_this" + ``` Then, run the program to be debugged as usual. From 82ca12f2982ade24329cad235cf3be533b6bf379 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Wed, 13 Jan 2016 12:22:04 -0800 Subject: [PATCH 005/257] dist: recompile --- dist/debug.js | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/dist/debug.js b/dist/debug.js index 97d6f787..4808b249 100644 --- a/dist/debug.js +++ b/dist/debug.js @@ -7,7 +7,7 @@ * Expose `debug()` as the module. */ -exports = module.exports = debug; +exports = module.exports = debug.debug = debug; exports.coerce = coerce; exports.disable = disable; exports.enable = enable; @@ -238,6 +238,8 @@ module.exports = function(val, options){ */ function parse(str) { + str = '' + str; + if (str.length > 10000) return; var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str); if (!match) return; var n = parseFloat(match[1]); @@ -336,17 +338,10 @@ exports.formatArgs = formatArgs; exports.save = save; exports.load = load; exports.useColors = useColors; - -/** - * Use chrome.storage.local if we are in an app - */ - -var storage; - -if (typeof chrome !== 'undefined' && typeof chrome.storage !== 'undefined') - storage = chrome.storage.local; -else - storage = localstorage(); +exports.storage = 'undefined' != typeof chrome + && 'undefined' != typeof chrome.storage + ? chrome.storage.local + : localstorage(); /** * Colors. @@ -454,9 +449,9 @@ function log() { function save(namespaces) { try { if (null == namespaces) { - storage.removeItem('debug'); + exports.storage.removeItem('debug'); } else { - storage.debug = namespaces; + exports.storage.debug = namespaces; } } catch(e) {} } @@ -471,7 +466,7 @@ function save(namespaces) { function load() { var r; try { - r = storage.debug; + r = exports.storage.debug; } catch(e) {} return r; } From 8dd8345d1498b8c6a3c6d7f7f4ebc600cfd2195b Mon Sep 17 00:00:00 2001 From: Joe Ibershoff Date: Thu, 14 Jan 2016 19:48:55 -0500 Subject: [PATCH 006/257] handle regex special characters --- debug.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debug.js b/debug.js index a21c0930..b475edcf 100644 --- a/debug.js +++ b/debug.js @@ -141,7 +141,7 @@ function enable(namespaces) { for (var i = 0; i < len; i++) { if (!split[i]) continue; // ignore empty strings - namespaces = split[i].replace(/\*/g, '.*?'); + namespaces = split[i].replace(/[\\^$+?.()|[\]{}]/g, '\\$&').replace(/\*/g, '.*?'); if (namespaces[0] === '-') { exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); } else { From 75dc1d5e26c6a27d9230d96d221078cd70993c94 Mon Sep 17 00:00:00 2001 From: Gabriel Imre Date: Mon, 18 Jan 2016 14:26:07 +0200 Subject: [PATCH 007/257] Corrected PowerShell environment variable example --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index bae742d4..e718f5be 100644 --- a/Readme.md +++ b/Readme.md @@ -62,7 +62,7 @@ setInterval(function(){ Note that PowerShell using different syntax to set environment variables. ```cmd - $env:DEBUG = "DEBUG=*,-not_this" + $env:DEBUG = "*,-not_this" ``` Then, run the program to be debugged as usual. From 735919b525c2713204d949f4cbfe28bcf0f2598e Mon Sep 17 00:00:00 2001 From: mlucool Date: Tue, 8 Mar 2016 20:47:45 -0500 Subject: [PATCH 008/257] Make the format string goodies clearer in README --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index bae742d4..3a2540f3 100644 --- a/Readme.md +++ b/Readme.md @@ -10,7 +10,7 @@ $ npm install debug ## Usage - With `debug` you simply invoke the exported function to generate your debug function, passing it a name which will determine if a noop function is returned, or a decorated `console.error`, so all of the `console` format string goodies you're used to work fine. A unique color is selected per-function for visibility. + With `debug` you simply invoke the exported function to generate your debug function, passing it a name which will determine if a noop function is returned, or a decorated `console.error`, so all of the `console` [format string goodies](https://developer.chrome.com/devtools/docs/console-api#consolelogobject-object) you're used to work fine. A unique color is selected per-function for visibility. Example _app.js_: From 01b30d759e4ff96265591c14be6d792c430885ea Mon Sep 17 00:00:00 2001 From: exoticknight Date: Fri, 11 Mar 2016 20:03:49 +0800 Subject: [PATCH 009/257] fix PowerShell set in readme.me --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index bae742d4..e718f5be 100644 --- a/Readme.md +++ b/Readme.md @@ -62,7 +62,7 @@ setInterval(function(){ Note that PowerShell using different syntax to set environment variables. ```cmd - $env:DEBUG = "DEBUG=*,-not_this" + $env:DEBUG = "*,-not_this" ``` Then, run the program to be debugged as usual. From dec66b8a30efbab4423262b0e4ae71fc34d3ef5f Mon Sep 17 00:00:00 2001 From: Sam D Date: Sat, 30 Apr 2016 19:16:51 -0400 Subject: [PATCH 010/257] updates license date --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index e718f5be..4ec39ea3 100644 --- a/Readme.md +++ b/Readme.md @@ -166,7 +166,7 @@ $ DEBUG_FD=3 node your-app.js 3> whatever.log (The MIT License) -Copyright (c) 2014 TJ Holowaychuk <tj@vision-media.ca> +Copyright (c) 2016 TJ Holowaychuk <tj@vision-media.ca> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the From 7748e508f1cc11c9e9aa0978bb6c3d2bc99deb92 Mon Sep 17 00:00:00 2001 From: Thomas Parisot Date: Tue, 10 May 2016 20:55:19 +0100 Subject: [PATCH 011/257] Add %O formatter to reflect Chrome's console.log capability refs #278 --- node.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node.js b/node.js index 1d392a81..774501c5 100644 --- a/node.js +++ b/node.js @@ -68,7 +68,7 @@ var inspect = (4 === util.inspect.length ? } ); -exports.formatters.o = function(v) { +exports.formatters.o = exports.formatters.O = function(v) { return inspect(v, this.useColors) .replace(/\s*\n\s*/g, ' '); }; From d39abeda93da6bee011ffce7e902a466f67616a7 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Thu, 26 May 2016 07:38:16 -0700 Subject: [PATCH 012/257] fix(browser): remove variable thats undefined in react-native https://github.com/facebook/react-native/pull/1632 --- browser.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/browser.js b/browser.js index 7c764522..a31d6ff3 100644 --- a/browser.js +++ b/browser.js @@ -39,7 +39,8 @@ exports.colors = [ function useColors() { // is webkit? http://stackoverflow.com/a/16459606/376773 - return ('WebkitAppearance' in document.documentElement.style) || + // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 + return (typeof document !== 'undefined' && 'WebkitAppearance' in document.documentElement.style) || // is firebug? http://stackoverflow.com/a/398120/376773 (window.console && (console.firebug || (console.exception && console.table))) || // is firefox >= v31? From a4e36a821b4c34ce147628a9568de3471f6222e9 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Sat, 22 Oct 2016 12:15:52 -0700 Subject: [PATCH 013/257] Readme: fix USE_COLORS to DEBUG_COLORS Also remove trailing whitespace --- Readme.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Readme.md b/Readme.md index 487832bc..04d4e673 100644 --- a/Readme.md +++ b/Readme.md @@ -58,9 +58,9 @@ setInterval(function(){ ```cmd set DEBUG=*,-not_this ``` - + Note that PowerShell using different syntax to set environment variables. - + ```cmd $env:DEBUG = "*,-not_this" ``` @@ -120,13 +120,13 @@ setInterval(function(){ Colored output looks something like: ![](https://cloud.githubusercontent.com/assets/71256/3139768/b98c5fd8-e8ef-11e3-862a-f7253b6f47c6.png) - + ## Output streams - + ### stderr vs stdout By default `debug` will log to stderr, however this can be changed by setting the environment variable `DEBUG_FD` to `1` for stdout and `2` for stderr (the default value). - + You can also set an alternative logging method per-namespace by overriding the `log` method on a per-namespace or globally: Example _stdout.js_: @@ -163,10 +163,10 @@ $ DEBUG_FD=3 node your-app.js 3> whatever.log ### Terminal colors - By default colors will only be used in a TTY. However this can be overridden by setting the environment variable `USE_COLORS` to `1`. - - Note: Certain IDEs (such as WebStorm) don't support colors on stderr. In these cases you must set `USE_COLORS` to `1` and additionally change `DEBUG_FD` to `1`. - + By default colors will only be used in a TTY. However this can be overridden by setting the environment variable `DEBUG_COLORS` to `1`. + + Note: Certain IDEs (such as WebStorm) don't support colors on stderr. In these cases you must set `DEBUG_COLORS` to `1` and additionally change `DEBUG_FD` to `1`. + ## Authors - TJ Holowaychuk From e8fe71b473632420e04a4b0c046b4a950fa002d6 Mon Sep 17 00:00:00 2001 From: DevSide Date: Tue, 25 Oct 2016 14:46:30 +0200 Subject: [PATCH 014/257] Bump ms 0.7.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b9f033a7..c3e2ab0a 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ ], "license": "MIT", "dependencies": { - "ms": "0.7.1" + "ms": "0.7.2" }, "devDependencies": { "browserify": "9.0.3", From dafc16e7b3400df50714440d22b15f0f4dfc2108 Mon Sep 17 00:00:00 2001 From: Goran Gajic Date: Tue, 25 Aug 2015 15:39:30 +0200 Subject: [PATCH 015/257] move ms to the last place --- node.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/node.js b/node.js index 1d392a81..8a98e202 100644 --- a/node.js +++ b/node.js @@ -80,17 +80,21 @@ exports.formatters.o = function(v) { */ function formatArgs() { - var args = arguments; + var args = []; + var len = arguments.length; var useColors = this.useColors; var name = this.namespace; + for (var i = 0; i < len; i++) { + args.push(arguments[i]); + } if (useColors) { var c = this.color; args[0] = ' \u001b[3' + c + ';1m' + name + ' ' + '\u001b[0m' - + args[0] + '\u001b[3' + c + 'm' - + ' +' + exports.humanize(this.diff) + '\u001b[0m'; + + args[0]; + args.push('\u001b[3' + c + 'm+' + exports.humanize(this.diff) + '\u001b[0m'); } else { args[0] = new Date().toUTCString() + ' ' + name + ' ' + args[0]; From 2b78d425cc80d303bdaf2a0679794976c4e4108c Mon Sep 17 00:00:00 2001 From: Sam D Date: Thu, 27 Oct 2016 07:54:20 -0400 Subject: [PATCH 016/257] hyphenates license years --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 4ec39ea3..a55eeb8c 100644 --- a/Readme.md +++ b/Readme.md @@ -166,7 +166,7 @@ $ DEBUG_FD=3 node your-app.js 3> whatever.log (The MIT License) -Copyright (c) 2016 TJ Holowaychuk <tj@vision-media.ca> +Copyright (c) 2014-2016 TJ Holowaychuk <tj@vision-media.ca> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the From 5b1e1dac0f71ddb82842ae2f584be0a4c55687a1 Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Thu, 27 Oct 2016 09:47:12 -0700 Subject: [PATCH 017/257] added yarn lockfile for yarn support --- yarn.lock | 977 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 977 insertions(+) create mode 100644 yarn.lock diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 00000000..49cea028 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,977 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 +acorn@^1.0.3: + version "1.2.2" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-1.2.2.tgz#c8ce27de0acc76d896d2b1fad3df588d9e82f014" + +acorn@^2.7.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-2.7.0.tgz#ab6e7d9d886aaca8b085bc3312b79a198433f0e7" + +acorn@^3.1.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a" + +amdefine@>=0.0.4: + version "1.0.0" + resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.0.tgz#fd17474700cb5cc9c2b709f0be9d23ce3c198c33" + +asn1.js@^4.0.0: + version "4.8.1" + resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-4.8.1.tgz#3949b7f5fd1e8bedc13be3abebf477f93490c810" + dependencies: + bn.js "^4.0.0" + inherits "^2.0.1" + minimalistic-assert "^1.0.0" + +assert@~1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/assert/-/assert-1.3.0.tgz#03939a622582a812cc202320a0b9a56c9b815849" + dependencies: + util "0.10.3" + +astw@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/astw/-/astw-2.0.0.tgz#08121ac8288d35611c0ceec663f6cd545604897d" + dependencies: + acorn "^1.0.3" + +balanced-match@^0.4.1: + version "0.4.2" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838" + +base64-js@0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-0.0.8.tgz#1101e9544f4a76b1bc3b26d452ca96d7a35e7978" + +Base64@~0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/Base64/-/Base64-0.2.1.tgz#ba3a4230708e186705065e66babdd4c35cf60028" + +bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.1.1, bn.js@^4.4.0: + version "4.11.6" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.6.tgz#53344adb14617a13f6e8dd2ce28905d1c0ba3215" + +brace-expansion@^1.0.0: + version "1.1.6" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.6.tgz#7197d7eaa9b87e648390ea61fc66c84427420df9" + dependencies: + balanced-match "^0.4.1" + concat-map "0.0.1" + +brorand@^1.0.1: + version "1.0.6" + resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.0.6.tgz#4028706b915f91f7b349a2e0bf3c376039d216e5" + +browser-pack@^4.0.0: + version "4.0.4" + resolved "https://registry.yarnpkg.com/browser-pack/-/browser-pack-4.0.4.tgz#8dae95a20ca43b3fea201faa6cfaa84ff4a0d484" + dependencies: + combine-source-map "~0.3.0" + concat-stream "~1.4.1" + defined "^1.0.0" + JSONStream "^1.0.3" + through2 "~0.5.1" + umd "^3.0.0" + +browser-resolve@^1.7.0, browser-resolve@^1.7.1: + version "1.11.2" + resolved "https://registry.yarnpkg.com/browser-resolve/-/browser-resolve-1.11.2.tgz#8ff09b0a2c421718a1051c260b32e48f442938ce" + dependencies: + resolve "1.1.7" + +browser-stdout@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.0.tgz#f351d32969d32fa5d7a5567154263d928ae3bd1f" + +browserify-aes@^1.0.0, browserify-aes@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/browserify-aes/-/browserify-aes-1.0.6.tgz#5e7725dbdef1fd5930d4ebab48567ce451c48a0a" + dependencies: + buffer-xor "^1.0.2" + cipher-base "^1.0.0" + create-hash "^1.1.0" + evp_bytestokey "^1.0.0" + inherits "^2.0.1" + +browserify-cipher@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/browserify-cipher/-/browserify-cipher-1.0.0.tgz#9988244874bf5ed4e28da95666dcd66ac8fc363a" + dependencies: + browserify-aes "^1.0.4" + browserify-des "^1.0.0" + evp_bytestokey "^1.0.0" + +browserify-des@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/browserify-des/-/browserify-des-1.0.0.tgz#daa277717470922ed2fe18594118a175439721dd" + dependencies: + cipher-base "^1.0.1" + des.js "^1.0.0" + inherits "^2.0.1" + +browserify-rsa@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/browserify-rsa/-/browserify-rsa-4.0.1.tgz#21e0abfaf6f2029cf2fafb133567a701d4135524" + dependencies: + bn.js "^4.1.0" + randombytes "^2.0.1" + +browserify-sign@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/browserify-sign/-/browserify-sign-4.0.0.tgz#10773910c3c206d5420a46aad8694f820b85968f" + dependencies: + bn.js "^4.1.1" + browserify-rsa "^4.0.0" + create-hash "^1.1.0" + create-hmac "^1.1.2" + elliptic "^6.0.0" + inherits "^2.0.1" + parse-asn1 "^5.0.0" + +browserify-zlib@~0.1.2: + version "0.1.4" + resolved "https://registry.yarnpkg.com/browserify-zlib/-/browserify-zlib-0.1.4.tgz#bb35f8a519f600e0fa6b8485241c979d0141fb2d" + dependencies: + pako "~0.2.0" + +browserify@9.0.3: + version "9.0.3" + resolved "https://registry.yarnpkg.com/browserify/-/browserify-9.0.3.tgz#f2f742b82ec5631c64b8c98a9788db0017c6517c" + dependencies: + assert "~1.3.0" + browser-pack "^4.0.0" + browser-resolve "^1.7.1" + browserify-zlib "~0.1.2" + buffer "^3.0.0" + builtins "~0.0.3" + commondir "0.0.1" + concat-stream "~1.4.1" + console-browserify "^1.1.0" + constants-browserify "~0.0.1" + crypto-browserify "^3.0.0" + deep-equal "^1.0.0" + defined "~0.0.0" + deps-sort "^1.3.5" + domain-browser "~1.1.0" + duplexer2 "~0.0.2" + events "~1.0.0" + glob "^4.0.5" + has "^1.0.0" + http-browserify "^1.4.0" + https-browserify "~0.0.0" + inherits "~2.0.1" + insert-module-globals "^6.2.0" + isarray "0.0.1" + JSONStream "~0.10.0" + labeled-stream-splicer "^1.0.0" + module-deps "^3.7.0" + os-browserify "~0.1.1" + parents "^1.0.1" + path-browserify "~0.0.0" + process "^0.10.0" + punycode "~1.2.3" + querystring-es3 "~0.2.0" + readable-stream "^1.1.13" + resolve "^1.1.4" + shallow-copy "0.0.1" + shasum "^1.0.0" + shell-quote "~0.0.1" + stream-browserify "^1.0.0" + string_decoder "~0.10.0" + subarg "^1.0.0" + syntax-error "^1.1.1" + through2 "^1.0.0" + timers-browserify "^1.0.1" + tty-browserify "~0.0.0" + url "~0.10.1" + util "~0.10.1" + vm-browserify "~0.0.1" + xtend "^3.0.0" + +buffer-xor@^1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/buffer-xor/-/buffer-xor-1.0.3.tgz#26e61ed1422fb70dd42e6e36729ed51d855fe8d9" + +buffer@^3.0.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-3.6.0.tgz#a72c936f77b96bf52f5f7e7b467180628551defb" + dependencies: + base64-js "0.0.8" + ieee754 "^1.1.4" + isarray "^1.0.0" + +builtins@~0.0.3: + version "0.0.7" + resolved "https://registry.yarnpkg.com/builtins/-/builtins-0.0.7.tgz#355219cd6cf18dbe7c01cc7fd2dce765cfdc549a" + +cipher-base@^1.0.0, cipher-base@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/cipher-base/-/cipher-base-1.0.3.tgz#eeabf194419ce900da3018c207d212f2a6df0a07" + dependencies: + inherits "^2.0.1" + +combine-source-map@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/combine-source-map/-/combine-source-map-0.3.0.tgz#d9e74f593d9cd43807312cb5d846d451efaa9eb7" + dependencies: + convert-source-map "~0.3.0" + inline-source-map "~0.3.0" + source-map "~0.1.31" + +combine-source-map@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/combine-source-map/-/combine-source-map-0.6.1.tgz#9b4a09c316033d768e0f11e029fa2730e079ad96" + dependencies: + convert-source-map "~1.1.0" + inline-source-map "~0.5.0" + lodash.memoize "~3.0.3" + source-map "~0.4.2" + +commander@2.9.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4" + dependencies: + graceful-readlink ">= 1.0.0" + +commondir@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/commondir/-/commondir-0.0.1.tgz#89f00fdcd51b519c578733fec563e6a6da7f5be2" + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + +concat-stream@~1.4.1, concat-stream@~1.4.5: + version "1.4.10" + resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.4.10.tgz#acc3bbf5602cb8cc980c6ac840fa7d8603e3ef36" + dependencies: + inherits "~2.0.1" + readable-stream "~1.1.9" + typedarray "~0.0.5" + +console-browserify@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/console-browserify/-/console-browserify-1.1.0.tgz#f0241c45730a9fc6323b206dbf38edc741d0bb10" + dependencies: + date-now "^0.1.4" + +constants-browserify@~0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/constants-browserify/-/constants-browserify-0.0.1.tgz#92577db527ba6c4cf0a4568d84bc031f441e21f2" + +convert-source-map@~0.3.0: + version "0.3.5" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-0.3.5.tgz#f1d802950af7dd2631a1febe0596550c86ab3190" + +convert-source-map@~1.1.0: + version "1.1.3" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.1.3.tgz#4829c877e9fe49b3161f3bf3673888e204699860" + +core-util-is@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + +create-ecdh@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/create-ecdh/-/create-ecdh-4.0.0.tgz#888c723596cdf7612f6498233eebd7a35301737d" + dependencies: + bn.js "^4.1.0" + elliptic "^6.0.0" + +create-hash@^1.1.0, create-hash@^1.1.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/create-hash/-/create-hash-1.1.2.tgz#51210062d7bb7479f6c65bb41a92208b1d61abad" + dependencies: + cipher-base "^1.0.1" + inherits "^2.0.1" + ripemd160 "^1.0.0" + sha.js "^2.3.6" + +create-hmac@^1.1.0, create-hmac@^1.1.2: + version "1.1.4" + resolved "https://registry.yarnpkg.com/create-hmac/-/create-hmac-1.1.4.tgz#d3fb4ba253eb8b3f56e39ea2fbcb8af747bd3170" + dependencies: + create-hash "^1.1.0" + inherits "^2.0.1" + +crypto-browserify@^3.0.0: + version "3.11.0" + resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.11.0.tgz#3652a0906ab9b2a7e0c3ce66a408e957a2485522" + dependencies: + browserify-cipher "^1.0.0" + browserify-sign "^4.0.0" + create-ecdh "^4.0.0" + create-hash "^1.1.0" + create-hmac "^1.1.0" + diffie-hellman "^5.0.0" + inherits "^2.0.1" + pbkdf2 "^3.0.3" + public-encrypt "^4.0.0" + randombytes "^2.0.0" + +date-now@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b" + +debug@2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" + dependencies: + ms "0.7.1" + +deep-equal@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5" + +defined@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693" + +defined@~0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/defined/-/defined-0.0.0.tgz#f35eea7d705e933baf13b2f03b3f83d921403b3e" + +deps-sort@^1.3.5: + version "1.3.9" + resolved "https://registry.yarnpkg.com/deps-sort/-/deps-sort-1.3.9.tgz#29dfff53e17b36aecae7530adbbbf622c2ed1a71" + dependencies: + JSONStream "^1.0.3" + shasum "^1.0.0" + subarg "^1.0.0" + through2 "^1.0.0" + +des.js@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/des.js/-/des.js-1.0.0.tgz#c074d2e2aa6a8a9a07dbd61f9a15c2cd83ec8ecc" + dependencies: + inherits "^2.0.1" + minimalistic-assert "^1.0.0" + +detective@^4.0.0: + version "4.3.2" + resolved "https://registry.yarnpkg.com/detective/-/detective-4.3.2.tgz#77697e2e7947ac3fe7c8e26a6d6f115235afa91c" + dependencies: + acorn "^3.1.0" + defined "^1.0.0" + +diff@1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-1.4.0.tgz#7f28d2eb9ee7b15a97efd89ce63dcfdaa3ccbabf" + +diffie-hellman@^5.0.0: + version "5.0.2" + resolved "https://registry.yarnpkg.com/diffie-hellman/-/diffie-hellman-5.0.2.tgz#b5835739270cfe26acf632099fded2a07f209e5e" + dependencies: + bn.js "^4.1.0" + miller-rabin "^4.0.0" + randombytes "^2.0.0" + +domain-browser@~1.1.0: + version "1.1.7" + resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-1.1.7.tgz#867aa4b093faa05f1de08c06f4d7b21fdf8698bc" + +duplexer2@~0.0.2, duplexer2@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.0.2.tgz#c614dcf67e2fb14995a91711e5a617e8a60a31db" + dependencies: + readable-stream "~1.1.9" + +elliptic@^6.0.0: + version "6.3.2" + resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.3.2.tgz#e4c81e0829cf0a65ab70e998b8232723b5c1bc48" + dependencies: + bn.js "^4.4.0" + brorand "^1.0.1" + hash.js "^1.0.0" + inherits "^2.0.1" + +escape-string-regexp@1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + +events@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/events/-/events-1.0.2.tgz#75849dcfe93d10fb057c30055afdbd51d06a8e24" + +evp_bytestokey@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/evp_bytestokey/-/evp_bytestokey-1.0.0.tgz#497b66ad9fef65cd7c08a6180824ba1476b66e53" + dependencies: + create-hash "^1.1.1" + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + +function-bind@^1.0.2: + version "1.1.0" + resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.0.tgz#16176714c801798e4e8f2cf7f7529467bb4a5771" + +glob@^4.0.5: + version "4.5.3" + resolved "https://registry.yarnpkg.com/glob/-/glob-4.5.3.tgz#c6cb73d3226c1efef04de3c56d012f03377ee15f" + dependencies: + inflight "^1.0.4" + inherits "2" + minimatch "^2.0.1" + once "^1.3.0" + +glob@7.0.5: + version "7.0.5" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.0.5.tgz#b4202a69099bbb4d292a7c1b95b6682b67ebdc95" + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.2" + once "^1.3.0" + path-is-absolute "^1.0.0" + +"graceful-readlink@>= 1.0.0": + version "1.0.1" + resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" + +growl@1.9.2: + version "1.9.2" + resolved "https://registry.yarnpkg.com/growl/-/growl-1.9.2.tgz#0ea7743715db8d8de2c5ede1775e1b45ac85c02f" + +has-flag@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa" + +has@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/has/-/has-1.0.1.tgz#8461733f538b0837c9361e39a9ab9e9704dc2f28" + dependencies: + function-bind "^1.0.2" + +hash.js@^1.0.0: + version "1.0.3" + resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.0.3.tgz#1332ff00156c0a0ffdd8236013d07b77a0451573" + dependencies: + inherits "^2.0.1" + +http-browserify@^1.4.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/http-browserify/-/http-browserify-1.7.0.tgz#33795ade72df88acfbfd36773cefeda764735b20" + dependencies: + Base64 "~0.2.0" + inherits "~2.0.1" + +https-browserify@~0.0.0: + version "0.0.1" + resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-0.0.1.tgz#3f91365cabe60b77ed0ebba24b454e3e09d95a82" + +ieee754@^1.1.4: + version "1.1.8" + resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.8.tgz#be33d40ac10ef1926701f6f08a2d86fbfd1ad3e4" + +indexof@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/indexof/-/indexof-0.0.1.tgz#82dc336d232b9062179d05ab3293a66059fd435d" + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@^2.0.1, inherits@~2.0.1, inherits@2: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + +inherits@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.1.tgz#b17d08d326b4423e568eff719f91b0b1cbdf69f1" + +inline-source-map@~0.3.0: + version "0.3.1" + resolved "https://registry.yarnpkg.com/inline-source-map/-/inline-source-map-0.3.1.tgz#a528b514e689fce90db3089e870d92f527acb5eb" + dependencies: + source-map "~0.3.0" + +inline-source-map@~0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/inline-source-map/-/inline-source-map-0.5.0.tgz#4a4c5dd8e4fb5e9b3cda60c822dfadcaee66e0af" + dependencies: + source-map "~0.4.0" + +insert-module-globals@^6.2.0: + version "6.6.3" + resolved "https://registry.yarnpkg.com/insert-module-globals/-/insert-module-globals-6.6.3.tgz#20638e29a30f9ed1ca2e3a825fbc2cba5246ddfc" + dependencies: + combine-source-map "~0.6.1" + concat-stream "~1.4.1" + is-buffer "^1.1.0" + JSONStream "^1.0.3" + lexical-scope "^1.2.0" + process "~0.11.0" + through2 "^1.0.0" + xtend "^4.0.0" + +is-buffer@^1.1.0: + version "1.1.4" + resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.4.tgz#cfc86ccd5dc5a52fa80489111c6920c457e2d98b" + +isarray@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + +isarray@~0.0.1, isarray@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" + +json-stable-stringify@~0.0.0: + version "0.0.1" + resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-0.0.1.tgz#611c23e814db375527df851193db59dd2af27f45" + dependencies: + jsonify "~0.0.0" + +json3@3.3.2: + version "3.3.2" + resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.2.tgz#3c0434743df93e2f5c42aee7b19bcb483575f4e1" + +jsonify@~0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" + +jsonparse@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.2.0.tgz#5c0c5685107160e72fe7489bddea0b44c2bc67bd" + +jsonparse@0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-0.0.5.tgz#330542ad3f0a654665b778f3eb2d9a9fa507ac64" + +JSONStream@^1.0.3: + version "1.2.1" + resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.2.1.tgz#32aa5790e799481083b49b4b7fa94e23bae69bf9" + dependencies: + jsonparse "^1.2.0" + through ">=2.2.7 <3" + +JSONStream@~0.10.0: + version "0.10.0" + resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-0.10.0.tgz#74349d0d89522b71f30f0a03ff9bd20ca6f12ac0" + dependencies: + jsonparse "0.0.5" + through ">=2.2.7 <3" + +labeled-stream-splicer@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/labeled-stream-splicer/-/labeled-stream-splicer-1.0.2.tgz#4615331537784981e8fd264e1f3a434c4e0ddd65" + dependencies: + inherits "^2.0.1" + isarray "~0.0.1" + stream-splicer "^1.1.0" + +lexical-scope@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/lexical-scope/-/lexical-scope-1.2.0.tgz#fcea5edc704a4b3a8796cdca419c3a0afaf22df4" + dependencies: + astw "^2.0.0" + +lodash._baseassign@^3.0.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz#8c38a099500f215ad09e59f1722fd0c52bfe0a4e" + dependencies: + lodash._basecopy "^3.0.0" + lodash.keys "^3.0.0" + +lodash._basecopy@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36" + +lodash._basecreate@^3.0.0: + version "3.0.3" + resolved "https://registry.yarnpkg.com/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz#1bc661614daa7fc311b7d03bf16806a0213cf821" + +lodash._getnative@^3.0.0: + version "3.9.1" + resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5" + +lodash._isiterateecall@^3.0.0: + version "3.0.9" + resolved "https://registry.yarnpkg.com/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz#5203ad7ba425fae842460e696db9cf3e6aac057c" + +lodash.create@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/lodash.create/-/lodash.create-3.1.1.tgz#d7f2849f0dbda7e04682bb8cd72ab022461debe7" + dependencies: + lodash._baseassign "^3.0.0" + lodash._basecreate "^3.0.0" + lodash._isiterateecall "^3.0.0" + +lodash.isarguments@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a" + +lodash.isarray@^3.0.0: + version "3.0.4" + resolved "https://registry.yarnpkg.com/lodash.isarray/-/lodash.isarray-3.0.4.tgz#79e4eb88c36a8122af86f844aa9bcd851b5fbb55" + +lodash.keys@^3.0.0: + version "3.1.2" + resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-3.1.2.tgz#4dbc0472b156be50a0b286855d1bd0b0c656098a" + dependencies: + lodash._getnative "^3.0.0" + lodash.isarguments "^3.0.0" + lodash.isarray "^3.0.0" + +lodash.memoize@~3.0.3: + version "3.0.4" + resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-3.0.4.tgz#2dcbd2c287cbc0a55cc42328bd0c736150d53e3f" + +miller-rabin@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.0.tgz#4a62fb1d42933c05583982f4c716f6fb9e6c6d3d" + dependencies: + bn.js "^4.0.0" + brorand "^1.0.1" + +minimalistic-assert@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.0.tgz#702be2dda6b37f4836bcb3f5db56641b64a1d3d3" + +minimatch@^2.0.1: + version "2.0.10" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-2.0.10.tgz#8d087c39c6b38c001b97fca7ce6d0e1e80afbac7" + dependencies: + brace-expansion "^1.0.0" + +minimatch@^3.0.2: + version "3.0.3" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774" + dependencies: + brace-expansion "^1.0.0" + +minimist@^1.1.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" + +minimist@0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" + +mkdirp@0.5.1: + version "0.5.1" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" + dependencies: + minimist "0.0.8" + +mocha@*: + version "3.1.2" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-3.1.2.tgz#51f93b432bf7e1b175ffc22883ccd0be32dba6b5" + dependencies: + browser-stdout "1.3.0" + commander "2.9.0" + debug "2.2.0" + diff "1.4.0" + escape-string-regexp "1.0.5" + glob "7.0.5" + growl "1.9.2" + json3 "3.3.2" + lodash.create "3.1.1" + mkdirp "0.5.1" + supports-color "3.1.2" + +module-deps@^3.7.0: + version "3.9.1" + resolved "https://registry.yarnpkg.com/module-deps/-/module-deps-3.9.1.tgz#ea75caf9199090d25b0d5512b5acacb96e7f87f3" + dependencies: + browser-resolve "^1.7.0" + concat-stream "~1.4.5" + defined "^1.0.0" + detective "^4.0.0" + duplexer2 "0.0.2" + inherits "^2.0.1" + JSONStream "^1.0.3" + parents "^1.0.0" + readable-stream "^1.1.13" + resolve "^1.1.3" + stream-combiner2 "~1.0.0" + subarg "^1.0.0" + through2 "^1.0.0" + xtend "^4.0.0" + +ms@0.7.1: + version "0.7.1" + resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098" + +ms@0.7.2: + version "0.7.2" + resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.2.tgz#ae25cf2512b3885a1d95d7f037868d8431124765" + +once@^1.3.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + dependencies: + wrappy "1" + +os-browserify@~0.1.1: + version "0.1.2" + resolved "https://registry.yarnpkg.com/os-browserify/-/os-browserify-0.1.2.tgz#49ca0293e0b19590a5f5de10c7f265a617d8fe54" + +pako@~0.2.0: + version "0.2.9" + resolved "https://registry.yarnpkg.com/pako/-/pako-0.2.9.tgz#f3f7522f4ef782348da8161bad9ecfd51bf83a75" + +parents@^1.0.0, parents@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/parents/-/parents-1.0.1.tgz#fedd4d2bf193a77745fe71e371d73c3307d9c751" + dependencies: + path-platform "~0.11.15" + +parse-asn1@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/parse-asn1/-/parse-asn1-5.0.0.tgz#35060f6d5015d37628c770f4e091a0b5a278bc23" + dependencies: + asn1.js "^4.0.0" + browserify-aes "^1.0.0" + create-hash "^1.1.0" + evp_bytestokey "^1.0.0" + pbkdf2 "^3.0.3" + +path-browserify@~0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-0.0.0.tgz#a0b870729aae214005b7d5032ec2cbbb0fb4451a" + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + +path-platform@~0.11.15: + version "0.11.15" + resolved "https://registry.yarnpkg.com/path-platform/-/path-platform-0.11.15.tgz#e864217f74c36850f0852b78dc7bf7d4a5721bf2" + +pbkdf2@^3.0.3: + version "3.0.9" + resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.0.9.tgz#f2c4b25a600058b3c3773c086c37dbbee1ffe693" + dependencies: + create-hmac "^1.1.2" + +process@^0.10.0: + version "0.10.1" + resolved "https://registry.yarnpkg.com/process/-/process-0.10.1.tgz#842457cc51cfed72dc775afeeafb8c6034372725" + +process@~0.11.0: + version "0.11.9" + resolved "https://registry.yarnpkg.com/process/-/process-0.11.9.tgz#7bd5ad21aa6253e7da8682264f1e11d11c0318c1" + +public-encrypt@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/public-encrypt/-/public-encrypt-4.0.0.tgz#39f699f3a46560dd5ebacbca693caf7c65c18cc6" + dependencies: + bn.js "^4.1.0" + browserify-rsa "^4.0.0" + create-hash "^1.1.0" + parse-asn1 "^5.0.0" + randombytes "^2.0.1" + +punycode@~1.2.3: + version "1.2.4" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.2.4.tgz#54008ac972aec74175def9cba6df7fa9d3918740" + +punycode@1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d" + +querystring-es3@~0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73" + +querystring@0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620" + +randombytes@^2.0.0, randombytes@^2.0.1: + version "2.0.3" + resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.0.3.tgz#674c99760901c3c4112771a31e521dc349cc09ec" + +readable-stream@^1.0.27-1, readable-stream@^1.1.13, readable-stream@^1.1.13-1, "readable-stream@>=1.1.13-1 <1.2.0-0", readable-stream@~1.1.9: + version "1.1.14" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "0.0.1" + string_decoder "~0.10.x" + +readable-stream@~1.0.17: + version "1.0.34" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "0.0.1" + string_decoder "~0.10.x" + +readable-wrap@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/readable-wrap/-/readable-wrap-1.0.0.tgz#3b5a211c631e12303a54991c806c17e7ae206bff" + dependencies: + readable-stream "^1.1.13-1" + +resolve@^1.1.3, resolve@^1.1.4, resolve@1.1.7: + version "1.1.7" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" + +ripemd160@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-1.0.1.tgz#93a4bbd4942bc574b69a8fa57c71de10ecca7d6e" + +sha.js@^2.3.6, sha.js@~2.4.4: + version "2.4.5" + resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.4.5.tgz#27d171efcc82a118b99639ff581660242b506e7c" + dependencies: + inherits "^2.0.1" + +shallow-copy@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/shallow-copy/-/shallow-copy-0.0.1.tgz#415f42702d73d810330292cc5ee86eae1a11a170" + +shasum@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/shasum/-/shasum-1.0.2.tgz#e7012310d8f417f4deb5712150e5678b87ae565f" + dependencies: + json-stable-stringify "~0.0.0" + sha.js "~2.4.4" + +shell-quote@~0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-0.0.1.tgz#1a41196f3c0333c482323593d6886ecf153dd986" + +source-map@~0.1.31: + version "0.1.43" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.1.43.tgz#c24bc146ca517c1471f5dacbe2571b2b7f9e3346" + dependencies: + amdefine ">=0.0.4" + +source-map@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.3.0.tgz#8586fb9a5a005e5b501e21cd18b6f21b457ad1f9" + dependencies: + amdefine ">=0.0.4" + +source-map@~0.4.0, source-map@~0.4.2: + version "0.4.4" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.4.4.tgz#eba4f5da9c0dc999de68032d8b4f76173652036b" + dependencies: + amdefine ">=0.0.4" + +stream-browserify@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/stream-browserify/-/stream-browserify-1.0.0.tgz#bf9b4abfb42b274d751479e44e0ff2656b6f1193" + dependencies: + inherits "~2.0.1" + readable-stream "^1.0.27-1" + +stream-combiner2@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/stream-combiner2/-/stream-combiner2-1.0.2.tgz#ba72a6b50cbfabfa950fc8bc87604bd01eb60671" + dependencies: + duplexer2 "~0.0.2" + through2 "~0.5.1" + +stream-splicer@^1.1.0: + version "1.3.2" + resolved "https://registry.yarnpkg.com/stream-splicer/-/stream-splicer-1.3.2.tgz#3c0441be15b9bf4e226275e6dc83964745546661" + dependencies: + indexof "0.0.1" + inherits "^2.0.1" + isarray "~0.0.1" + readable-stream "^1.1.13-1" + readable-wrap "^1.0.0" + through2 "^1.0.0" + +string_decoder@~0.10.0, string_decoder@~0.10.x: + version "0.10.31" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" + +subarg@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/subarg/-/subarg-1.0.0.tgz#f62cf17581e996b48fc965699f54c06ae268b8d2" + dependencies: + minimist "^1.1.0" + +supports-color@3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.1.2.tgz#72a262894d9d408b956ca05ff37b2ed8a6e2a2d5" + dependencies: + has-flag "^1.0.0" + +syntax-error@^1.1.1: + version "1.1.6" + resolved "https://registry.yarnpkg.com/syntax-error/-/syntax-error-1.1.6.tgz#b4549706d386cc1c1dc7c2423f18579b6cade710" + dependencies: + acorn "^2.7.0" + +"through@>=2.2.7 <3": + version "2.3.8" + resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" + +through2@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/through2/-/through2-1.1.1.tgz#0847cbc4449f3405574dbdccd9bb841b83ac3545" + dependencies: + readable-stream ">=1.1.13-1 <1.2.0-0" + xtend ">=4.0.0 <4.1.0-0" + +through2@~0.5.1: + version "0.5.1" + resolved "https://registry.yarnpkg.com/through2/-/through2-0.5.1.tgz#dfdd012eb9c700e2323fd334f38ac622ab372da7" + dependencies: + readable-stream "~1.0.17" + xtend "~3.0.0" + +timers-browserify@^1.0.1: + version "1.4.2" + resolved "https://registry.yarnpkg.com/timers-browserify/-/timers-browserify-1.4.2.tgz#c9c58b575be8407375cb5e2462dacee74359f41d" + dependencies: + process "~0.11.0" + +tty-browserify@~0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6" + +typedarray@~0.0.5: + version "0.0.6" + resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" + +umd@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/umd/-/umd-3.0.1.tgz#8ae556e11011f63c2596708a8837259f01b3d60e" + +url@~0.10.1: + version "0.10.3" + resolved "https://registry.yarnpkg.com/url/-/url-0.10.3.tgz#021e4d9c7705f21bbf37d03ceb58767402774c64" + dependencies: + punycode "1.3.2" + querystring "0.2.0" + +util@~0.10.1, util@0.10.3: + version "0.10.3" + resolved "https://registry.yarnpkg.com/util/-/util-0.10.3.tgz#7afb1afe50805246489e3db7fe0ed379336ac0f9" + dependencies: + inherits "2.0.1" + +vm-browserify@~0.0.1: + version "0.0.4" + resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-0.0.4.tgz#5d7ea45bbef9e4a6ff65f95438e0a87c357d5a73" + dependencies: + indexof "0.0.1" + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + +xtend@^3.0.0, xtend@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/xtend/-/xtend-3.0.0.tgz#5cce7407baf642cba7becda568111c493f59665a" + +xtend@^4.0.0, "xtend@>=4.0.0 <4.1.0-0": + version "4.0.1" + resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" + From b39265f55eeb72cf63d0e2fec8b2d629c94081e6 Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Thu, 27 Oct 2016 09:47:49 -0700 Subject: [PATCH 018/257] renamed History.md to CHANGELOG.md --- History.md => CHANGELOG.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename History.md => CHANGELOG.md (100%) diff --git a/History.md b/CHANGELOG.md similarity index 100% rename from History.md rename to CHANGELOG.md From 341e584dd47c2d3ece9c495d0def09f827fc5c8f Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Thu, 27 Oct 2016 10:29:12 -0700 Subject: [PATCH 019/257] added Yarn integration to Makefile --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 5cf4a596..db71cafc 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,8 @@ BIN := $(THIS_DIR)/node_modules/.bin # applications NODE ?= $(shell which node) -NPM ?= $(NODE) $(shell which npm) +YARN ?= $(shell which yarn) +PKG ?= $(if $(YARN),$(YARN),$(NODE) $(shell which npm)) BROWSERIFY ?= $(NODE) $(BIN)/browserify all: dist/debug.js @@ -30,7 +31,7 @@ distclean: clean @rm -rf node_modules node_modules: package.json - @NODE_ENV= $(NPM) install + @NODE_ENV= $(PKG) install @touch node_modules .PHONY: all install clean distclean From d887d9326f2ea3a70931cf4662b4faa00e1c2cda Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Thu, 27 Oct 2016 17:48:04 -0700 Subject: [PATCH 020/257] updated contributors --- Readme.md | 1 + package.json | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 6ec39055..9e80851f 100644 --- a/Readme.md +++ b/Readme.md @@ -171,6 +171,7 @@ $ DEBUG_FD=3 node your-app.js 3> whatever.log - TJ Holowaychuk - Nathan Rajlich + - Andrew Rhyne ## License diff --git a/package.json b/package.json index c3e2ab0a..4f8b4e2e 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ ], "author": "TJ Holowaychuk ", "contributors": [ - "Nathan Rajlich (http://n8.io)" + "Nathan Rajlich (http://n8.io)", + "Andrew Rhyne " ], "license": "MIT", "dependencies": { From 8e5a6b3c3d436843ed8c2d9a02315d9d5f9e9442 Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Mon, 7 Nov 2016 09:39:45 -0800 Subject: [PATCH 021/257] 2.3.0 --- CHANGELOG.md | 20 ++++++++++++++++++++ bower.json | 4 +++- package.json | 2 +- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 854c9711..ee049555 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,24 @@ +2.3.0 / 2016-11-07 +================== + + * Fix: Consistent placement of ms diff at end of output (#215, @gorangajic) + * Fix: Escaping of regex special characters in namespace strings (#250, @zacronos) + * Fix: Fixed bug causing crash on react-native (#282, @vkarpov15) + * Feature: Enabled ES6+ compatible import via default export (#212 @bucaran) + * Feature: Added %O formatter to reflect Chrome's console.log capability (#279, @oncletom) + * Package: Update "ms" to 0.7.2 (#315, @DevSide) + * Package: removed superfluous version property from bower.json (#207 @kkirsche) + * Readme: fix USE_COLORS to DEBUG_COLORS + * Readme: Doc fixes for format string sugar (#269, @mlucool) + * Readme: Updated docs for DEBUG_FD and DEBUG_COLORS environment variables (#232, @mattlyons0) + * Readme: doc fixes for PowerShell (#271 #243, @exoticknight @unreadable) + * Readme: better docs for browser support (#224, @matthewmueller) + * Tooling: Added yarn integration for development (#317, @thebigredgeek) + * Misc: Renamed History.md to CHANGELOG.md (@thebigredgeek) + * Misc: Added license file (#226 #274, @CantemoInternal @sdaitzman) + * Misc: Updated contributors (@thebigredgeek) + 2.2.0 / 2015-05-09 ================== diff --git a/bower.json b/bower.json index 0555fc71..7a1a5a8f 100644 --- a/bower.json +++ b/bower.json @@ -3,7 +3,9 @@ "main": "dist/debug.js", "homepage": "https://github.com/visionmedia/debug", "authors": [ - "TJ Holowaychuk " + "TJ Holowaychuk ", + "Nathan Rajlich (http://n8.io)", + "Andrew Rhyne " ], "description": "visionmedia-debug", "moduleType": [ diff --git a/package.json b/package.json index 4f8b4e2e..5ab1c1c6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "2.2.0", + "version": "2.3.0", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From 475e7b31f37571057c67ab31e363653d3415f49e Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Mon, 7 Nov 2016 10:46:22 -0800 Subject: [PATCH 022/257] some random optimizations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hopefully… --- debug.js | 11 +++++++---- node.js | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/debug.js b/debug.js index b475edcf..a5992a44 100644 --- a/debug.js +++ b/debug.js @@ -83,7 +83,10 @@ function debug(namespace) { if (null == self.useColors) self.useColors = exports.useColors(); if (null == self.color && self.useColors) self.color = selectColor(); - var args = Array.prototype.slice.call(arguments); + var args = new Array(arguments.length); + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i]; + } args[0] = exports.coerce(args[0]); @@ -110,9 +113,9 @@ function debug(namespace) { return match; }); - if ('function' === typeof exports.formatArgs) { - args = exports.formatArgs.apply(self, args); - } + // apply env-specific formatting + args = exports.formatArgs.apply(self, args); + var logFn = enabled.log || exports.log || console.log.bind(console); logFn.apply(self, args); } diff --git a/node.js b/node.js index 01d534b0..01e9fad5 100644 --- a/node.js +++ b/node.js @@ -80,12 +80,12 @@ exports.formatters.o = exports.formatters.O = function(v) { */ function formatArgs() { - var args = []; var len = arguments.length; + var args = new Array(len); var useColors = this.useColors; var name = this.namespace; for (var i = 0; i < len; i++) { - args.push(arguments[i]); + args[i] = arguments[i]; } if (useColors) { From 310ae229de447062c54cf508caf3ee7c8335f5a5 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Tue, 8 Nov 2016 02:07:25 +0800 Subject: [PATCH 023/257] Library should not contains lockfile see https://t.co/ce8TntXr7N --- .gitignore | 1 + .npmignore | 1 + yarn.lock | 977 ----------------------------------------------------- 3 files changed, 2 insertions(+), 977 deletions(-) delete mode 100644 yarn.lock diff --git a/.gitignore b/.gitignore index c78f3472..84f7efc1 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules *.sock build +yarn.lock diff --git a/.npmignore b/.npmignore index 7e6163db..35b0dc77 100644 --- a/.npmignore +++ b/.npmignore @@ -4,3 +4,4 @@ examples example *.sock dist +yarn.lock diff --git a/yarn.lock b/yarn.lock deleted file mode 100644 index 49cea028..00000000 --- a/yarn.lock +++ /dev/null @@ -1,977 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 -acorn@^1.0.3: - version "1.2.2" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-1.2.2.tgz#c8ce27de0acc76d896d2b1fad3df588d9e82f014" - -acorn@^2.7.0: - version "2.7.0" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-2.7.0.tgz#ab6e7d9d886aaca8b085bc3312b79a198433f0e7" - -acorn@^3.1.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a" - -amdefine@>=0.0.4: - version "1.0.0" - resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.0.tgz#fd17474700cb5cc9c2b709f0be9d23ce3c198c33" - -asn1.js@^4.0.0: - version "4.8.1" - resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-4.8.1.tgz#3949b7f5fd1e8bedc13be3abebf477f93490c810" - dependencies: - bn.js "^4.0.0" - inherits "^2.0.1" - minimalistic-assert "^1.0.0" - -assert@~1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/assert/-/assert-1.3.0.tgz#03939a622582a812cc202320a0b9a56c9b815849" - dependencies: - util "0.10.3" - -astw@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/astw/-/astw-2.0.0.tgz#08121ac8288d35611c0ceec663f6cd545604897d" - dependencies: - acorn "^1.0.3" - -balanced-match@^0.4.1: - version "0.4.2" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838" - -base64-js@0.0.8: - version "0.0.8" - resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-0.0.8.tgz#1101e9544f4a76b1bc3b26d452ca96d7a35e7978" - -Base64@~0.2.0: - version "0.2.1" - resolved "https://registry.yarnpkg.com/Base64/-/Base64-0.2.1.tgz#ba3a4230708e186705065e66babdd4c35cf60028" - -bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.1.1, bn.js@^4.4.0: - version "4.11.6" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.6.tgz#53344adb14617a13f6e8dd2ce28905d1c0ba3215" - -brace-expansion@^1.0.0: - version "1.1.6" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.6.tgz#7197d7eaa9b87e648390ea61fc66c84427420df9" - dependencies: - balanced-match "^0.4.1" - concat-map "0.0.1" - -brorand@^1.0.1: - version "1.0.6" - resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.0.6.tgz#4028706b915f91f7b349a2e0bf3c376039d216e5" - -browser-pack@^4.0.0: - version "4.0.4" - resolved "https://registry.yarnpkg.com/browser-pack/-/browser-pack-4.0.4.tgz#8dae95a20ca43b3fea201faa6cfaa84ff4a0d484" - dependencies: - combine-source-map "~0.3.0" - concat-stream "~1.4.1" - defined "^1.0.0" - JSONStream "^1.0.3" - through2 "~0.5.1" - umd "^3.0.0" - -browser-resolve@^1.7.0, browser-resolve@^1.7.1: - version "1.11.2" - resolved "https://registry.yarnpkg.com/browser-resolve/-/browser-resolve-1.11.2.tgz#8ff09b0a2c421718a1051c260b32e48f442938ce" - dependencies: - resolve "1.1.7" - -browser-stdout@1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.0.tgz#f351d32969d32fa5d7a5567154263d928ae3bd1f" - -browserify-aes@^1.0.0, browserify-aes@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/browserify-aes/-/browserify-aes-1.0.6.tgz#5e7725dbdef1fd5930d4ebab48567ce451c48a0a" - dependencies: - buffer-xor "^1.0.2" - cipher-base "^1.0.0" - create-hash "^1.1.0" - evp_bytestokey "^1.0.0" - inherits "^2.0.1" - -browserify-cipher@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/browserify-cipher/-/browserify-cipher-1.0.0.tgz#9988244874bf5ed4e28da95666dcd66ac8fc363a" - dependencies: - browserify-aes "^1.0.4" - browserify-des "^1.0.0" - evp_bytestokey "^1.0.0" - -browserify-des@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/browserify-des/-/browserify-des-1.0.0.tgz#daa277717470922ed2fe18594118a175439721dd" - dependencies: - cipher-base "^1.0.1" - des.js "^1.0.0" - inherits "^2.0.1" - -browserify-rsa@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/browserify-rsa/-/browserify-rsa-4.0.1.tgz#21e0abfaf6f2029cf2fafb133567a701d4135524" - dependencies: - bn.js "^4.1.0" - randombytes "^2.0.1" - -browserify-sign@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/browserify-sign/-/browserify-sign-4.0.0.tgz#10773910c3c206d5420a46aad8694f820b85968f" - dependencies: - bn.js "^4.1.1" - browserify-rsa "^4.0.0" - create-hash "^1.1.0" - create-hmac "^1.1.2" - elliptic "^6.0.0" - inherits "^2.0.1" - parse-asn1 "^5.0.0" - -browserify-zlib@~0.1.2: - version "0.1.4" - resolved "https://registry.yarnpkg.com/browserify-zlib/-/browserify-zlib-0.1.4.tgz#bb35f8a519f600e0fa6b8485241c979d0141fb2d" - dependencies: - pako "~0.2.0" - -browserify@9.0.3: - version "9.0.3" - resolved "https://registry.yarnpkg.com/browserify/-/browserify-9.0.3.tgz#f2f742b82ec5631c64b8c98a9788db0017c6517c" - dependencies: - assert "~1.3.0" - browser-pack "^4.0.0" - browser-resolve "^1.7.1" - browserify-zlib "~0.1.2" - buffer "^3.0.0" - builtins "~0.0.3" - commondir "0.0.1" - concat-stream "~1.4.1" - console-browserify "^1.1.0" - constants-browserify "~0.0.1" - crypto-browserify "^3.0.0" - deep-equal "^1.0.0" - defined "~0.0.0" - deps-sort "^1.3.5" - domain-browser "~1.1.0" - duplexer2 "~0.0.2" - events "~1.0.0" - glob "^4.0.5" - has "^1.0.0" - http-browserify "^1.4.0" - https-browserify "~0.0.0" - inherits "~2.0.1" - insert-module-globals "^6.2.0" - isarray "0.0.1" - JSONStream "~0.10.0" - labeled-stream-splicer "^1.0.0" - module-deps "^3.7.0" - os-browserify "~0.1.1" - parents "^1.0.1" - path-browserify "~0.0.0" - process "^0.10.0" - punycode "~1.2.3" - querystring-es3 "~0.2.0" - readable-stream "^1.1.13" - resolve "^1.1.4" - shallow-copy "0.0.1" - shasum "^1.0.0" - shell-quote "~0.0.1" - stream-browserify "^1.0.0" - string_decoder "~0.10.0" - subarg "^1.0.0" - syntax-error "^1.1.1" - through2 "^1.0.0" - timers-browserify "^1.0.1" - tty-browserify "~0.0.0" - url "~0.10.1" - util "~0.10.1" - vm-browserify "~0.0.1" - xtend "^3.0.0" - -buffer-xor@^1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/buffer-xor/-/buffer-xor-1.0.3.tgz#26e61ed1422fb70dd42e6e36729ed51d855fe8d9" - -buffer@^3.0.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/buffer/-/buffer-3.6.0.tgz#a72c936f77b96bf52f5f7e7b467180628551defb" - dependencies: - base64-js "0.0.8" - ieee754 "^1.1.4" - isarray "^1.0.0" - -builtins@~0.0.3: - version "0.0.7" - resolved "https://registry.yarnpkg.com/builtins/-/builtins-0.0.7.tgz#355219cd6cf18dbe7c01cc7fd2dce765cfdc549a" - -cipher-base@^1.0.0, cipher-base@^1.0.1: - version "1.0.3" - resolved "https://registry.yarnpkg.com/cipher-base/-/cipher-base-1.0.3.tgz#eeabf194419ce900da3018c207d212f2a6df0a07" - dependencies: - inherits "^2.0.1" - -combine-source-map@~0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/combine-source-map/-/combine-source-map-0.3.0.tgz#d9e74f593d9cd43807312cb5d846d451efaa9eb7" - dependencies: - convert-source-map "~0.3.0" - inline-source-map "~0.3.0" - source-map "~0.1.31" - -combine-source-map@~0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/combine-source-map/-/combine-source-map-0.6.1.tgz#9b4a09c316033d768e0f11e029fa2730e079ad96" - dependencies: - convert-source-map "~1.1.0" - inline-source-map "~0.5.0" - lodash.memoize "~3.0.3" - source-map "~0.4.2" - -commander@2.9.0: - version "2.9.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4" - dependencies: - graceful-readlink ">= 1.0.0" - -commondir@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/commondir/-/commondir-0.0.1.tgz#89f00fdcd51b519c578733fec563e6a6da7f5be2" - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - -concat-stream@~1.4.1, concat-stream@~1.4.5: - version "1.4.10" - resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.4.10.tgz#acc3bbf5602cb8cc980c6ac840fa7d8603e3ef36" - dependencies: - inherits "~2.0.1" - readable-stream "~1.1.9" - typedarray "~0.0.5" - -console-browserify@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/console-browserify/-/console-browserify-1.1.0.tgz#f0241c45730a9fc6323b206dbf38edc741d0bb10" - dependencies: - date-now "^0.1.4" - -constants-browserify@~0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/constants-browserify/-/constants-browserify-0.0.1.tgz#92577db527ba6c4cf0a4568d84bc031f441e21f2" - -convert-source-map@~0.3.0: - version "0.3.5" - resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-0.3.5.tgz#f1d802950af7dd2631a1febe0596550c86ab3190" - -convert-source-map@~1.1.0: - version "1.1.3" - resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.1.3.tgz#4829c877e9fe49b3161f3bf3673888e204699860" - -core-util-is@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" - -create-ecdh@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/create-ecdh/-/create-ecdh-4.0.0.tgz#888c723596cdf7612f6498233eebd7a35301737d" - dependencies: - bn.js "^4.1.0" - elliptic "^6.0.0" - -create-hash@^1.1.0, create-hash@^1.1.1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/create-hash/-/create-hash-1.1.2.tgz#51210062d7bb7479f6c65bb41a92208b1d61abad" - dependencies: - cipher-base "^1.0.1" - inherits "^2.0.1" - ripemd160 "^1.0.0" - sha.js "^2.3.6" - -create-hmac@^1.1.0, create-hmac@^1.1.2: - version "1.1.4" - resolved "https://registry.yarnpkg.com/create-hmac/-/create-hmac-1.1.4.tgz#d3fb4ba253eb8b3f56e39ea2fbcb8af747bd3170" - dependencies: - create-hash "^1.1.0" - inherits "^2.0.1" - -crypto-browserify@^3.0.0: - version "3.11.0" - resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.11.0.tgz#3652a0906ab9b2a7e0c3ce66a408e957a2485522" - dependencies: - browserify-cipher "^1.0.0" - browserify-sign "^4.0.0" - create-ecdh "^4.0.0" - create-hash "^1.1.0" - create-hmac "^1.1.0" - diffie-hellman "^5.0.0" - inherits "^2.0.1" - pbkdf2 "^3.0.3" - public-encrypt "^4.0.0" - randombytes "^2.0.0" - -date-now@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b" - -debug@2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" - dependencies: - ms "0.7.1" - -deep-equal@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5" - -defined@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693" - -defined@~0.0.0: - version "0.0.0" - resolved "https://registry.yarnpkg.com/defined/-/defined-0.0.0.tgz#f35eea7d705e933baf13b2f03b3f83d921403b3e" - -deps-sort@^1.3.5: - version "1.3.9" - resolved "https://registry.yarnpkg.com/deps-sort/-/deps-sort-1.3.9.tgz#29dfff53e17b36aecae7530adbbbf622c2ed1a71" - dependencies: - JSONStream "^1.0.3" - shasum "^1.0.0" - subarg "^1.0.0" - through2 "^1.0.0" - -des.js@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/des.js/-/des.js-1.0.0.tgz#c074d2e2aa6a8a9a07dbd61f9a15c2cd83ec8ecc" - dependencies: - inherits "^2.0.1" - minimalistic-assert "^1.0.0" - -detective@^4.0.0: - version "4.3.2" - resolved "https://registry.yarnpkg.com/detective/-/detective-4.3.2.tgz#77697e2e7947ac3fe7c8e26a6d6f115235afa91c" - dependencies: - acorn "^3.1.0" - defined "^1.0.0" - -diff@1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/diff/-/diff-1.4.0.tgz#7f28d2eb9ee7b15a97efd89ce63dcfdaa3ccbabf" - -diffie-hellman@^5.0.0: - version "5.0.2" - resolved "https://registry.yarnpkg.com/diffie-hellman/-/diffie-hellman-5.0.2.tgz#b5835739270cfe26acf632099fded2a07f209e5e" - dependencies: - bn.js "^4.1.0" - miller-rabin "^4.0.0" - randombytes "^2.0.0" - -domain-browser@~1.1.0: - version "1.1.7" - resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-1.1.7.tgz#867aa4b093faa05f1de08c06f4d7b21fdf8698bc" - -duplexer2@~0.0.2, duplexer2@0.0.2: - version "0.0.2" - resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.0.2.tgz#c614dcf67e2fb14995a91711e5a617e8a60a31db" - dependencies: - readable-stream "~1.1.9" - -elliptic@^6.0.0: - version "6.3.2" - resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.3.2.tgz#e4c81e0829cf0a65ab70e998b8232723b5c1bc48" - dependencies: - bn.js "^4.4.0" - brorand "^1.0.1" - hash.js "^1.0.0" - inherits "^2.0.1" - -escape-string-regexp@1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - -events@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/events/-/events-1.0.2.tgz#75849dcfe93d10fb057c30055afdbd51d06a8e24" - -evp_bytestokey@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/evp_bytestokey/-/evp_bytestokey-1.0.0.tgz#497b66ad9fef65cd7c08a6180824ba1476b66e53" - dependencies: - create-hash "^1.1.1" - -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - -function-bind@^1.0.2: - version "1.1.0" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.0.tgz#16176714c801798e4e8f2cf7f7529467bb4a5771" - -glob@^4.0.5: - version "4.5.3" - resolved "https://registry.yarnpkg.com/glob/-/glob-4.5.3.tgz#c6cb73d3226c1efef04de3c56d012f03377ee15f" - dependencies: - inflight "^1.0.4" - inherits "2" - minimatch "^2.0.1" - once "^1.3.0" - -glob@7.0.5: - version "7.0.5" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.0.5.tgz#b4202a69099bbb4d292a7c1b95b6682b67ebdc95" - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.2" - once "^1.3.0" - path-is-absolute "^1.0.0" - -"graceful-readlink@>= 1.0.0": - version "1.0.1" - resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" - -growl@1.9.2: - version "1.9.2" - resolved "https://registry.yarnpkg.com/growl/-/growl-1.9.2.tgz#0ea7743715db8d8de2c5ede1775e1b45ac85c02f" - -has-flag@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa" - -has@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.1.tgz#8461733f538b0837c9361e39a9ab9e9704dc2f28" - dependencies: - function-bind "^1.0.2" - -hash.js@^1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.0.3.tgz#1332ff00156c0a0ffdd8236013d07b77a0451573" - dependencies: - inherits "^2.0.1" - -http-browserify@^1.4.0: - version "1.7.0" - resolved "https://registry.yarnpkg.com/http-browserify/-/http-browserify-1.7.0.tgz#33795ade72df88acfbfd36773cefeda764735b20" - dependencies: - Base64 "~0.2.0" - inherits "~2.0.1" - -https-browserify@~0.0.0: - version "0.0.1" - resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-0.0.1.tgz#3f91365cabe60b77ed0ebba24b454e3e09d95a82" - -ieee754@^1.1.4: - version "1.1.8" - resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.8.tgz#be33d40ac10ef1926701f6f08a2d86fbfd1ad3e4" - -indexof@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/indexof/-/indexof-0.0.1.tgz#82dc336d232b9062179d05ab3293a66059fd435d" - -inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@^2.0.1, inherits@~2.0.1, inherits@2: - version "2.0.3" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" - -inherits@2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.1.tgz#b17d08d326b4423e568eff719f91b0b1cbdf69f1" - -inline-source-map@~0.3.0: - version "0.3.1" - resolved "https://registry.yarnpkg.com/inline-source-map/-/inline-source-map-0.3.1.tgz#a528b514e689fce90db3089e870d92f527acb5eb" - dependencies: - source-map "~0.3.0" - -inline-source-map@~0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/inline-source-map/-/inline-source-map-0.5.0.tgz#4a4c5dd8e4fb5e9b3cda60c822dfadcaee66e0af" - dependencies: - source-map "~0.4.0" - -insert-module-globals@^6.2.0: - version "6.6.3" - resolved "https://registry.yarnpkg.com/insert-module-globals/-/insert-module-globals-6.6.3.tgz#20638e29a30f9ed1ca2e3a825fbc2cba5246ddfc" - dependencies: - combine-source-map "~0.6.1" - concat-stream "~1.4.1" - is-buffer "^1.1.0" - JSONStream "^1.0.3" - lexical-scope "^1.2.0" - process "~0.11.0" - through2 "^1.0.0" - xtend "^4.0.0" - -is-buffer@^1.1.0: - version "1.1.4" - resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.4.tgz#cfc86ccd5dc5a52fa80489111c6920c457e2d98b" - -isarray@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" - -isarray@~0.0.1, isarray@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" - -json-stable-stringify@~0.0.0: - version "0.0.1" - resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-0.0.1.tgz#611c23e814db375527df851193db59dd2af27f45" - dependencies: - jsonify "~0.0.0" - -json3@3.3.2: - version "3.3.2" - resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.2.tgz#3c0434743df93e2f5c42aee7b19bcb483575f4e1" - -jsonify@~0.0.0: - version "0.0.0" - resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" - -jsonparse@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.2.0.tgz#5c0c5685107160e72fe7489bddea0b44c2bc67bd" - -jsonparse@0.0.5: - version "0.0.5" - resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-0.0.5.tgz#330542ad3f0a654665b778f3eb2d9a9fa507ac64" - -JSONStream@^1.0.3: - version "1.2.1" - resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.2.1.tgz#32aa5790e799481083b49b4b7fa94e23bae69bf9" - dependencies: - jsonparse "^1.2.0" - through ">=2.2.7 <3" - -JSONStream@~0.10.0: - version "0.10.0" - resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-0.10.0.tgz#74349d0d89522b71f30f0a03ff9bd20ca6f12ac0" - dependencies: - jsonparse "0.0.5" - through ">=2.2.7 <3" - -labeled-stream-splicer@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/labeled-stream-splicer/-/labeled-stream-splicer-1.0.2.tgz#4615331537784981e8fd264e1f3a434c4e0ddd65" - dependencies: - inherits "^2.0.1" - isarray "~0.0.1" - stream-splicer "^1.1.0" - -lexical-scope@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/lexical-scope/-/lexical-scope-1.2.0.tgz#fcea5edc704a4b3a8796cdca419c3a0afaf22df4" - dependencies: - astw "^2.0.0" - -lodash._baseassign@^3.0.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz#8c38a099500f215ad09e59f1722fd0c52bfe0a4e" - dependencies: - lodash._basecopy "^3.0.0" - lodash.keys "^3.0.0" - -lodash._basecopy@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36" - -lodash._basecreate@^3.0.0: - version "3.0.3" - resolved "https://registry.yarnpkg.com/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz#1bc661614daa7fc311b7d03bf16806a0213cf821" - -lodash._getnative@^3.0.0: - version "3.9.1" - resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5" - -lodash._isiterateecall@^3.0.0: - version "3.0.9" - resolved "https://registry.yarnpkg.com/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz#5203ad7ba425fae842460e696db9cf3e6aac057c" - -lodash.create@3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/lodash.create/-/lodash.create-3.1.1.tgz#d7f2849f0dbda7e04682bb8cd72ab022461debe7" - dependencies: - lodash._baseassign "^3.0.0" - lodash._basecreate "^3.0.0" - lodash._isiterateecall "^3.0.0" - -lodash.isarguments@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a" - -lodash.isarray@^3.0.0: - version "3.0.4" - resolved "https://registry.yarnpkg.com/lodash.isarray/-/lodash.isarray-3.0.4.tgz#79e4eb88c36a8122af86f844aa9bcd851b5fbb55" - -lodash.keys@^3.0.0: - version "3.1.2" - resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-3.1.2.tgz#4dbc0472b156be50a0b286855d1bd0b0c656098a" - dependencies: - lodash._getnative "^3.0.0" - lodash.isarguments "^3.0.0" - lodash.isarray "^3.0.0" - -lodash.memoize@~3.0.3: - version "3.0.4" - resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-3.0.4.tgz#2dcbd2c287cbc0a55cc42328bd0c736150d53e3f" - -miller-rabin@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.0.tgz#4a62fb1d42933c05583982f4c716f6fb9e6c6d3d" - dependencies: - bn.js "^4.0.0" - brorand "^1.0.1" - -minimalistic-assert@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.0.tgz#702be2dda6b37f4836bcb3f5db56641b64a1d3d3" - -minimatch@^2.0.1: - version "2.0.10" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-2.0.10.tgz#8d087c39c6b38c001b97fca7ce6d0e1e80afbac7" - dependencies: - brace-expansion "^1.0.0" - -minimatch@^3.0.2: - version "3.0.3" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774" - dependencies: - brace-expansion "^1.0.0" - -minimist@^1.1.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" - -minimist@0.0.8: - version "0.0.8" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" - -mkdirp@0.5.1: - version "0.5.1" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" - dependencies: - minimist "0.0.8" - -mocha@*: - version "3.1.2" - resolved "https://registry.yarnpkg.com/mocha/-/mocha-3.1.2.tgz#51f93b432bf7e1b175ffc22883ccd0be32dba6b5" - dependencies: - browser-stdout "1.3.0" - commander "2.9.0" - debug "2.2.0" - diff "1.4.0" - escape-string-regexp "1.0.5" - glob "7.0.5" - growl "1.9.2" - json3 "3.3.2" - lodash.create "3.1.1" - mkdirp "0.5.1" - supports-color "3.1.2" - -module-deps@^3.7.0: - version "3.9.1" - resolved "https://registry.yarnpkg.com/module-deps/-/module-deps-3.9.1.tgz#ea75caf9199090d25b0d5512b5acacb96e7f87f3" - dependencies: - browser-resolve "^1.7.0" - concat-stream "~1.4.5" - defined "^1.0.0" - detective "^4.0.0" - duplexer2 "0.0.2" - inherits "^2.0.1" - JSONStream "^1.0.3" - parents "^1.0.0" - readable-stream "^1.1.13" - resolve "^1.1.3" - stream-combiner2 "~1.0.0" - subarg "^1.0.0" - through2 "^1.0.0" - xtend "^4.0.0" - -ms@0.7.1: - version "0.7.1" - resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098" - -ms@0.7.2: - version "0.7.2" - resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.2.tgz#ae25cf2512b3885a1d95d7f037868d8431124765" - -once@^1.3.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - dependencies: - wrappy "1" - -os-browserify@~0.1.1: - version "0.1.2" - resolved "https://registry.yarnpkg.com/os-browserify/-/os-browserify-0.1.2.tgz#49ca0293e0b19590a5f5de10c7f265a617d8fe54" - -pako@~0.2.0: - version "0.2.9" - resolved "https://registry.yarnpkg.com/pako/-/pako-0.2.9.tgz#f3f7522f4ef782348da8161bad9ecfd51bf83a75" - -parents@^1.0.0, parents@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/parents/-/parents-1.0.1.tgz#fedd4d2bf193a77745fe71e371d73c3307d9c751" - dependencies: - path-platform "~0.11.15" - -parse-asn1@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/parse-asn1/-/parse-asn1-5.0.0.tgz#35060f6d5015d37628c770f4e091a0b5a278bc23" - dependencies: - asn1.js "^4.0.0" - browserify-aes "^1.0.0" - create-hash "^1.1.0" - evp_bytestokey "^1.0.0" - pbkdf2 "^3.0.3" - -path-browserify@~0.0.0: - version "0.0.0" - resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-0.0.0.tgz#a0b870729aae214005b7d5032ec2cbbb0fb4451a" - -path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - -path-platform@~0.11.15: - version "0.11.15" - resolved "https://registry.yarnpkg.com/path-platform/-/path-platform-0.11.15.tgz#e864217f74c36850f0852b78dc7bf7d4a5721bf2" - -pbkdf2@^3.0.3: - version "3.0.9" - resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.0.9.tgz#f2c4b25a600058b3c3773c086c37dbbee1ffe693" - dependencies: - create-hmac "^1.1.2" - -process@^0.10.0: - version "0.10.1" - resolved "https://registry.yarnpkg.com/process/-/process-0.10.1.tgz#842457cc51cfed72dc775afeeafb8c6034372725" - -process@~0.11.0: - version "0.11.9" - resolved "https://registry.yarnpkg.com/process/-/process-0.11.9.tgz#7bd5ad21aa6253e7da8682264f1e11d11c0318c1" - -public-encrypt@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/public-encrypt/-/public-encrypt-4.0.0.tgz#39f699f3a46560dd5ebacbca693caf7c65c18cc6" - dependencies: - bn.js "^4.1.0" - browserify-rsa "^4.0.0" - create-hash "^1.1.0" - parse-asn1 "^5.0.0" - randombytes "^2.0.1" - -punycode@~1.2.3: - version "1.2.4" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.2.4.tgz#54008ac972aec74175def9cba6df7fa9d3918740" - -punycode@1.3.2: - version "1.3.2" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d" - -querystring-es3@~0.2.0: - version "0.2.1" - resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73" - -querystring@0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620" - -randombytes@^2.0.0, randombytes@^2.0.1: - version "2.0.3" - resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.0.3.tgz#674c99760901c3c4112771a31e521dc349cc09ec" - -readable-stream@^1.0.27-1, readable-stream@^1.1.13, readable-stream@^1.1.13-1, "readable-stream@>=1.1.13-1 <1.2.0-0", readable-stream@~1.1.9: - version "1.1.14" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9" - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.1" - isarray "0.0.1" - string_decoder "~0.10.x" - -readable-stream@~1.0.17: - version "1.0.34" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c" - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.1" - isarray "0.0.1" - string_decoder "~0.10.x" - -readable-wrap@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/readable-wrap/-/readable-wrap-1.0.0.tgz#3b5a211c631e12303a54991c806c17e7ae206bff" - dependencies: - readable-stream "^1.1.13-1" - -resolve@^1.1.3, resolve@^1.1.4, resolve@1.1.7: - version "1.1.7" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" - -ripemd160@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-1.0.1.tgz#93a4bbd4942bc574b69a8fa57c71de10ecca7d6e" - -sha.js@^2.3.6, sha.js@~2.4.4: - version "2.4.5" - resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.4.5.tgz#27d171efcc82a118b99639ff581660242b506e7c" - dependencies: - inherits "^2.0.1" - -shallow-copy@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/shallow-copy/-/shallow-copy-0.0.1.tgz#415f42702d73d810330292cc5ee86eae1a11a170" - -shasum@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/shasum/-/shasum-1.0.2.tgz#e7012310d8f417f4deb5712150e5678b87ae565f" - dependencies: - json-stable-stringify "~0.0.0" - sha.js "~2.4.4" - -shell-quote@~0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-0.0.1.tgz#1a41196f3c0333c482323593d6886ecf153dd986" - -source-map@~0.1.31: - version "0.1.43" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.1.43.tgz#c24bc146ca517c1471f5dacbe2571b2b7f9e3346" - dependencies: - amdefine ">=0.0.4" - -source-map@~0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.3.0.tgz#8586fb9a5a005e5b501e21cd18b6f21b457ad1f9" - dependencies: - amdefine ">=0.0.4" - -source-map@~0.4.0, source-map@~0.4.2: - version "0.4.4" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.4.4.tgz#eba4f5da9c0dc999de68032d8b4f76173652036b" - dependencies: - amdefine ">=0.0.4" - -stream-browserify@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/stream-browserify/-/stream-browserify-1.0.0.tgz#bf9b4abfb42b274d751479e44e0ff2656b6f1193" - dependencies: - inherits "~2.0.1" - readable-stream "^1.0.27-1" - -stream-combiner2@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/stream-combiner2/-/stream-combiner2-1.0.2.tgz#ba72a6b50cbfabfa950fc8bc87604bd01eb60671" - dependencies: - duplexer2 "~0.0.2" - through2 "~0.5.1" - -stream-splicer@^1.1.0: - version "1.3.2" - resolved "https://registry.yarnpkg.com/stream-splicer/-/stream-splicer-1.3.2.tgz#3c0441be15b9bf4e226275e6dc83964745546661" - dependencies: - indexof "0.0.1" - inherits "^2.0.1" - isarray "~0.0.1" - readable-stream "^1.1.13-1" - readable-wrap "^1.0.0" - through2 "^1.0.0" - -string_decoder@~0.10.0, string_decoder@~0.10.x: - version "0.10.31" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" - -subarg@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/subarg/-/subarg-1.0.0.tgz#f62cf17581e996b48fc965699f54c06ae268b8d2" - dependencies: - minimist "^1.1.0" - -supports-color@3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.1.2.tgz#72a262894d9d408b956ca05ff37b2ed8a6e2a2d5" - dependencies: - has-flag "^1.0.0" - -syntax-error@^1.1.1: - version "1.1.6" - resolved "https://registry.yarnpkg.com/syntax-error/-/syntax-error-1.1.6.tgz#b4549706d386cc1c1dc7c2423f18579b6cade710" - dependencies: - acorn "^2.7.0" - -"through@>=2.2.7 <3": - version "2.3.8" - resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" - -through2@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/through2/-/through2-1.1.1.tgz#0847cbc4449f3405574dbdccd9bb841b83ac3545" - dependencies: - readable-stream ">=1.1.13-1 <1.2.0-0" - xtend ">=4.0.0 <4.1.0-0" - -through2@~0.5.1: - version "0.5.1" - resolved "https://registry.yarnpkg.com/through2/-/through2-0.5.1.tgz#dfdd012eb9c700e2323fd334f38ac622ab372da7" - dependencies: - readable-stream "~1.0.17" - xtend "~3.0.0" - -timers-browserify@^1.0.1: - version "1.4.2" - resolved "https://registry.yarnpkg.com/timers-browserify/-/timers-browserify-1.4.2.tgz#c9c58b575be8407375cb5e2462dacee74359f41d" - dependencies: - process "~0.11.0" - -tty-browserify@~0.0.0: - version "0.0.0" - resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6" - -typedarray@~0.0.5: - version "0.0.6" - resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" - -umd@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/umd/-/umd-3.0.1.tgz#8ae556e11011f63c2596708a8837259f01b3d60e" - -url@~0.10.1: - version "0.10.3" - resolved "https://registry.yarnpkg.com/url/-/url-0.10.3.tgz#021e4d9c7705f21bbf37d03ceb58767402774c64" - dependencies: - punycode "1.3.2" - querystring "0.2.0" - -util@~0.10.1, util@0.10.3: - version "0.10.3" - resolved "https://registry.yarnpkg.com/util/-/util-0.10.3.tgz#7afb1afe50805246489e3db7fe0ed379336ac0f9" - dependencies: - inherits "2.0.1" - -vm-browserify@~0.0.1: - version "0.0.4" - resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-0.0.4.tgz#5d7ea45bbef9e4a6ff65f95438e0a87c357d5a73" - dependencies: - indexof "0.0.1" - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - -xtend@^3.0.0, xtend@~3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/xtend/-/xtend-3.0.0.tgz#5cce7407baf642cba7becda568111c493f59665a" - -xtend@^4.0.0, "xtend@>=4.0.0 <4.1.0-0": - version "4.0.1" - resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" - From d26711169f97188af5600ce48897e6332cb6b024 Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Wed, 9 Nov 2016 15:01:07 -0800 Subject: [PATCH 024/257] Add a switch to flip between electron and node --- index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 index.js diff --git a/index.js b/index.js new file mode 100644 index 00000000..8d3a3186 --- /dev/null +++ b/index.js @@ -0,0 +1,10 @@ +/** + * Detect Electron renderer process, which is node, but we should + * treat as a browser. + */ + +if ((process || {}).type === 'renderer') { + module.exports = require('./browser'); +} else { + module.exports = require('./node'); +} From 2ba1323100b915bdd6d51534c67d13d6669fdb7b Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Wed, 9 Nov 2016 15:01:14 -0800 Subject: [PATCH 025/257] Wire it up --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5ab1c1c6..318c79d9 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "browserify": "9.0.3", "mocha": "*" }, - "main": "./node.js", + "main": "./index.js", "browser": "./browser.js", "component": { "scripts": { From dc86779d521186c444cee37cc712f23c3f6db886 Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Wed, 9 Nov 2016 15:01:46 -0800 Subject: [PATCH 026/257] If we're in Electron, try to fallback to process.env.DEBUG if we've got it --- browser.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/browser.js b/browser.js index a31d6ff3..d82e9176 100644 --- a/browser.js +++ b/browser.js @@ -142,6 +142,12 @@ function load() { try { r = exports.storage.debug; } catch(e) {} + + // If debug isn't set in LS, and we're in Electron, try to load $DEBUG + if ('env' in (process || {})) { + r = process.env.DEBUG; + } + return r; } From 6d2cd136beeda6f58c6ed24c4ffabd07d3c5c721 Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Wed, 9 Nov 2016 15:53:17 -0800 Subject: [PATCH 027/257] Save a stat --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 8d3a3186..b8bcd909 100644 --- a/index.js +++ b/index.js @@ -4,7 +4,7 @@ */ if ((process || {}).type === 'renderer') { - module.exports = require('./browser'); + module.exports = require('./browser.js'); } else { - module.exports = require('./node'); + module.exports = require('./node.js'); } From 6b45c3a15510ad67a9bc79b1309c1e75c3ab6e0a Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Wed, 9 Nov 2016 16:13:31 -0800 Subject: [PATCH 028/257] Release 2.3.1 --- CHANGELOG.md | 7 +++++++ component.json | 2 +- package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee049555..3d93b4de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +2.3.1 / 2016-11-09 +================== + + * Fix: Added electron compatibility (#324, @paulcbetts) + * Improvement: Added performance optimizations (@tootallnate) + * Readme: Corrected PowerShell environment variable example (#252, @gimre) + * Misc: Removed yarn lock file from source control (#321, @fengmk2) 2.3.0 / 2016-11-07 ================== diff --git a/component.json b/component.json index ca106372..3fb0e887 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "debug", "repo": "visionmedia/debug", "description": "small debugging utility", - "version": "2.2.0", + "version": "2.3.1", "keywords": [ "debug", "log", diff --git a/package.json b/package.json index 318c79d9..00c9a285 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "2.3.0", + "version": "2.3.1", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From 0b6ca275e61125d001a5dd2c7782b67433084049 Mon Sep 17 00:00:00 2001 From: Tom Newby Date: Thu, 10 Nov 2016 12:46:44 +1000 Subject: [PATCH 029/257] fix(browser): should check whether process exists Closes #325. --- browser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser.js b/browser.js index d82e9176..095a0451 100644 --- a/browser.js +++ b/browser.js @@ -144,7 +144,7 @@ function load() { } catch(e) {} // If debug isn't set in LS, and we're in Electron, try to load $DEBUG - if ('env' in (process || {})) { + if ('env' in (typeof process === 'undefined' ? {} : process)) { r = process.env.DEBUG; } From 56fd3366c20a812fe2de7d4dbdac43d2823f9ee9 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Wed, 9 Nov 2016 22:27:37 -0800 Subject: [PATCH 030/257] be super-safe in index.js as well --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index b8bcd909..8a39392c 100644 --- a/index.js +++ b/index.js @@ -3,7 +3,7 @@ * treat as a browser. */ -if ((process || {}).type === 'renderer') { +if ((typeof process === 'undefined' ? {} : process).type === 'renderer') { module.exports = require('./browser.js'); } else { module.exports = require('./node.js'); From 1c6f45840d0dba8cb14f9975b4633bb685fda400 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Wed, 9 Nov 2016 22:29:51 -0800 Subject: [PATCH 031/257] Release 2.3.2 --- CHANGELOG.md | 6 ++++++ component.json | 2 +- package.json | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d93b4de..d5bb0ac3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +2.3.2 / 2016-11-09 +================== + + * Fix: be super-safe in index.js as well (@TooTallNate) + * Fix: should check whether process exists (Tom Newby) + 2.3.1 / 2016-11-09 ================== diff --git a/component.json b/component.json index 3fb0e887..eb399b78 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "debug", "repo": "visionmedia/debug", "description": "small debugging utility", - "version": "2.3.1", + "version": "2.3.2", "keywords": [ "debug", "log", diff --git a/package.json b/package.json index 00c9a285..2ef4c448 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "2.3.1", + "version": "2.3.2", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From a746d52cf2eecb63df3025f2f469b2e06cf70196 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Thu, 10 Nov 2016 09:59:27 -0800 Subject: [PATCH 032/257] don't create an empty object when no `process` This is also more readable in my opinion. --- browser.js | 2 +- index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/browser.js b/browser.js index 095a0451..26070efe 100644 --- a/browser.js +++ b/browser.js @@ -144,7 +144,7 @@ function load() { } catch(e) {} // If debug isn't set in LS, and we're in Electron, try to load $DEBUG - if ('env' in (typeof process === 'undefined' ? {} : process)) { + if (typeof process !== 'undefined' && 'env' in process) { r = process.env.DEBUG; } diff --git a/index.js b/index.js index 8a39392c..e12cf4d5 100644 --- a/index.js +++ b/index.js @@ -3,7 +3,7 @@ * treat as a browser. */ -if ((typeof process === 'undefined' ? {} : process).type === 'renderer') { +if (typeof process !== 'undefined' && process.type === 'renderer') { module.exports = require('./browser.js'); } else { module.exports = require('./node.js'); From 20c37fdc169eeb42f34d22b11362f66a6a64b19e Mon Sep 17 00:00:00 2001 From: Levi Thomason Date: Sun, 13 Nov 2016 10:26:59 -0800 Subject: [PATCH 033/257] fix(browser): do not override ls debug if found --- browser.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/browser.js b/browser.js index 26070efe..aeb1e214 100644 --- a/browser.js +++ b/browser.js @@ -140,15 +140,13 @@ function save(namespaces) { function load() { var r; try { - r = exports.storage.debug; + return exports.storage.debug; } catch(e) {} // If debug isn't set in LS, and we're in Electron, try to load $DEBUG if (typeof process !== 'undefined' && 'env' in process) { - r = process.env.DEBUG; + return process.env.DEBUG; } - - return r; } /** From 8e09edf8f632717595ebfc0894c8d803d15e8576 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Mon, 14 Nov 2016 16:31:44 -0800 Subject: [PATCH 034/257] browser: whitespace --- browser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser.js b/browser.js index f0a6614c..016189a7 100644 --- a/browser.js +++ b/browser.js @@ -55,7 +55,7 @@ function useColors() { exports.formatters.j = function(v) { try { return JSON.stringify(v); - }catch( err){ + } catch (err) { return '[UnexpectedJSONParseError]: ' + err.message; } }; From 3ad8df75614cd4306709ad73519fd579971fb8d9 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Sat, 19 Nov 2016 11:59:10 -0800 Subject: [PATCH 035/257] Release 2.3.3 --- CHANGELOG.md | 7 +++++++ component.json | 2 +- package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5bb0ac3..1c8c5537 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +2.3.3 / 2016-11-09 +================== + + * Fix: Catch `JSON.stringify()` errors (#195, Jovan Alleyne) + * Fix: Returning `localStorage` saved values (#331, Levi Thomason) + * Improvement: Don't create an empty object when no `process` (Nathan Rajlich) + 2.3.2 / 2016-11-09 ================== diff --git a/component.json b/component.json index eb399b78..582c2e9d 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "debug", "repo": "visionmedia/debug", "description": "small debugging utility", - "version": "2.3.2", + "version": "2.3.3", "keywords": [ "debug", "log", diff --git a/package.json b/package.json index 2ef4c448..e59512a6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "2.3.2", + "version": "2.3.3", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From e2a1955330acc155cd6e92580d9ec74f3d55f09b Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Mon, 21 Nov 2016 19:16:12 -0800 Subject: [PATCH 036/257] Revert "handle regex special characters" This reverts commit 8dd8345d1498b8c6a3c6d7f7f4ebc600cfd2195b. We shouldn't have changed the original behavior, which too many people are relying on at this point. It's also technically a breaking change, which we shouldn't have landed on a minor/patch version change. So in the interest of not breaking people's logs in production, reverting this. We can discuss in a new issue if we want to restore this patch for a `v3` release, but at the moment I'm personally leaningo towards *no*, for historical reasons (i.e. this is reminding me of Node.js trying to remove `sys` if anybody reading this remembers those days). See the discussion in #250 for more backlog. --- debug.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debug.js b/debug.js index a5992a44..6e9f5213 100644 --- a/debug.js +++ b/debug.js @@ -144,7 +144,7 @@ function enable(namespaces) { for (var i = 0; i < len; i++) { if (!split[i]) continue; // ignore empty strings - namespaces = split[i].replace(/[\\^$+?.()|[\]{}]/g, '\\$&').replace(/\*/g, '.*?'); + namespaces = split[i].replace(/\*/g, '.*?'); if (namespaces[0] === '-') { exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); } else { From 501521fcc60685b844af06f7c6aa239d5f532f45 Mon Sep 17 00:00:00 2001 From: Laurent Date: Tue, 6 Dec 2016 18:54:01 +0100 Subject: [PATCH 037/257] Use same color for same namespace. (#338) * Use same color for same namespace. CF #258 * Remove unused var. --- debug.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/debug.js b/debug.js index 6e9f5213..b7fc5176 100644 --- a/debug.js +++ b/debug.js @@ -42,13 +42,20 @@ var prevTime; /** * Select a color. - * + * @param {String} namespace * @return {Number} * @api private */ -function selectColor() { - return exports.colors[prevColor++ % exports.colors.length]; +function selectColor(namespace) { + var hash = 0, i; + + for (i in namespace) { + hash = ((hash << 5) - hash) + namespace.charCodeAt(i); + hash |= 0; // Convert to 32bit integer + } + + return exports.colors[Math.abs(hash) % exports.colors.length]; } /** @@ -81,7 +88,7 @@ function debug(namespace) { // add the `color` if not set if (null == self.useColors) self.useColors = exports.useColors(); - if (null == self.color && self.useColors) self.color = selectColor(); + if (null == self.color && self.useColors) self.color = selectColor(namespace); var args = new Array(arguments.length); for (var i = 0; i < args.length; i++) { From bd9faa1289fad6557bfcad7f7db0fb49d9921871 Mon Sep 17 00:00:00 2001 From: Alfonso de la Osa Date: Mon, 12 Dec 2016 07:23:39 +0000 Subject: [PATCH 038/257] allow colours in workers (#335) --- browser.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/browser.js b/browser.js index 016189a7..3f63ab23 100644 --- a/browser.js +++ b/browser.js @@ -42,10 +42,12 @@ function useColors() { // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 return (typeof document !== 'undefined' && 'WebkitAppearance' in document.documentElement.style) || // is firebug? http://stackoverflow.com/a/398120/376773 - (window.console && (console.firebug || (console.exception && console.table))) || + (typeof window !== 'undefined' && window.console && (console.firebug || (console.exception && console.table))) || // is firefox >= v31? // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31); + (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || + // double check webkit in userAgent just in case we are in a worker + (navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); } /** From 00f3046c30eb6462123d1e68e5520d62ef19a996 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Mon, 12 Dec 2016 11:13:19 -0800 Subject: [PATCH 039/257] Node: `%O` (big O) pretty-prints the object (#322) * %O (big O) pretty-prints the object For example: ```js var debug = require('./')('foo') var o = { foo: 'bar', b: new Buffer(10), c: Math.PI } debug('%O', o) ``` Previously: ``` foo { foo: 'bar', b: , c: 3.141592653589793 } +0ms ``` Now: ``` foo { foo: 'bar', foo b: , foo c: 3.141592653589793 } +0ms ``` This is a breaking change for anybody relying on the old `%O` behavior. Though I don't think `%O` was working previously because the formatters regexp wasn't checking for uppercase formatters (now fixed in this patch). * use %O by default if no formatting string is given * Readme: add Formatters section Fixes #302. * Readme: finish custom formatters example --- Readme.md | 30 ++++++++++++++++++++++++++++++ debug.js | 6 +++--- node.js | 11 +++++++---- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/Readme.md b/Readme.md index 9e80851f..7ee4d081 100644 --- a/Readme.md +++ b/Readme.md @@ -87,6 +87,36 @@ Then, run the program to be debugged as usual. You can also exclude specific debuggers by prefixing them with a "-" character. For example, `DEBUG=*,-connect:*` would include all debuggers except those starting with "connect:". +## Formatters + + + Debug uses [printf-style](https://wikipedia.org/wiki/Printf_format_string) formatting. Below are the officially supported formatters: + +| Formatter | Representation | +|-----------|----------------| +| `%O` | Pretty-print an Object on multiple lines. | +| `%o` | Pretty-print an Object all on a single line. | +| `%s` | String. | +| `%d` | Number (both integer and float). | +| `%j` | JSON. Replaced with the string '[Circular]' if the argument contains circular references. | +| `%%` | Single percent sign ('%'). This does not consume an argument. | + +### Custom formatters + + You can add custom formatters by extending the `debug.formatters` object. For example, if you wanted to add support for rendering a Buffer as hex with `%h`, you could do something like: + +```js +const createDebug = require('debug') +createDebug.formatters.h = (v) => { + return v.toString('hex') +} + +// …elsewhere +const debug = createDebug('foo') +debug('this is hex: %h', new Buffer('hello world')) +// foo this is hex: 68656c6c6f20776f726c6421 +0ms +``` + ## Browser support Debug works in the browser as well, currently persisted by `localStorage`. Consider the situation shown below where you have `worker:a` and `worker:b`, and wish to debug both. You can enable this using `localStorage.debug`: diff --git a/debug.js b/debug.js index b7fc5176..6664947c 100644 --- a/debug.js +++ b/debug.js @@ -98,13 +98,13 @@ function debug(namespace) { args[0] = exports.coerce(args[0]); if ('string' !== typeof args[0]) { - // anything else let's inspect with %o - args = ['%o'].concat(args); + // anything else let's inspect with %O + args.unshift('%O'); } // apply any `formatters` transformations var index = 0; - args[0] = args[0].replace(/%([a-z%])/g, function(match, format) { + args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) { // if we encounter an escaped % then don't increase the array index if (match === '%%') return match; index++; diff --git a/node.js b/node.js index 01e9fad5..1f5cd7ed 100644 --- a/node.js +++ b/node.js @@ -68,11 +68,15 @@ var inspect = (4 === util.inspect.length ? } ); -exports.formatters.o = exports.formatters.O = function(v) { +exports.formatters.o = function(v) { return inspect(v, this.useColors) .replace(/\s*\n\s*/g, ' '); }; +exports.formatters.O = function(v) { + return inspect(v, this.useColors); +}; + /** * Adds ANSI color escape codes if enabled. * @@ -90,10 +94,9 @@ function formatArgs() { if (useColors) { var c = this.color; + var prefix = ' \u001b[3' + c + ';1m' + name + ' ' + '\u001b[0m'; - args[0] = ' \u001b[3' + c + ';1m' + name + ' ' - + '\u001b[0m' - + args[0]; + args[0] = prefix + args[0].split('\n').join('\n' + prefix); args.push('\u001b[3' + c + 'm+' + exports.humanize(this.diff) + '\u001b[0m'); } else { args[0] = new Date().toUTCString() From e58d54b46f6b446afd5262d67faea2308e952908 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Mon, 12 Dec 2016 15:13:35 -0800 Subject: [PATCH 040/257] Node: configurable `util.inspect()` options (#327) * `formatArgs()` gets passed the args Array directly Rather than working on `arguments`. The Node.js version was for some reason turning the arguments into an Array again so it was happening twice! This should make things faster overall. * whitespace * rename `Readme.md` to `README.md` * refactor the `debug()` constructor a bit Now, debug instances are hot-enabelable. That is, you can toggle the `debug.enabled` boolean on instances to enable or disable an instance. There is still no global version of this functionality. Now all instances get a `useColors` and `colors` property, even disabled ones, in case they get enabled later on. Boot-up time impact should be negligible. * node: allow configurable `util.inspect()` options Via env variables by default. So to get more object depth, you pass the `DEBUG_DEPTH=10` env var. For the `showHidden` option, you set `DEBUG_SHOW_HIDDEN=on`. See the Node.js docs for the complete list of `util.inspect()` options: https://nodejs.org/api/util.html#util_util_inspect_object_options * README: document inspect env variables --- Readme.md => README.md | 30 ++++++++++---- browser.js | 7 +--- debug.js | 40 +++++++++---------- node.js | 88 ++++++++++++++++++++++++++---------------- 4 files changed, 98 insertions(+), 67 deletions(-) rename Readme.md => README.md (83%) diff --git a/Readme.md b/README.md similarity index 83% rename from Readme.md rename to README.md index 7ee4d081..e46d8f22 100644 --- a/Readme.md +++ b/README.md @@ -79,7 +79,7 @@ Then, run the program to be debugged as usual. ## Conventions - If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". + If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". ## Wildcards @@ -87,6 +87,28 @@ Then, run the program to be debugged as usual. You can also exclude specific debuggers by prefixing them with a "-" character. For example, `DEBUG=*,-connect:*` would include all debuggers except those starting with "connect:". +## Environment Variables + + When running through Node.js, you can set a few environment variables that will + change the behavior of the debug logging: + +| Name | Purpose | +|-----------|-------------------------------------------------| +| `DEBUG` | Enables/disabled specific debugging namespaces. | +| `DEBUG_COLORS`| Whether or not to use colors in the debug output. | +| `DEBUG_FD`| File descriptor to output debug logs to. Defaults to stderr. | +| `DEBUG_DEPTH` | Object inspection depth. | +| `DEBUG_SHOW_HIDDEN` | Shows hidden properties on inspected objects. | + + + __Note:__ The environment variables beginning with `DEBUG_` end up being + converted into an Options object that gets used with `%o`/`%O` formatters. + See the Node.js documentation for + [`util.inspect()`](https://nodejs.org/api/util.html#util_util_inspect_object_options) + for the complete list. + + __Note:__ Certain IDEs (such as WebStorm) don't support colors on stderr. In these cases you must set `DEBUG_COLORS` to `1` and additionally change `DEBUG_FD` to `1`. + ## Formatters @@ -191,12 +213,6 @@ Example: $ DEBUG_FD=3 node your-app.js 3> whatever.log ``` -### Terminal colors - - By default colors will only be used in a TTY. However this can be overridden by setting the environment variable `DEBUG_COLORS` to `1`. - - Note: Certain IDEs (such as WebStorm) don't support colors on stderr. In these cases you must set `DEBUG_COLORS` to `1` and additionally change `DEBUG_FD` to `1`. - ## Authors - TJ Holowaychuk diff --git a/browser.js b/browser.js index 3f63ab23..2963b23c 100644 --- a/browser.js +++ b/browser.js @@ -1,4 +1,3 @@ - /** * This is the web browser implementation of `debug()`. * @@ -69,8 +68,7 @@ exports.formatters.j = function(v) { * @api public */ -function formatArgs() { - var args = arguments; +function formatArgs(args) { var useColors = this.useColors; args[0] = (useColors ? '%c' : '') @@ -101,7 +99,6 @@ function formatArgs() { }); args.splice(lastC, 0, c); - return args; } /** @@ -172,7 +169,7 @@ exports.enable(load()); * @api private */ -function localstorage(){ +function localstorage() { try { return window.localStorage; } catch (e) {} diff --git a/debug.js b/debug.js index 6664947c..fc634f7e 100644 --- a/debug.js +++ b/debug.js @@ -6,7 +6,7 @@ * Expose `debug()` as the module. */ -exports = module.exports = debug.debug = debug; +exports = module.exports = createDebug.debug = createDebug.default = createDebug; exports.coerce = coerce; exports.disable = disable; exports.enable = enable; @@ -23,7 +23,7 @@ exports.skips = []; /** * Map of special "%n" handling functions, for the debug "format" argument. * - * Valid key names are a single, lowercased letter, i.e. "n". + * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". */ exports.formatters = {}; @@ -66,17 +66,13 @@ function selectColor(namespace) { * @api public */ -function debug(namespace) { +function createDebug(namespace) { - // define the `disabled` version - function disabled() { - } - disabled.enabled = false; - - // define the `enabled` version - function enabled() { + function debug() { + // disabled? + if (!debug.enabled) return; - var self = enabled; + var self = debug; // set `diff` timestamp var curr = +new Date(); @@ -86,10 +82,7 @@ function debug(namespace) { self.curr = curr; prevTime = curr; - // add the `color` if not set - if (null == self.useColors) self.useColors = exports.useColors(); - if (null == self.color && self.useColors) self.color = selectColor(namespace); - + // turn the `arguments` into a proper Array var args = new Array(arguments.length); for (var i = 0; i < args.length; i++) { args[i] = arguments[i]; @@ -120,19 +113,24 @@ function debug(namespace) { return match; }); - // apply env-specific formatting - args = exports.formatArgs.apply(self, args); + // apply env-specific formatting (colors, etc.) + exports.formatArgs.call(self, args); var logFn = enabled.log || exports.log || console.log.bind(console); logFn.apply(self, args); } - enabled.enabled = true; - var fn = exports.enabled(namespace) ? enabled : disabled; + debug.namespace = namespace; + debug.enabled = exports.enabled(namespace); + debug.useColors = exports.useColors(); + debug.color = selectColor(namespae); - fn.namespace = namespace; + // env-specific initialization logic for debug instances + if ('function' === typeof exports.init) { + exports.init(debug); + } - return fn; + return debug; } /** diff --git a/node.js b/node.js index 1f5cd7ed..15bf55af 100644 --- a/node.js +++ b/node.js @@ -1,4 +1,3 @@ - /** * Module dependencies. */ @@ -13,6 +12,7 @@ var util = require('util'); */ exports = module.exports = require('./debug'); +exports.init = init; exports.log = log; exports.formatArgs = formatArgs; exports.save = save; @@ -25,6 +25,32 @@ exports.useColors = useColors; exports.colors = [6, 2, 3, 4, 5, 1]; +/** + * Build up the default `inspectOpts` object from the environment variables. + * + * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js + */ + +exports.inspectOpts = Object.keys(process.env).filter(function (key) { + return /^debug_/i.test(key); +}).reduce(function (obj, key) { + // camel-case + var prop = key + .substring(6) + .toLowerCase() + .replace(/_([a-z])/, function (_, k) { return k.toUpperCase() }); + + // coerce string value into JS value + var val = process.env[key]; + if (/^(yes|on|true|enabled)$/i.test(val)) val = true; + else if (/^(no|off|false|disabled)$/i.test(val)) val = false; + else if (val === 'null') val = null; + else val = Number(val); + + obj[prop] = val; + return obj; +}, {}); + /** * The file descriptor to write the `debug()` calls to. * Set the `DEBUG_FD` env variable to override with another value. i.e.: @@ -42,39 +68,28 @@ var stream = 1 === fd ? process.stdout : */ function useColors() { - var debugColors = (process.env.DEBUG_COLORS || '').trim().toLowerCase(); - if (0 === debugColors.length) { - return tty.isatty(fd); - } else { - return '0' !== debugColors - && 'no' !== debugColors - && 'false' !== debugColors - && 'disabled' !== debugColors; - } + return 'colors' in exports.inspectOpts + ? Boolean(exports.inspectOpts.colors) + : tty.isatty(fd); } /** - * Map %o to `util.inspect()`, since Node doesn't do that out of the box. + * Map %o to `util.inspect()`, all on a single line. */ -var inspect = (4 === util.inspect.length ? - // node <= 0.8.x - function (v, colors) { - return util.inspect(v, void 0, void 0, colors); - } : - // node > 0.8.x - function (v, colors) { - return util.inspect(v, { colors: colors }); - } -); - exports.formatters.o = function(v) { - return inspect(v, this.useColors) + this.inspectOpts.colors = this.useColors; + return util.inspect(v, this.inspectOpts) .replace(/\s*\n\s*/g, ' '); }; +/** + * Map %o to `util.inspect()`, allowing multiple lines if needed. + */ + exports.formatters.O = function(v) { - return inspect(v, this.useColors); + this.inspectOpts.colors = this.useColors; + return util.inspect(v, this.inspectOpts); }; /** @@ -83,14 +98,9 @@ exports.formatters.O = function(v) { * @api public */ -function formatArgs() { - var len = arguments.length; - var args = new Array(len); - var useColors = this.useColors; +function formatArgs(args) { var name = this.namespace; - for (var i = 0; i < len; i++) { - args[i] = arguments[i]; - } + var useColors = this.useColors; if (useColors) { var c = this.color; @@ -102,15 +112,14 @@ function formatArgs() { args[0] = new Date().toUTCString() + ' ' + name + ' ' + args[0]; } - return args; } /** - * Invokes `console.error()` with the specified arguments. + * Invokes `util.format()` with the specified arguments and writes to `stream`. */ function log() { - return stream.write(util.format.apply(this, arguments) + '\n'); + return stream.write(util.format.apply(util, arguments) + '\n'); } /** @@ -209,6 +218,17 @@ function createWritableStdioStream (fd) { return stream; } +/** + * Init logic for `debug` instances. + * + * Create a new `inspectOpts` object in case `useColors` is set + * differently for a particular `debug` instance. + */ + +function init (debug) { + debug.inspectOpts = util._extend({}, exports.inspectOpts); +} + /** * Enable namespaces listed in `process.env.DEBUG` initially. */ From 41002f1c7cf6fe2533de1a9400e68007a80d7204 Mon Sep 17 00:00:00 2001 From: Matt Campbell Date: Mon, 12 Dec 2016 18:13:53 -0500 Subject: [PATCH 041/257] Update bower.json (#342) Error thrown if using `bower.json` to require files. `.npmignore` contains `dist`. --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 7a1a5a8f..073ecfcf 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "visionmedia-debug", - "main": "dist/debug.js", + "main": "./debug.js", "homepage": "https://github.com/visionmedia/debug", "authors": [ "TJ Holowaychuk ", From b82d4e6c799198b3d39b05265bf68da9a9aacd41 Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Tue, 13 Dec 2016 22:51:43 -0800 Subject: [PATCH 042/257] release 2.4.0 --- CHANGELOG.md | 11 +++++++++++ component.json | 2 +- package.json | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c8c5537..facd10f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ + +2.4.0 / 2016-12-13 +================== + + * Fix: bower.json references unbuilt src entry point (#342, @justmatt) + * Fix: revert "handle regex special characters" (@tootallnate) + * Feature: configurable util.inspect()`options for NodeJS (#327, @tootallnate) + * Feature: %O`(big O) pretty-prints objects (#322, @tootallnate) + * Improvement: allow colors in workers (#335, @botverse) + * Improvement: use same color for same namespace. (#338, @lchenay) + 2.3.3 / 2016-11-09 ================== diff --git a/component.json b/component.json index 582c2e9d..8e5f3977 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "debug", "repo": "visionmedia/debug", "description": "small debugging utility", - "version": "2.3.3", + "version": "2.4.0", "keywords": [ "debug", "log", diff --git a/package.json b/package.json index e59512a6..174d8780 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "2.3.3", + "version": "2.4.0", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From 94d78b5b80fb1282dcf97b739cd58402dbeeec14 Mon Sep 17 00:00:00 2001 From: Lazarev Alexandr Date: Wed, 14 Dec 2016 10:21:11 +0300 Subject: [PATCH 043/257] Fixed a typo (#356) --- debug.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/debug.js b/debug.js index fc634f7e..4ea6d93e 100644 --- a/debug.js +++ b/debug.js @@ -49,12 +49,12 @@ var prevTime; function selectColor(namespace) { var hash = 0, i; - + for (i in namespace) { hash = ((hash << 5) - hash) + namespace.charCodeAt(i); hash |= 0; // Convert to 32bit integer } - + return exports.colors[Math.abs(hash) % exports.colors.length]; } @@ -123,7 +123,7 @@ function createDebug(namespace) { debug.namespace = namespace; debug.enabled = exports.enabled(namespace); debug.useColors = exports.useColors(); - debug.color = selectColor(namespae); + debug.color = selectColor(namespace); // env-specific initialization logic for debug instances if ('function' === typeof exports.init) { From 803fb05785675e262feb37546858c411b56dc35a Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Tue, 13 Dec 2016 23:22:03 -0800 Subject: [PATCH 044/257] release 2.4.1 --- CHANGELOG.md | 5 +++++ component.json | 2 +- package.json | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index facd10f0..d371f4e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ +2.4.1 / 2016-12-13 +================== + + * Fixed a typo that broke the package (#356) + 2.4.0 / 2016-12-13 ================== diff --git a/component.json b/component.json index 8e5f3977..c5d88618 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "debug", "repo": "visionmedia/debug", "description": "small debugging utility", - "version": "2.4.0", + "version": "2.4.1", "keywords": [ "debug", "log", diff --git a/package.json b/package.json index 174d8780..18d69eb0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "2.4.0", + "version": "2.4.1", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From f77ca5d56c06a98cd81ade020a2ffbf2c73940a6 Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Wed, 14 Dec 2016 00:16:55 -0800 Subject: [PATCH 045/257] added linting and testing boilerplate with sanity check --- .babelrc | 4 ++++ .eslintrc | 15 +++++++++++++++ .jshintrc | 3 --- Makefile | 13 ++++++++++++- debug.js | 6 ------ package.json | 12 +++++++++++- test/debug_spec.js | 12 ++++++++++++ test/mocha.opts | 1 + 8 files changed, 55 insertions(+), 11 deletions(-) create mode 100644 .babelrc create mode 100644 .eslintrc delete mode 100644 .jshintrc create mode 100644 test/debug_spec.js create mode 100644 test/mocha.opts diff --git a/.babelrc b/.babelrc new file mode 100644 index 00000000..1b790bfa --- /dev/null +++ b/.babelrc @@ -0,0 +1,4 @@ +{ + "presets": ["es2015"], + "sourceMaps": true +} diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000..21bfbb5a --- /dev/null +++ b/.eslintrc @@ -0,0 +1,15 @@ +{ + "parserOptions": { + "ecmaVersion": 6, + "sourceType": "module" + }, + "parser": "babel-eslint", + "env": { + "browser": true, + "node": true + }, + "rules": { + "no-console": 0 + }, + "extends": "eslint:recommended" +} diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 299877f2..00000000 --- a/.jshintrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "laxbreak": true -} diff --git a/Makefile b/Makefile index db71cafc..19716b29 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,3 @@ - # get Makefile directory name: http://stackoverflow.com/a/5982798/376773 THIS_MAKEFILE_PATH:=$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) THIS_DIR:=$(shell cd $(dir $(THIS_MAKEFILE_PATH));pwd) @@ -6,12 +5,18 @@ THIS_DIR:=$(shell cd $(dir $(THIS_MAKEFILE_PATH));pwd) # BIN directory BIN := $(THIS_DIR)/node_modules/.bin +# Path +PATH := node_modules/.bin:$(PATH) +SHELL := /bin/bash + # applications NODE ?= $(shell which node) YARN ?= $(shell which yarn) PKG ?= $(if $(YARN),$(YARN),$(NODE) $(shell which npm)) BROWSERIFY ?= $(NODE) $(BIN)/browserify +.FORCE: + all: dist/debug.js install: node_modules @@ -33,5 +38,11 @@ distclean: clean node_modules: package.json @NODE_ENV= $(PKG) install @touch node_modules + +lint: .FORCE + eslint debug.js + +test: .FORCE + mocha .PHONY: all install clean distclean diff --git a/debug.js b/debug.js index 4ea6d93e..7b0632db 100644 --- a/debug.js +++ b/debug.js @@ -28,12 +28,6 @@ exports.skips = []; exports.formatters = {}; -/** - * Previously assigned color. - */ - -var prevColor = 0; - /** * Previous log timestamp. */ diff --git a/package.json b/package.json index 18d69eb0..5dd407ac 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,18 @@ "ms": "0.7.2" }, "devDependencies": { + "babel": "^6.5.2", + "babel-eslint": "^7.1.1", + "babel-polyfill": "^6.20.0", + "babel-preset-es2015": "^6.18.0", + "babel-register": "^6.18.0", + "babel-runtime": "^6.20.0", "browserify": "9.0.3", - "mocha": "*" + "chai": "^3.5.0", + "eslint": "^3.12.1", + "eslint-plugin-babel": "^4.0.0", + "mocha": "^3.2.0", + "sinon": "^1.17.6" }, "main": "./index.js", "browser": "./browser.js", diff --git a/test/debug_spec.js b/test/debug_spec.js new file mode 100644 index 00000000..b0339218 --- /dev/null +++ b/test/debug_spec.js @@ -0,0 +1,12 @@ +import { expect } from 'chai'; + +import debug from '../index'; + +describe('debug', () => { + describe('sanity check', () => { + it('passes', () => { + const log = debug('test'); + log('hello world'); + }); + }); +}) diff --git a/test/mocha.opts b/test/mocha.opts new file mode 100644 index 00000000..6b233a1c --- /dev/null +++ b/test/mocha.opts @@ -0,0 +1 @@ +--compilers js:babel-register From a5bbe13b75d9dde0fdb6596f4ecdb08998a21a4b Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Wed, 14 Dec 2016 11:27:21 -0800 Subject: [PATCH 046/257] travis ci integration --- .travis.yml | 13 +++++++++++++ README.md | 4 +++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..97320f42 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,13 @@ + +language: node_js +node_js: + - "6" + - "5" + - "4" + +install: + - make node_modules + +script: + - make lint + - make test diff --git a/README.md b/README.md index e46d8f22..7654d677 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # debug +[![Build Status](https://travis-ci.org/visionmedia/debug.svg?branch=master)](https://travis-ci.org/visionmedia/debug) + +tiny node.js debugging utility modelled after node core's debugging technique. - tiny node.js debugging utility modelled after node core's debugging technique. ## Installation From 5783966298d2b4d34c3fd25ff284df9d7cd8529f Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Wed, 14 Dec 2016 11:38:14 -0800 Subject: [PATCH 047/257] fix browser colors (#367) Fixes #366. --- browser.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/browser.js b/browser.js index 2963b23c..bee8b0b7 100644 --- a/browser.js +++ b/browser.js @@ -78,10 +78,10 @@ function formatArgs(args) { + (useColors ? '%c ' : ' ') + '+' + exports.humanize(this.diff); - if (!useColors) return args; + if (!useColors) return; var c = 'color: ' + this.color; - args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1)); + args.splice(1, 0, c, 'color: inherit') // the final "%c" is somewhat tricky, because there could be other // arguments passed either before or after the %c, so we need to From 4c3e80dfaaa499b451619201130c6c2ff07068c2 Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Wed, 14 Dec 2016 11:40:00 -0800 Subject: [PATCH 048/257] release 2.4.2 --- CHANGELOG.md | 9 ++++++++- component.json | 2 +- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d371f4e1..355c4342 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,15 @@ +2.4.2 / 2016-12-14 +================== + + * Fix: browser colors (#367, @tootallnate) + * Misc: travis ci integration (@thebigredgeek) + * Misc: added linting and testing boilerplate with sanity check (@thebigredgeek) + 2.4.1 / 2016-12-13 ================== - * Fixed a typo that broke the package (#356) + * Fix: typo that broke the package (#356) 2.4.0 / 2016-12-13 ================== diff --git a/component.json b/component.json index c5d88618..765066b4 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "debug", "repo": "visionmedia/debug", "description": "small debugging utility", - "version": "2.4.1", + "version": "2.4.2", "keywords": [ "debug", "log", diff --git a/package.json b/package.json index 5dd407ac..96f1a686 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "2.4.1", + "version": "2.4.2", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From e4b8bb9a2312844b574bebb5f43b46bfd55cbd61 Mon Sep 17 00:00:00 2001 From: Erik Karlsson Date: Wed, 14 Dec 2016 22:27:54 +0100 Subject: [PATCH 049/257] Fix #363 (#364) --- browser.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/browser.js b/browser.js index bee8b0b7..f907c708 100644 --- a/browser.js +++ b/browser.js @@ -44,9 +44,9 @@ function useColors() { (typeof window !== 'undefined' && window.console && (console.firebug || (console.exception && console.table))) || // is firefox >= v31? // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || + (navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || // double check webkit in userAgent just in case we are in a worker - (navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); + (navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); } /** From e1ee4d546a3c366146de708a9c1bf50939f0f425 Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Wed, 14 Dec 2016 13:49:04 -0800 Subject: [PATCH 050/257] release 2.4.3 --- CHANGELOG.md | 5 +++++ component.json | 2 +- package.json | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 355c4342..47fcd50f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ +2.4.3 / 2016-12-14 +================== + + * Fix: navigation.userAgent error for react native (#364, @escwald) + 2.4.2 / 2016-12-14 ================== diff --git a/component.json b/component.json index 765066b4..05489518 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "debug", "repo": "visionmedia/debug", "description": "small debugging utility", - "version": "2.4.2", + "version": "2.4.3", "keywords": [ "debug", "log", diff --git a/package.json b/package.json index 96f1a686..af3e7259 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "2.4.2", + "version": "2.4.3", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From 69480c3bd1b61413b3d5c543d75505ccde774614 Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Wed, 14 Dec 2016 15:58:20 -0800 Subject: [PATCH 051/257] Work around debug being loaded in preload scripts (#368) --- browser.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/browser.js b/browser.js index f907c708..a2552839 100644 --- a/browser.js +++ b/browser.js @@ -37,6 +37,13 @@ exports.colors = [ */ function useColors() { + // NB: In an Electron preload script, document will be defined but not fully + // initialized. Since we know we're in Chrome, we'll just detect this case + // explicitly + if (typeof window !== 'undefined' && 'process' in window && window.process.type === 'renderer') { + return true; + } + // is webkit? http://stackoverflow.com/a/16459606/376773 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 return (typeof document !== 'undefined' && 'WebkitAppearance' in document.documentElement.style) || From f1ca2ab80b824c6bb5d58dade36b587bd2b80272 Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Wed, 14 Dec 2016 17:26:37 -0800 Subject: [PATCH 052/257] release 2.4.4 --- CHANGELOG.md | 5 +++++ component.json | 2 +- package.json | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47fcd50f..4a2fbd5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ +2.4.4 / 2016-12-14 +================== + + * Fix: work around debug being loaded in preload scripts for electron (#368, @paulcbetts) + 2.4.3 / 2016-12-14 ================== diff --git a/component.json b/component.json index 05489518..adde6538 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "debug", "repo": "visionmedia/debug", "description": "small debugging utility", - "version": "2.4.3", + "version": "2.4.4", "keywords": [ "debug", "log", diff --git a/package.json b/package.json index af3e7259..edbe441f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "2.4.3", + "version": "2.4.4", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From c50b33f8864f5bf52786baa394920ed745931212 Mon Sep 17 00:00:00 2001 From: Yami Date: Thu, 15 Dec 2016 16:06:35 +0000 Subject: [PATCH 053/257] docs: Simplified language in the opening paragraph. Closes #340 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7654d677..81f55382 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # debug [![Build Status](https://travis-ci.org/visionmedia/debug.svg?branch=master)](https://travis-ci.org/visionmedia/debug) -tiny node.js debugging utility modelled after node core's debugging technique. +A tiny node.js debugging utility modelled after node core's debugging technique. ## Installation @@ -12,7 +12,7 @@ $ npm install debug ## Usage - With `debug` you simply invoke the exported function to generate your debug function, passing it a name which will determine if a noop function is returned, or a decorated `console.error`, so all of the `console` [format string goodies](https://developer.chrome.com/devtools/docs/console-api#consolelogobject-object) you're used to work fine. A unique color is selected per-function for visibility. +`debug` exposes a function; simply pass this function the name of your module, and it will return a decorated version of `console.error` for you to pass debug statements to. This will allow you to specify which modules you wish to see debug statements from when working an issue. Example _app.js_: From 2a146b65ca801e5d4cfd1d0b7e33d452b69bb09b Mon Sep 17 00:00:00 2001 From: Yami Date: Fri, 16 Dec 2016 12:47:04 +0000 Subject: [PATCH 054/257] fix: Adjust wording as per @thebigredgeek --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 81f55382..b2903bfb 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ $ npm install debug ## Usage -`debug` exposes a function; simply pass this function the name of your module, and it will return a decorated version of `console.error` for you to pass debug statements to. This will allow you to specify which modules you wish to see debug statements from when working an issue. +`debug` exposes a function; simply pass this function the name of your module, and it will return a decorated version of `console.error` for you to pass debug statements to. This will allow you to toggle the debug output for different parts of your module as well as the module as a whole. Example _app.js_: From f42b9627922995561299b064fce56bd292abb030 Mon Sep 17 00:00:00 2001 From: Yami Date: Fri, 16 Dec 2016 15:19:40 +0000 Subject: [PATCH 055/257] refactor: Moved source files to /src. Moved test files to client and server side tests. Added karma for front-end testing. --- Makefile | 5 +- bower.json | 2 +- component.json | 6 +- dist/debug.js | 576 ++++++++++++++++++++++++----------- karma.conf.js | 70 +++++ package.json | 4 +- browser.js => src/browser.js | 5 + debug.js => src/debug.js | 0 index.js => src/index.js | 0 node.js => src/node.js | 0 test/client/debug_spec.js | 8 + test/debug_spec.js | 12 - test/mocha.opts | 1 - test/server/debug_spec.js | 12 + 14 files changed, 501 insertions(+), 200 deletions(-) create mode 100644 karma.conf.js rename browser.js => src/browser.js (98%) rename debug.js => src/debug.js (100%) rename index.js => src/index.js (100%) rename node.js => src/node.js (100%) create mode 100644 test/client/debug_spec.js delete mode 100644 test/debug_spec.js delete mode 100644 test/mocha.opts create mode 100644 test/server/debug_spec.js diff --git a/Makefile b/Makefile index 19716b29..fe9c7f6a 100644 --- a/Makefile +++ b/Makefile @@ -43,6 +43,7 @@ lint: .FORCE eslint debug.js test: .FORCE - mocha - + mocha test/server/**.js + karma start --single-run + .PHONY: all install clean distclean diff --git a/bower.json b/bower.json index 073ecfcf..ad6589ef 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "visionmedia-debug", - "main": "./debug.js", + "main": "./src/debug.js", "homepage": "https://github.com/visionmedia/debug", "authors": [ "TJ Holowaychuk ", diff --git a/component.json b/component.json index 765066b4..32d5c388 100644 --- a/component.json +++ b/component.json @@ -8,10 +8,10 @@ "log", "debugger" ], - "main": "browser.js", + "main": "src/browser.js", "scripts": [ - "browser.js", - "debug.js" + "src/browser.js", + "src/debug.js" ], "dependencies": { "rauchg/ms.js": "0.7.1" diff --git a/dist/debug.js b/dist/debug.js index 18105c34..a57f060e 100644 --- a/dist/debug.js +++ b/dist/debug.js @@ -1,4 +1,337 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.debug = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; + +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + +},{}],2:[function(require,module,exports){ +/** + * Helpers. + */ + +var s = 1000 +var m = s * 60 +var h = m * 60 +var d = h * 24 +var y = d * 365.25 + +/** + * Parse or format the given `val`. + * + * Options: + * + * - `long` verbose formatting [false] + * + * @param {String|Number} val + * @param {Object} options + * @throws {Error} throw an error if val is not a non-empty string or a number + * @return {String|Number} + * @api public + */ + +module.exports = function (val, options) { + options = options || {} + var type = typeof val + if (type === 'string' && val.length > 0) { + return parse(val) + } else if (type === 'number' && isNaN(val) === false) { + return options.long ? + fmtLong(val) : + fmtShort(val) + } + throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val)) +} + +/** + * Parse the given `str` and return milliseconds. + * + * @param {String} str + * @return {Number} + * @api private + */ + +function parse(str) { + str = String(str) + if (str.length > 10000) { + return + } + var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str) + if (!match) { + return + } + var n = parseFloat(match[1]) + var type = (match[2] || 'ms').toLowerCase() + switch (type) { + case 'years': + case 'year': + case 'yrs': + case 'yr': + case 'y': + return n * y + case 'days': + case 'day': + case 'd': + return n * d + case 'hours': + case 'hour': + case 'hrs': + case 'hr': + case 'h': + return n * h + case 'minutes': + case 'minute': + case 'mins': + case 'min': + case 'm': + return n * m + case 'seconds': + case 'second': + case 'secs': + case 'sec': + case 's': + return n * s + case 'milliseconds': + case 'millisecond': + case 'msecs': + case 'msec': + case 'ms': + return n + default: + return undefined + } +} + +/** + * Short format for `ms`. + * + * @param {Number} ms + * @return {String} + * @api private + */ + +function fmtShort(ms) { + if (ms >= d) { + return Math.round(ms / d) + 'd' + } + if (ms >= h) { + return Math.round(ms / h) + 'h' + } + if (ms >= m) { + return Math.round(ms / m) + 'm' + } + if (ms >= s) { + return Math.round(ms / s) + 's' + } + return ms + 'ms' +} + +/** + * Long format for `ms`. + * + * @param {Number} ms + * @return {String} + * @api private + */ + +function fmtLong(ms) { + return plural(ms, d, 'day') || + plural(ms, h, 'hour') || + plural(ms, m, 'minute') || + plural(ms, s, 'second') || + ms + ' ms' +} + +/** + * Pluralization helper. + */ + +function plural(ms, n, name) { + if (ms < n) { + return + } + if (ms < n * 1.5) { + return Math.floor(ms / n) + ' ' + name + } + return Math.ceil(ms / n) + ' ' + name + 's' +} + +},{}],3:[function(require,module,exports){ /** * This is the common logic for both the Node.js and web browser @@ -7,7 +340,7 @@ * Expose `debug()` as the module. */ -exports = module.exports = debug.debug = debug; +exports = module.exports = createDebug.debug = createDebug.default = createDebug; exports.coerce = coerce; exports.disable = disable; exports.enable = enable; @@ -24,17 +357,11 @@ exports.skips = []; /** * Map of special "%n" handling functions, for the debug "format" argument. * - * Valid key names are a single, lowercased letter, i.e. "n". + * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". */ exports.formatters = {}; -/** - * Previously assigned color. - */ - -var prevColor = 0; - /** * Previous log timestamp. */ @@ -43,13 +370,20 @@ var prevTime; /** * Select a color. - * + * @param {String} namespace * @return {Number} * @api private */ -function selectColor() { - return exports.colors[prevColor++ % exports.colors.length]; +function selectColor(namespace) { + var hash = 0, i; + + for (i in namespace) { + hash = ((hash << 5) - hash) + namespace.charCodeAt(i); + hash |= 0; // Convert to 32bit integer + } + + return exports.colors[Math.abs(hash) % exports.colors.length]; } /** @@ -60,17 +394,13 @@ function selectColor() { * @api public */ -function debug(namespace) { +function createDebug(namespace) { - // define the `disabled` version - function disabled() { - } - disabled.enabled = false; + function debug() { + // disabled? + if (!debug.enabled) return; - // define the `enabled` version - function enabled() { - - var self = enabled; + var self = debug; // set `diff` timestamp var curr = +new Date(); @@ -80,22 +410,22 @@ function debug(namespace) { self.curr = curr; prevTime = curr; - // add the `color` if not set - if (null == self.useColors) self.useColors = exports.useColors(); - if (null == self.color && self.useColors) self.color = selectColor(); - - var args = Array.prototype.slice.call(arguments); + // turn the `arguments` into a proper Array + var args = new Array(arguments.length); + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i]; + } args[0] = exports.coerce(args[0]); if ('string' !== typeof args[0]) { - // anything else let's inspect with %o - args = ['%o'].concat(args); + // anything else let's inspect with %O + args.unshift('%O'); } // apply any `formatters` transformations var index = 0; - args[0] = args[0].replace(/%([a-z%])/g, function(match, format) { + args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) { // if we encounter an escaped % then don't increase the array index if (match === '%%') return match; index++; @@ -111,19 +441,24 @@ function debug(namespace) { return match; }); - if ('function' === typeof exports.formatArgs) { - args = exports.formatArgs.apply(self, args); - } + // apply env-specific formatting (colors, etc.) + exports.formatArgs.call(self, args); + var logFn = enabled.log || exports.log || console.log.bind(console); logFn.apply(self, args); } - enabled.enabled = true; - var fn = exports.enabled(namespace) ? enabled : disabled; + debug.namespace = namespace; + debug.enabled = exports.enabled(namespace); + debug.useColors = exports.useColors(); + debug.color = selectColor(namespace); - fn.namespace = namespace; + // env-specific initialization logic for debug instances + if ('function' === typeof exports.init) { + exports.init(debug); + } - return fn; + return debug; } /** @@ -197,135 +532,8 @@ function coerce(val) { return val; } -},{"ms":2}],2:[function(require,module,exports){ -/** - * Helpers. - */ - -var s = 1000; -var m = s * 60; -var h = m * 60; -var d = h * 24; -var y = d * 365.25; - -/** - * Parse or format the given `val`. - * - * Options: - * - * - `long` verbose formatting [false] - * - * @param {String|Number} val - * @param {Object} options - * @return {String|Number} - * @api public - */ - -module.exports = function(val, options){ - options = options || {}; - if ('string' == typeof val) return parse(val); - return options.long - ? long(val) - : short(val); -}; - -/** - * Parse the given `str` and return milliseconds. - * - * @param {String} str - * @return {Number} - * @api private - */ - -function parse(str) { - str = '' + str; - if (str.length > 10000) return; - var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str); - if (!match) return; - var n = parseFloat(match[1]); - var type = (match[2] || 'ms').toLowerCase(); - switch (type) { - case 'years': - case 'year': - case 'yrs': - case 'yr': - case 'y': - return n * y; - case 'days': - case 'day': - case 'd': - return n * d; - case 'hours': - case 'hour': - case 'hrs': - case 'hr': - case 'h': - return n * h; - case 'minutes': - case 'minute': - case 'mins': - case 'min': - case 'm': - return n * m; - case 'seconds': - case 'second': - case 'secs': - case 'sec': - case 's': - return n * s; - case 'milliseconds': - case 'millisecond': - case 'msecs': - case 'msec': - case 'ms': - return n; - } -} - -/** - * Short format for `ms`. - * - * @param {Number} ms - * @return {String} - * @api private - */ - -function short(ms) { - if (ms >= d) return Math.round(ms / d) + 'd'; - if (ms >= h) return Math.round(ms / h) + 'h'; - if (ms >= m) return Math.round(ms / m) + 'm'; - if (ms >= s) return Math.round(ms / s) + 's'; - return ms + 'ms'; -} - -/** - * Long format for `ms`. - * - * @param {Number} ms - * @return {String} - * @api private - */ - -function long(ms) { - return plural(ms, d, 'day') - || plural(ms, h, 'hour') - || plural(ms, m, 'minute') - || plural(ms, s, 'second') - || ms + ' ms'; -} - -/** - * Pluralization helper. - */ - -function plural(ms, n, name) { - if (ms < n) return; - if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name; - return Math.ceil(ms / n) + ' ' + name + 's'; -} - -},{}],3:[function(require,module,exports){ - +},{"ms":2}],4:[function(require,module,exports){ +(function (process){ /** * This is the web browser implementation of `debug()`. * @@ -366,12 +574,15 @@ exports.colors = [ function useColors() { // is webkit? http://stackoverflow.com/a/16459606/376773 - return ('WebkitAppearance' in document.documentElement.style) || + // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 + return (typeof document !== 'undefined' && 'WebkitAppearance' in document.documentElement.style) || // is firebug? http://stackoverflow.com/a/398120/376773 - (window.console && (console.firebug || (console.exception && console.table))) || + (typeof window !== 'undefined' && window.console && (console.firebug || (console.exception && console.table))) || // is firefox >= v31? // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31); + (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || + // double check webkit in userAgent just in case we are in a worker + (navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); } /** @@ -381,7 +592,7 @@ function useColors() { exports.formatters.j = function(v) { try { return JSON.stringify(v); - }catch( err){ + } catch (err) { return '[UnexpectedJSONParseError]: ' + err.message; } }; @@ -393,8 +604,7 @@ exports.formatters.j = function(v) { * @api public */ -function formatArgs() { - var args = arguments; +function formatArgs(args) { var useColors = this.useColors; args[0] = (useColors ? '%c' : '') @@ -404,10 +614,10 @@ function formatArgs() { + (useColors ? '%c ' : ' ') + '+' + exports.humanize(this.diff); - if (!useColors) return args; + if (!useColors) return; var c = 'color: ' + this.color; - args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1)); + args.splice(1, 0, c, 'color: inherit') // the final "%c" is somewhat tricky, because there could be other // arguments passed either before or after the %c, so we need to @@ -425,7 +635,6 @@ function formatArgs() { }); args.splice(lastC, 0, c); - return args; } /** @@ -470,9 +679,13 @@ function save(namespaces) { function load() { var r; try { - r = exports.storage.debug; + return exports.storage.debug; } catch(e) {} - return r; + + // If debug isn't set in LS, and we're in Electron, try to load $DEBUG + if (typeof process !== 'undefined' && 'env' in process) { + return process.env.DEBUG; + } } /** @@ -492,11 +705,16 @@ exports.enable(load()); * @api private */ -function localstorage(){ +function localstorage() { try { return window.localStorage; } catch (e) {} } -},{"./debug":1}]},{},[3])(3) -}); \ No newline at end of file +/** Attach to Window*/ +if (window) { + window.debug = exports; +} + +}).call(this,require('_process')) +},{"./debug":3,"_process":1}]},{},[4]); diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 00000000..58b700d5 --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,70 @@ +// Karma configuration +// Generated on Fri Dec 16 2016 13:09:51 GMT+0000 (UTC) + +module.exports = function(config) { + config.set({ + + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: '', + + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ['mocha', 'browserify'], + + + // list of files / patterns to load in the browser + files: [ + 'dist/debug.js', + 'test/client/*spec.js' + ], + + + // list of files to exclude + exclude: [ + 'src/node.js' + ], + + + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + }, + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ['progress'], + + + // web server port + port: 9876, + + + // enable / disable colors in the output (reporters and logs) + colors: true, + + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, + + + // enable / disable watching file and executing tests whenever any file changes + autoWatch: true, + + + // start these browsers + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + browsers: ['PhantomJS'], + + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: false, + + // Concurrency level + // how many browser should be started simultaneous + concurrency: Infinity + }) +} diff --git a/package.json b/package.json index 96f1a686..890e4ac7 100644 --- a/package.json +++ b/package.json @@ -34,8 +34,8 @@ "mocha": "^3.2.0", "sinon": "^1.17.6" }, - "main": "./index.js", - "browser": "./browser.js", + "main": "./src/index.js", + "browser": "./src/browser.js", "component": { "scripts": { "debug/index.js": "browser.js", diff --git a/browser.js b/src/browser.js similarity index 98% rename from browser.js rename to src/browser.js index bee8b0b7..f49434fc 100644 --- a/browser.js +++ b/src/browser.js @@ -174,3 +174,8 @@ function localstorage() { return window.localStorage; } catch (e) {} } + +/** Attach to Window*/ +if (window) { + window.debug = exports; +} diff --git a/debug.js b/src/debug.js similarity index 100% rename from debug.js rename to src/debug.js diff --git a/index.js b/src/index.js similarity index 100% rename from index.js rename to src/index.js diff --git a/node.js b/src/node.js similarity index 100% rename from node.js rename to src/node.js diff --git a/test/client/debug_spec.js b/test/client/debug_spec.js new file mode 100644 index 00000000..8b007eb0 --- /dev/null +++ b/test/client/debug_spec.js @@ -0,0 +1,8 @@ +describe('debug', function () { + describe('sanity check', function () { + it('passes', function () { + const log = debug('test'); + log('hello world'); + }); + }); +}); \ No newline at end of file diff --git a/test/debug_spec.js b/test/debug_spec.js deleted file mode 100644 index b0339218..00000000 --- a/test/debug_spec.js +++ /dev/null @@ -1,12 +0,0 @@ -import { expect } from 'chai'; - -import debug from '../index'; - -describe('debug', () => { - describe('sanity check', () => { - it('passes', () => { - const log = debug('test'); - log('hello world'); - }); - }); -}) diff --git a/test/mocha.opts b/test/mocha.opts deleted file mode 100644 index 6b233a1c..00000000 --- a/test/mocha.opts +++ /dev/null @@ -1 +0,0 @@ ---compilers js:babel-register diff --git a/test/server/debug_spec.js b/test/server/debug_spec.js new file mode 100644 index 00000000..82144e20 --- /dev/null +++ b/test/server/debug_spec.js @@ -0,0 +1,12 @@ +const expect = require('chai').expect + +const debug = require('../../src/index'); + +describe('debug', function () { + describe('sanity check', function () { + it('passes', function () { + const log = debug('test'); + log('hello world'); + }); + }); +}) From 88766af08a6701ee744fcaa15e33534efbfdef85 Mon Sep 17 00:00:00 2001 From: Yami Date: Fri, 16 Dec 2016 15:30:29 +0000 Subject: [PATCH 056/257] fix: update package.json so karma gets installed. --- package.json | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/package.json b/package.json index 890e4ac7..e4a83f94 100644 --- a/package.json +++ b/package.json @@ -21,16 +21,11 @@ "ms": "0.7.2" }, "devDependencies": { - "babel": "^6.5.2", - "babel-eslint": "^7.1.1", - "babel-polyfill": "^6.20.0", - "babel-preset-es2015": "^6.18.0", - "babel-register": "^6.18.0", - "babel-runtime": "^6.20.0", "browserify": "9.0.3", "chai": "^3.5.0", "eslint": "^3.12.1", "eslint-plugin-babel": "^4.0.0", + "karma": "^1.3.0", "mocha": "^3.2.0", "sinon": "^1.17.6" }, From adf6ccfc88a165550f763701a07b53d7e5424feb Mon Sep 17 00:00:00 2001 From: Yami Date: Fri, 16 Dec 2016 15:34:20 +0000 Subject: [PATCH 057/257] fix: Add karma-mocha dependency, and remove browserify --- karma.conf.js | 2 +- package.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/karma.conf.js b/karma.conf.js index 58b700d5..23cee73a 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -10,7 +10,7 @@ module.exports = function(config) { // frameworks to use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter - frameworks: ['mocha', 'browserify'], + frameworks: ['mocha'], // list of files / patterns to load in the browser diff --git a/package.json b/package.json index e4a83f94..062ac943 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "eslint": "^3.12.1", "eslint-plugin-babel": "^4.0.0", "karma": "^1.3.0", + "karma-mocha": "^1.3.0", "mocha": "^3.2.0", "sinon": "^1.17.6" }, From bb1e132d70b64c75671f7b6dc40f1eabae621a0d Mon Sep 17 00:00:00 2001 From: Yami Date: Fri, 16 Dec 2016 15:41:01 +0000 Subject: [PATCH 058/257] chore: add phantomjs for travis --- .babelrc | 4 ---- package.json | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) delete mode 100644 .babelrc diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 1b790bfa..00000000 --- a/.babelrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "presets": ["es2015"], - "sourceMaps": true -} diff --git a/package.json b/package.json index 062ac943..4c0a6748 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "eslint-plugin-babel": "^4.0.0", "karma": "^1.3.0", "karma-mocha": "^1.3.0", + "karma-phantomjs-launcher": "^1.0.2", "mocha": "^3.2.0", "sinon": "^1.17.6" }, From 6bc5986f878dcc5907088dad0b231075e1818a93 Mon Sep 17 00:00:00 2001 From: Yami Date: Fri, 16 Dec 2016 15:56:49 +0000 Subject: [PATCH 059/257] test: Added an expectation to the client-side test, and the necessary wiring --- karma.conf.js | 2 +- package.json | 4 +++- test/client/debug_spec.js | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index 23cee73a..10690990 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -10,7 +10,7 @@ module.exports = function(config) { // frameworks to use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter - frameworks: ['mocha'], + frameworks: ['mocha', 'chai'], // list of files / patterns to load in the browser diff --git a/package.json b/package.json index 4c0a6748..38aa8b87 100644 --- a/package.json +++ b/package.json @@ -26,10 +26,12 @@ "eslint": "^3.12.1", "eslint-plugin-babel": "^4.0.0", "karma": "^1.3.0", + "karma-chai": "^0.1.0", "karma-mocha": "^1.3.0", "karma-phantomjs-launcher": "^1.0.2", "mocha": "^3.2.0", - "sinon": "^1.17.6" + "sinon": "^1.17.6", + "sinon-chai": "^2.8.0" }, "main": "./src/index.js", "browser": "./src/browser.js", diff --git a/test/client/debug_spec.js b/test/client/debug_spec.js index 8b007eb0..644bea29 100644 --- a/test/client/debug_spec.js +++ b/test/client/debug_spec.js @@ -2,7 +2,7 @@ describe('debug', function () { describe('sanity check', function () { it('passes', function () { const log = debug('test'); - log('hello world'); + expect(log('hello world')).to.not.throw; }); }); }); \ No newline at end of file From 46ccb741c04896ef244fcc54cfb6628a6193fdbd Mon Sep 17 00:00:00 2001 From: Yami Date: Fri, 16 Dec 2016 16:04:57 +0000 Subject: [PATCH 060/257] Testing precommit hook by tweaking linting issues --- dist/browser.js | 715 ++++++++++++++++++++++++++++++++++++++ test/client/debug_spec.js | 1 + 2 files changed, 716 insertions(+) create mode 100644 dist/browser.js diff --git a/dist/browser.js b/dist/browser.js new file mode 100644 index 00000000..4437883d --- /dev/null +++ b/dist/browser.js @@ -0,0 +1,715 @@ +(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; + +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + +},{}],2:[function(require,module,exports){ +/** + * Helpers. + */ + +var s = 1000 +var m = s * 60 +var h = m * 60 +var d = h * 24 +var y = d * 365.25 + +/** + * Parse or format the given `val`. + * + * Options: + * + * - `long` verbose formatting [false] + * + * @param {String|Number} val + * @param {Object} options + * @throws {Error} throw an error if val is not a non-empty string or a number + * @return {String|Number} + * @api public + */ + +module.exports = function (val, options) { + options = options || {} + var type = typeof val + if (type === 'string' && val.length > 0) { + return parse(val) + } else if (type === 'number' && isNaN(val) === false) { + return options.long ? + fmtLong(val) : + fmtShort(val) + } + throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val)) +} + +/** + * Parse the given `str` and return milliseconds. + * + * @param {String} str + * @return {Number} + * @api private + */ + +function parse(str) { + str = String(str) + if (str.length > 10000) { + return + } + var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str) + if (!match) { + return + } + var n = parseFloat(match[1]) + var type = (match[2] || 'ms').toLowerCase() + switch (type) { + case 'years': + case 'year': + case 'yrs': + case 'yr': + case 'y': + return n * y + case 'days': + case 'day': + case 'd': + return n * d + case 'hours': + case 'hour': + case 'hrs': + case 'hr': + case 'h': + return n * h + case 'minutes': + case 'minute': + case 'mins': + case 'min': + case 'm': + return n * m + case 'seconds': + case 'second': + case 'secs': + case 'sec': + case 's': + return n * s + case 'milliseconds': + case 'millisecond': + case 'msecs': + case 'msec': + case 'ms': + return n + default: + return undefined + } +} + +/** + * Short format for `ms`. + * + * @param {Number} ms + * @return {String} + * @api private + */ + +function fmtShort(ms) { + if (ms >= d) { + return Math.round(ms / d) + 'd' + } + if (ms >= h) { + return Math.round(ms / h) + 'h' + } + if (ms >= m) { + return Math.round(ms / m) + 'm' + } + if (ms >= s) { + return Math.round(ms / s) + 's' + } + return ms + 'ms' +} + +/** + * Long format for `ms`. + * + * @param {Number} ms + * @return {String} + * @api private + */ + +function fmtLong(ms) { + return plural(ms, d, 'day') || + plural(ms, h, 'hour') || + plural(ms, m, 'minute') || + plural(ms, s, 'second') || + ms + ' ms' +} + +/** + * Pluralization helper. + */ + +function plural(ms, n, name) { + if (ms < n) { + return + } + if (ms < n * 1.5) { + return Math.floor(ms / n) + ' ' + name + } + return Math.ceil(ms / n) + ' ' + name + 's' +} + +},{}],3:[function(require,module,exports){ +(function (process){ +/** + * This is the web browser implementation of `debug()`. + * + * Expose `debug()` as the module. + */ + +exports = module.exports = require('./debug'); +exports.log = log; +exports.formatArgs = formatArgs; +exports.save = save; +exports.load = load; +exports.useColors = useColors; +exports.storage = 'undefined' != typeof chrome + && 'undefined' != typeof chrome.storage + ? chrome.storage.local + : localstorage(); + +/** + * Colors. + */ + +exports.colors = [ + 'lightseagreen', + 'forestgreen', + 'goldenrod', + 'dodgerblue', + 'darkorchid', + 'crimson' +]; + +/** + * Currently only WebKit-based Web Inspectors, Firefox >= v31, + * and the Firebug extension (any Firefox version) are known + * to support "%c" CSS customizations. + * + * TODO: add a `localStorage` variable to explicitly enable/disable colors + */ + +function useColors() { + // is webkit? http://stackoverflow.com/a/16459606/376773 + // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 + return (typeof document !== 'undefined' && 'WebkitAppearance' in document.documentElement.style) || + // is firebug? http://stackoverflow.com/a/398120/376773 + (typeof window !== 'undefined' && window.console && (console.firebug || (console.exception && console.table))) || + // is firefox >= v31? + // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages + (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || + // double check webkit in userAgent just in case we are in a worker + (navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); +} + +/** + * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. + */ + +exports.formatters.j = function(v) { + try { + return JSON.stringify(v); + } catch (err) { + return '[UnexpectedJSONParseError]: ' + err.message; + } +}; + + +/** + * Colorize log arguments if enabled. + * + * @api public + */ + +function formatArgs(args) { + var useColors = this.useColors; + + args[0] = (useColors ? '%c' : '') + + this.namespace + + (useColors ? ' %c' : ' ') + + args[0] + + (useColors ? '%c ' : ' ') + + '+' + exports.humanize(this.diff); + + if (!useColors) return; + + var c = 'color: ' + this.color; + args.splice(1, 0, c, 'color: inherit') + + // the final "%c" is somewhat tricky, because there could be other + // arguments passed either before or after the %c, so we need to + // figure out the correct index to insert the CSS into + var index = 0; + var lastC = 0; + args[0].replace(/%[a-z%]/g, function(match) { + if ('%%' === match) return; + index++; + if ('%c' === match) { + // we only are interested in the *last* %c + // (the user may have provided their own) + lastC = index; + } + }); + + args.splice(lastC, 0, c); +} + +/** + * Invokes `console.log()` when available. + * No-op when `console.log` is not a "function". + * + * @api public + */ + +function log() { + // this hackery is required for IE8/9, where + // the `console.log` function doesn't have 'apply' + return 'object' === typeof console + && console.log + && Function.prototype.apply.call(console.log, console, arguments); +} + +/** + * Save `namespaces`. + * + * @param {String} namespaces + * @api private + */ + +function save(namespaces) { + try { + if (null == namespaces) { + exports.storage.removeItem('debug'); + } else { + exports.storage.debug = namespaces; + } + } catch(e) {} +} + +/** + * Load `namespaces`. + * + * @return {String} returns the previously persisted debug modes + * @api private + */ + +function load() { + var r; + try { + return exports.storage.debug; + } catch(e) {} + + // If debug isn't set in LS, and we're in Electron, try to load $DEBUG + if (typeof process !== 'undefined' && 'env' in process) { + return process.env.DEBUG; + } +} + +/** + * Enable namespaces listed in `localStorage.debug` initially. + */ + +exports.enable(load()); + +/** + * Localstorage attempts to return the localstorage. + * + * This is necessary because safari throws + * when a user disables cookies/localstorage + * and you attempt to access it. + * + * @return {LocalStorage} + * @api private + */ + +function localstorage() { + try { + return window.localStorage; + } catch (e) {} +} + +}).call(this,require('_process')) +},{"./debug":4,"_process":1}],4:[function(require,module,exports){ + +/** + * This is the common logic for both the Node.js and web browser + * implementations of `debug()`. + * + * Expose `debug()` as the module. + */ + +exports = module.exports = createDebug.debug = createDebug.default = createDebug; +exports.coerce = coerce; +exports.disable = disable; +exports.enable = enable; +exports.enabled = enabled; +exports.humanize = require('ms'); + +/** + * The currently active debug mode names, and names to skip. + */ + +exports.names = []; +exports.skips = []; + +/** + * Map of special "%n" handling functions, for the debug "format" argument. + * + * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". + */ + +exports.formatters = {}; + +/** + * Previous log timestamp. + */ + +var prevTime; + +/** + * Select a color. + * @param {String} namespace + * @return {Number} + * @api private + */ + +function selectColor(namespace) { + var hash = 0, i; + + for (i in namespace) { + hash = ((hash << 5) - hash) + namespace.charCodeAt(i); + hash |= 0; // Convert to 32bit integer + } + + return exports.colors[Math.abs(hash) % exports.colors.length]; +} + +/** + * Create a debugger with the given `namespace`. + * + * @param {String} namespace + * @return {Function} + * @api public + */ + +function createDebug(namespace) { + + function debug() { + // disabled? + if (!debug.enabled) return; + + var self = debug; + + // set `diff` timestamp + var curr = +new Date(); + var ms = curr - (prevTime || curr); + self.diff = ms; + self.prev = prevTime; + self.curr = curr; + prevTime = curr; + + // turn the `arguments` into a proper Array + var args = new Array(arguments.length); + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i]; + } + + args[0] = exports.coerce(args[0]); + + if ('string' !== typeof args[0]) { + // anything else let's inspect with %O + args.unshift('%O'); + } + + // apply any `formatters` transformations + var index = 0; + args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) { + // if we encounter an escaped % then don't increase the array index + if (match === '%%') return match; + index++; + var formatter = exports.formatters[format]; + if ('function' === typeof formatter) { + var val = args[index]; + match = formatter.call(self, val); + + // now we need to remove `args[index]` since it's inlined in the `format` + args.splice(index, 1); + index--; + } + return match; + }); + + // apply env-specific formatting (colors, etc.) + exports.formatArgs.call(self, args); + + var logFn = enabled.log || exports.log || console.log.bind(console); + logFn.apply(self, args); + } + + debug.namespace = namespace; + debug.enabled = exports.enabled(namespace); + debug.useColors = exports.useColors(); + debug.color = selectColor(namespace); + + // env-specific initialization logic for debug instances + if ('function' === typeof exports.init) { + exports.init(debug); + } + + return debug; +} + +/** + * Enables a debug mode by namespaces. This can include modes + * separated by a colon and wildcards. + * + * @param {String} namespaces + * @api public + */ + +function enable(namespaces) { + exports.save(namespaces); + + var split = (namespaces || '').split(/[\s,]+/); + var len = split.length; + + for (var i = 0; i < len; i++) { + if (!split[i]) continue; // ignore empty strings + namespaces = split[i].replace(/\*/g, '.*?'); + if (namespaces[0] === '-') { + exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); + } else { + exports.names.push(new RegExp('^' + namespaces + '$')); + } + } +} + +/** + * Disable debug output. + * + * @api public + */ + +function disable() { + exports.enable(''); +} + +/** + * Returns true if the given mode name is enabled, false otherwise. + * + * @param {String} name + * @return {Boolean} + * @api public + */ + +function enabled(name) { + var i, len; + for (i = 0, len = exports.skips.length; i < len; i++) { + if (exports.skips[i].test(name)) { + return false; + } + } + for (i = 0, len = exports.names.length; i < len; i++) { + if (exports.names[i].test(name)) { + return true; + } + } + return false; +} + +/** + * Coerce `val`. + * + * @param {Mixed} val + * @return {Mixed} + * @api private + */ + +function coerce(val) { + if (val instanceof Error) return val.stack || val.message; + return val; +} + +},{"ms":2}]},{},[3]); diff --git a/test/client/debug_spec.js b/test/client/debug_spec.js index 644bea29..0be7a91d 100644 --- a/test/client/debug_spec.js +++ b/test/client/debug_spec.js @@ -1,3 +1,4 @@ +/* globals describe, it, expect, debug*/ describe('debug', function () { describe('sanity check', function () { it('passes', function () { From cea345a1cb11d4959db4703e7e2b44656b4a4788 Mon Sep 17 00:00:00 2001 From: Yami Date: Fri, 16 Dec 2016 14:16:15 -0500 Subject: [PATCH 061/257] docs: Simplified language in the opening paragraph. Closes #340 (#373) * docs: Simplified language in the opening paragraph. Closes #340 * fix: Adjust wording as per @thebigredgeek --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7654d677..b2903bfb 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # debug [![Build Status](https://travis-ci.org/visionmedia/debug.svg?branch=master)](https://travis-ci.org/visionmedia/debug) -tiny node.js debugging utility modelled after node core's debugging technique. +A tiny node.js debugging utility modelled after node core's debugging technique. ## Installation @@ -12,7 +12,7 @@ $ npm install debug ## Usage - With `debug` you simply invoke the exported function to generate your debug function, passing it a name which will determine if a noop function is returned, or a decorated `console.error`, so all of the `console` [format string goodies](https://developer.chrome.com/devtools/docs/console-api#consolelogobject-object) you're used to work fine. A unique color is selected per-function for visibility. +`debug` exposes a function; simply pass this function the name of your module, and it will return a decorated version of `console.error` for you to pass debug statements to. This will allow you to toggle the debug output for different parts of your module as well as the module as a whole. Example _app.js_: From 932b24a68554e4200327d20d5ca778e0d728c7d6 Mon Sep 17 00:00:00 2001 From: Sean Lavine Date: Sat, 17 Dec 2016 22:43:35 -0800 Subject: [PATCH 062/257] rm non-maintainted `dist/` dir (#375) --- README.md | 7 +- dist/debug.js | 502 -------------------------------------------------- 2 files changed, 6 insertions(+), 503 deletions(-) delete mode 100644 dist/debug.js diff --git a/README.md b/README.md index b2903bfb..89e7f576 100644 --- a/README.md +++ b/README.md @@ -142,8 +142,13 @@ debug('this is hex: %h', new Buffer('hello world')) ``` ## Browser support + You can build a browser-ready script using [browserify](https://github.com/substack/node-browserify), + or just use the [browserify-as-a-service](https://wzrd.in/) [build](https://wzrd.in/standalone/debug@latest), + if you don't want to build it yourself. - Debug works in the browser as well, currently persisted by `localStorage`. Consider the situation shown below where you have `worker:a` and `worker:b`, and wish to debug both. You can enable this using `localStorage.debug`: + Debug's enable state is currently persisted by `localStorage`. + Consider the situation shown below where you have `worker:a` and `worker:b`, + and wish to debug both. You can enable this using `localStorage.debug`: ```js localStorage.debug = 'worker:*' diff --git a/dist/debug.js b/dist/debug.js deleted file mode 100644 index 18105c34..00000000 --- a/dist/debug.js +++ /dev/null @@ -1,502 +0,0 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.debug = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 10000) return; - var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str); - if (!match) return; - var n = parseFloat(match[1]); - var type = (match[2] || 'ms').toLowerCase(); - switch (type) { - case 'years': - case 'year': - case 'yrs': - case 'yr': - case 'y': - return n * y; - case 'days': - case 'day': - case 'd': - return n * d; - case 'hours': - case 'hour': - case 'hrs': - case 'hr': - case 'h': - return n * h; - case 'minutes': - case 'minute': - case 'mins': - case 'min': - case 'm': - return n * m; - case 'seconds': - case 'second': - case 'secs': - case 'sec': - case 's': - return n * s; - case 'milliseconds': - case 'millisecond': - case 'msecs': - case 'msec': - case 'ms': - return n; - } -} - -/** - * Short format for `ms`. - * - * @param {Number} ms - * @return {String} - * @api private - */ - -function short(ms) { - if (ms >= d) return Math.round(ms / d) + 'd'; - if (ms >= h) return Math.round(ms / h) + 'h'; - if (ms >= m) return Math.round(ms / m) + 'm'; - if (ms >= s) return Math.round(ms / s) + 's'; - return ms + 'ms'; -} - -/** - * Long format for `ms`. - * - * @param {Number} ms - * @return {String} - * @api private - */ - -function long(ms) { - return plural(ms, d, 'day') - || plural(ms, h, 'hour') - || plural(ms, m, 'minute') - || plural(ms, s, 'second') - || ms + ' ms'; -} - -/** - * Pluralization helper. - */ - -function plural(ms, n, name) { - if (ms < n) return; - if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name; - return Math.ceil(ms / n) + ' ' + name + 's'; -} - -},{}],3:[function(require,module,exports){ - -/** - * This is the web browser implementation of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = require('./debug'); -exports.log = log; -exports.formatArgs = formatArgs; -exports.save = save; -exports.load = load; -exports.useColors = useColors; -exports.storage = 'undefined' != typeof chrome - && 'undefined' != typeof chrome.storage - ? chrome.storage.local - : localstorage(); - -/** - * Colors. - */ - -exports.colors = [ - 'lightseagreen', - 'forestgreen', - 'goldenrod', - 'dodgerblue', - 'darkorchid', - 'crimson' -]; - -/** - * Currently only WebKit-based Web Inspectors, Firefox >= v31, - * and the Firebug extension (any Firefox version) are known - * to support "%c" CSS customizations. - * - * TODO: add a `localStorage` variable to explicitly enable/disable colors - */ - -function useColors() { - // is webkit? http://stackoverflow.com/a/16459606/376773 - return ('WebkitAppearance' in document.documentElement.style) || - // is firebug? http://stackoverflow.com/a/398120/376773 - (window.console && (console.firebug || (console.exception && console.table))) || - // is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31); -} - -/** - * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. - */ - -exports.formatters.j = function(v) { - try { - return JSON.stringify(v); - }catch( err){ - return '[UnexpectedJSONParseError]: ' + err.message; - } -}; - - -/** - * Colorize log arguments if enabled. - * - * @api public - */ - -function formatArgs() { - var args = arguments; - var useColors = this.useColors; - - args[0] = (useColors ? '%c' : '') - + this.namespace - + (useColors ? ' %c' : ' ') - + args[0] - + (useColors ? '%c ' : ' ') - + '+' + exports.humanize(this.diff); - - if (!useColors) return args; - - var c = 'color: ' + this.color; - args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1)); - - // the final "%c" is somewhat tricky, because there could be other - // arguments passed either before or after the %c, so we need to - // figure out the correct index to insert the CSS into - var index = 0; - var lastC = 0; - args[0].replace(/%[a-z%]/g, function(match) { - if ('%%' === match) return; - index++; - if ('%c' === match) { - // we only are interested in the *last* %c - // (the user may have provided their own) - lastC = index; - } - }); - - args.splice(lastC, 0, c); - return args; -} - -/** - * Invokes `console.log()` when available. - * No-op when `console.log` is not a "function". - * - * @api public - */ - -function log() { - // this hackery is required for IE8/9, where - // the `console.log` function doesn't have 'apply' - return 'object' === typeof console - && console.log - && Function.prototype.apply.call(console.log, console, arguments); -} - -/** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ - -function save(namespaces) { - try { - if (null == namespaces) { - exports.storage.removeItem('debug'); - } else { - exports.storage.debug = namespaces; - } - } catch(e) {} -} - -/** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ - -function load() { - var r; - try { - r = exports.storage.debug; - } catch(e) {} - return r; -} - -/** - * Enable namespaces listed in `localStorage.debug` initially. - */ - -exports.enable(load()); - -/** - * Localstorage attempts to return the localstorage. - * - * This is necessary because safari throws - * when a user disables cookies/localstorage - * and you attempt to access it. - * - * @return {LocalStorage} - * @api private - */ - -function localstorage(){ - try { - return window.localStorage; - } catch (e) {} -} - -},{"./debug":1}]},{},[3])(3) -}); \ No newline at end of file From 1c625d45786fa8b3f0d285d3165e4dd346985fac Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Sat, 17 Dec 2016 22:53:56 -0800 Subject: [PATCH 063/257] bit of cleanup + linting fixes --- .eslintrc | 3 ++- Makefile | 2 +- browser.js | 7 +++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.eslintrc b/.eslintrc index 21bfbb5a..658f7d8f 100644 --- a/.eslintrc +++ b/.eslintrc @@ -9,7 +9,8 @@ "node": true }, "rules": { - "no-console": 0 + "no-console": 0, + "no-empty": [1, { "allowEmptyCatch": true }] }, "extends": "eslint:recommended" } diff --git a/Makefile b/Makefile index 19716b29..ae247985 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,7 @@ node_modules: package.json @touch node_modules lint: .FORCE - eslint debug.js + eslint browser.js debug.js index.js node.js test: .FORCE mocha diff --git a/browser.js b/browser.js index a2552839..b0fe9887 100644 --- a/browser.js +++ b/browser.js @@ -10,9 +10,9 @@ exports.formatArgs = formatArgs; exports.save = save; exports.load = load; exports.useColors = useColors; -exports.storage = 'undefined' != typeof chrome - && 'undefined' != typeof chrome.storage - ? chrome.storage.local +exports.storage = 'undefined' != typeof window.chrome + && 'undefined' != typeof window.chrome.storage + ? window.chrome.storage.local : localstorage(); /** @@ -148,7 +148,6 @@ function save(namespaces) { */ function load() { - var r; try { return exports.storage.debug; } catch(e) {} From 50ffa9d85ed55bf905e454b417171f080ebb4528 Mon Sep 17 00:00:00 2001 From: Hristo Iliev Date: Sun, 18 Dec 2016 08:56:14 +0200 Subject: [PATCH 064/257] Enable use of custom log function (#379) * Enable use of custom log function * Add test for custom log function --- debug.js | 2 +- test/debug_spec.js | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/debug.js b/debug.js index 7b0632db..4d3c7f27 100644 --- a/debug.js +++ b/debug.js @@ -110,7 +110,7 @@ function createDebug(namespace) { // apply env-specific formatting (colors, etc.) exports.formatArgs.call(self, args); - var logFn = enabled.log || exports.log || console.log.bind(console); + var logFn = debug.log || exports.log || console.log.bind(console); logFn.apply(self, args); } diff --git a/test/debug_spec.js b/test/debug_spec.js index b0339218..136937aa 100644 --- a/test/debug_spec.js +++ b/test/debug_spec.js @@ -1,4 +1,5 @@ import { expect } from 'chai'; +import { assert, spy } from 'sinon'; import debug from '../index'; @@ -9,4 +10,22 @@ describe('debug', () => { log('hello world'); }); }); -}) + + describe('custom functions', () => { + let log; + + beforeEach(() => { + debug.enable('test'); + log = debug('test'); + }); + + context('with log function', () => { + it('uses it', () => { + log.log = spy(); + log('using custom log function'); + + assert.calledOnce(log.log); + }); + }); + }); +}); From 17d0e0bb49b46f53bd97aa6d7b56bf9990a8cb62 Mon Sep 17 00:00:00 2001 From: jochenberger Date: Sun, 18 Dec 2016 08:02:18 +0100 Subject: [PATCH 065/257] check for navigator (#376) Fix: navigator undefined in Rhino --- browser.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/browser.js b/browser.js index b0fe9887..52f3a972 100644 --- a/browser.js +++ b/browser.js @@ -51,9 +51,9 @@ function useColors() { (typeof window !== 'undefined' && window.console && (console.firebug || (console.exception && console.table))) || // is firefox >= v31? // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || + (navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || // double check webkit in userAgent just in case we are in a worker - (navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); + (navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); } /** From 7e741fcc2f834672796333c97aa15f27f0ea2b5c Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Sat, 17 Dec 2016 23:13:40 -0800 Subject: [PATCH 066/257] release 2.4.5 --- CHANGELOG.md | 9 +++++++++ component.json | 2 +- package.json | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a2fbd5c..58143e7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,13 @@ +2.4.5 / 2016-12-17 +================== + + * Fix: `navigator` undefined in Rhino (#376, @jochenberger) + * Fix: custom log function (#379, @hsiliev) + * Improvement: bit of cleanup + linting fixes (@thebigredgeek) + * Improvement: rm non-maintainted `dist/` dir (#375, @freewil) + * Docs: simplified language in the opening paragraph. (#373, @yamikuronue) + 2.4.4 / 2016-12-14 ================== diff --git a/component.json b/component.json index adde6538..2c15f670 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "debug", "repo": "visionmedia/debug", "description": "small debugging utility", - "version": "2.4.4", + "version": "2.4.5", "keywords": [ "debug", "log", diff --git a/package.json b/package.json index edbe441f..92ae4ab2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "2.4.4", + "version": "2.4.5", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From 9011c5a17a568f2ca5b37563a3c6e375cf5b44b4 Mon Sep 17 00:00:00 2001 From: Yami Date: Mon, 19 Dec 2016 12:01:09 +0000 Subject: [PATCH 067/257] chore: Add pre-commit hook via ghooks so it can be shared --- package.json | 6 ++++++ scripts/precommit.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100755 scripts/precommit.sh diff --git a/package.json b/package.json index 38aa8b87..9d6b68bf 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "chai": "^3.5.0", "eslint": "^3.12.1", "eslint-plugin-babel": "^4.0.0", + "ghooks": "^1.3.2", "karma": "^1.3.0", "karma-chai": "^0.1.0", "karma-mocha": "^1.3.0", @@ -40,5 +41,10 @@ "debug/index.js": "browser.js", "debug/debug.js": "debug.js" } + }, + "config": { + "ghooks": { + "pre-commit": "scripts/precommit.sh" + } } } diff --git a/scripts/precommit.sh b/scripts/precommit.sh new file mode 100755 index 00000000..071ca416 --- /dev/null +++ b/scripts/precommit.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed. +# Called by "git commit" with no arguments. The hook should +# exit with non-zero status after issuing an appropriate message if +# it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-commit". + +# Stash anything not being committed +git stash -q --keep-index + +echo +echo "Generating dist" +echo +# Make the dist files +make dist +echo +echo +echo "Distribution generation complete" +echo +echo "Adding updated files to commit" +echo +# add them +git add dist/ +git add -u dist/ + +# Restore uncommitted changes +git stash pop -q From 92e0e88570b23fb32d542c37818158de1d973e29 Mon Sep 17 00:00:00 2001 From: Yami Date: Mon, 19 Dec 2016 12:06:38 +0000 Subject: [PATCH 068/257] feature: Combined backend and frontend tests --- Makefile | 2 +- karma.conf.js | 4 ++-- package.json | 1 + test/client/debug_spec.js | 9 --------- test/debug_spec.js | 34 ++++++++++++++++++++++++++++++++++ test/server/debug_spec.js | 12 ------------ 6 files changed, 38 insertions(+), 24 deletions(-) delete mode 100644 test/client/debug_spec.js create mode 100644 test/debug_spec.js delete mode 100644 test/server/debug_spec.js diff --git a/Makefile b/Makefile index fe9c7f6a..3bad5e62 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,7 @@ lint: .FORCE eslint debug.js test: .FORCE - mocha test/server/**.js + mocha test/**.js karma start --single-run .PHONY: all install clean distclean diff --git a/karma.conf.js b/karma.conf.js index 10690990..103a82d1 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -10,13 +10,13 @@ module.exports = function(config) { // frameworks to use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter - frameworks: ['mocha', 'chai'], + frameworks: ['mocha', 'chai', 'sinon'], // list of files / patterns to load in the browser files: [ 'dist/debug.js', - 'test/client/*spec.js' + 'test/*spec.js' ], diff --git a/package.json b/package.json index 9d6b68bf..042364a8 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "karma-chai": "^0.1.0", "karma-mocha": "^1.3.0", "karma-phantomjs-launcher": "^1.0.2", + "karma-sinon": "^1.0.5", "mocha": "^3.2.0", "sinon": "^1.17.6", "sinon-chai": "^2.8.0" diff --git a/test/client/debug_spec.js b/test/client/debug_spec.js deleted file mode 100644 index 0be7a91d..00000000 --- a/test/client/debug_spec.js +++ /dev/null @@ -1,9 +0,0 @@ -/* globals describe, it, expect, debug*/ -describe('debug', function () { - describe('sanity check', function () { - it('passes', function () { - const log = debug('test'); - expect(log('hello world')).to.not.throw; - }); - }); -}); \ No newline at end of file diff --git a/test/debug_spec.js b/test/debug_spec.js new file mode 100644 index 00000000..b4642885 --- /dev/null +++ b/test/debug_spec.js @@ -0,0 +1,34 @@ +/* global describe, it */ + +if (typeof module !== 'undefined' && module.exports) { + const chai = require('chai'); + const expect = chai.expect; + + const debug = require('../src/index'); + const sinon = require('sinon'); + var sinonChai = require("sinon-chai"); + chai.use(sinonChai); +} + +const dummyConsole = { + log: function() { + //dummy function + } +}; + +debug.log = dummyConsole; + + +describe('debug', function () { + const log = debug('test'); + log.log = sinon.stub(); + it('passes a basic sanity check', function () { + expect(log('hello world')).to.not.throw; + }); + + it('Should output to the log function', function () { + sinon.spy(dummyConsole, 'log'); + log('Hello world'); + //expect(dummyConsole.log).to.have.been.called; + }); +}); diff --git a/test/server/debug_spec.js b/test/server/debug_spec.js deleted file mode 100644 index 82144e20..00000000 --- a/test/server/debug_spec.js +++ /dev/null @@ -1,12 +0,0 @@ -const expect = require('chai').expect - -const debug = require('../../src/index'); - -describe('debug', function () { - describe('sanity check', function () { - it('passes', function () { - const log = debug('test'); - log('hello world'); - }); - }); -}) From 0d7c9ebcc92423e02640985af708837caf2b6929 Mon Sep 17 00:00:00 2001 From: Yami Date: Mon, 19 Dec 2016 12:12:35 +0000 Subject: [PATCH 069/257] fix: remove ES6 features since this also now runs on the browser --- test/debug_spec.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/test/debug_spec.js b/test/debug_spec.js index b4642885..8eff678d 100644 --- a/test/debug_spec.js +++ b/test/debug_spec.js @@ -1,32 +1,33 @@ /* global describe, it */ +'use strict' -if (typeof module !== 'undefined' && module.exports) { - const chai = require('chai'); - const expect = chai.expect; +if (typeof module !== 'undefined') { + var chai = require('chai'); + var expect = chai.expect; - const debug = require('../src/index'); - const sinon = require('sinon'); + var debug = require('../src/index'); + var sinon = require('sinon'); var sinonChai = require("sinon-chai"); chai.use(sinonChai); } -const dummyConsole = { +var dummyConsole = { log: function() { //dummy function } }; -debug.log = dummyConsole; - describe('debug', function () { - const log = debug('test'); + var log = debug('test'); + log.log = sinon.stub(); it('passes a basic sanity check', function () { expect(log('hello world')).to.not.throw; }); it('Should output to the log function', function () { + debug.log = dummyConsole.log; sinon.spy(dummyConsole, 'log'); log('Hello world'); //expect(dummyConsole.log).to.have.been.called; From 6a8d525642c1a559a61cedfe70501c1bebbcb710 Mon Sep 17 00:00:00 2001 From: Yami Date: Mon, 19 Dec 2016 12:25:16 +0000 Subject: [PATCH 070/257] chore: add coveralls --- .travis.yml | 1 + Makefile | 5 ++++- package.json | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 97320f42..4db6e14e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,3 +11,4 @@ install: script: - make lint - make test + - make coveralls \ No newline at end of file diff --git a/Makefile b/Makefile index 3bad5e62..796c3cac 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,10 @@ lint: .FORCE eslint debug.js test: .FORCE - mocha test/**.js + istanbul cover node_modules/mocha/bin/_mocha -- test/**.js karma start --single-run +coveralls: + cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js + .PHONY: all install clean distclean diff --git a/package.json b/package.json index 042364a8..f4f0e3de 100644 --- a/package.json +++ b/package.json @@ -23,15 +23,18 @@ "devDependencies": { "browserify": "9.0.3", "chai": "^3.5.0", + "coveralls": "^2.11.15", "eslint": "^3.12.1", "eslint-plugin-babel": "^4.0.0", "ghooks": "^1.3.2", + "istanbul": "^0.4.5", "karma": "^1.3.0", "karma-chai": "^0.1.0", "karma-mocha": "^1.3.0", "karma-phantomjs-launcher": "^1.0.2", "karma-sinon": "^1.0.5", "mocha": "^3.2.0", + "mocha-lcov-reporter": "^1.2.0", "sinon": "^1.17.6", "sinon-chai": "^2.8.0" }, From 6e934e9fb02fe4f353f1d84404ee2ff508cbb0bd Mon Sep 17 00:00:00 2001 From: Erik Karlsson Date: Tue, 20 Dec 2016 01:22:13 +0100 Subject: [PATCH 071/257] Fix for #381. Moved .babelrc into test folder, where it is used and which is not built with the module. (#383) --- .babelrc => test/.babelrc | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .babelrc => test/.babelrc (100%) diff --git a/.babelrc b/test/.babelrc similarity index 100% rename from .babelrc rename to test/.babelrc From 2a01c6c7756e5849a61535865c8c125ed0402c57 Mon Sep 17 00:00:00 2001 From: Yami Date: Tue, 20 Dec 2016 12:27:29 +0000 Subject: [PATCH 072/257] Merged from upstream/master. I left the dist/debug in place because my hook now updates it automatically, but I removed the babelrc file since we don't need it anymore. --- .eslintrc | 3 ++- CHANGELOG.md | 19 +++++++++++++++++++ Makefile | 2 +- README.md | 7 ++++++- component.json | 2 +- package.json | 2 +- src/browser.js | 18 ++++++++++++------ src/debug.js | 2 +- test/debug_spec.js | 22 ++++++++++++++++++++++ 9 files changed, 65 insertions(+), 12 deletions(-) diff --git a/.eslintrc b/.eslintrc index 21bfbb5a..658f7d8f 100644 --- a/.eslintrc +++ b/.eslintrc @@ -9,7 +9,8 @@ "node": true }, "rules": { - "no-console": 0 + "no-console": 0, + "no-empty": [1, { "allowEmptyCatch": true }] }, "extends": "eslint:recommended" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 355c4342..58143e7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,23 @@ +2.4.5 / 2016-12-17 +================== + + * Fix: `navigator` undefined in Rhino (#376, @jochenberger) + * Fix: custom log function (#379, @hsiliev) + * Improvement: bit of cleanup + linting fixes (@thebigredgeek) + * Improvement: rm non-maintainted `dist/` dir (#375, @freewil) + * Docs: simplified language in the opening paragraph. (#373, @yamikuronue) + +2.4.4 / 2016-12-14 +================== + + * Fix: work around debug being loaded in preload scripts for electron (#368, @paulcbetts) + +2.4.3 / 2016-12-14 +================== + + * Fix: navigation.userAgent error for react native (#364, @escwald) + 2.4.2 / 2016-12-14 ================== diff --git a/Makefile b/Makefile index 796c3cac..5d1d4cdd 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,7 @@ node_modules: package.json @touch node_modules lint: .FORCE - eslint debug.js + eslint browser.js debug.js index.js node.js test: .FORCE istanbul cover node_modules/mocha/bin/_mocha -- test/**.js diff --git a/README.md b/README.md index b2903bfb..89e7f576 100644 --- a/README.md +++ b/README.md @@ -142,8 +142,13 @@ debug('this is hex: %h', new Buffer('hello world')) ``` ## Browser support + You can build a browser-ready script using [browserify](https://github.com/substack/node-browserify), + or just use the [browserify-as-a-service](https://wzrd.in/) [build](https://wzrd.in/standalone/debug@latest), + if you don't want to build it yourself. - Debug works in the browser as well, currently persisted by `localStorage`. Consider the situation shown below where you have `worker:a` and `worker:b`, and wish to debug both. You can enable this using `localStorage.debug`: + Debug's enable state is currently persisted by `localStorage`. + Consider the situation shown below where you have `worker:a` and `worker:b`, + and wish to debug both. You can enable this using `localStorage.debug`: ```js localStorage.debug = 'worker:*' diff --git a/component.json b/component.json index 32d5c388..00a036a1 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "debug", "repo": "visionmedia/debug", "description": "small debugging utility", - "version": "2.4.2", + "version": "2.4.5", "keywords": [ "debug", "log", diff --git a/package.json b/package.json index f4f0e3de..62bed8d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "2.4.2", + "version": "2.4.5", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" diff --git a/src/browser.js b/src/browser.js index f49434fc..18f03c41 100644 --- a/src/browser.js +++ b/src/browser.js @@ -10,9 +10,9 @@ exports.formatArgs = formatArgs; exports.save = save; exports.load = load; exports.useColors = useColors; -exports.storage = 'undefined' != typeof chrome - && 'undefined' != typeof chrome.storage - ? chrome.storage.local +exports.storage = 'undefined' != typeof window.chrome + && 'undefined' != typeof window.chrome.storage + ? window.chrome.storage.local : localstorage(); /** @@ -37,6 +37,13 @@ exports.colors = [ */ function useColors() { + // NB: In an Electron preload script, document will be defined but not fully + // initialized. Since we know we're in Chrome, we'll just detect this case + // explicitly + if (typeof window !== 'undefined' && 'process' in window && window.process.type === 'renderer') { + return true; + } + // is webkit? http://stackoverflow.com/a/16459606/376773 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 return (typeof document !== 'undefined' && 'WebkitAppearance' in document.documentElement.style) || @@ -44,9 +51,9 @@ function useColors() { (typeof window !== 'undefined' && window.console && (console.firebug || (console.exception && console.table))) || // is firefox >= v31? // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || + (navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || // double check webkit in userAgent just in case we are in a worker - (navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); + (navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); } /** @@ -141,7 +148,6 @@ function save(namespaces) { */ function load() { - var r; try { return exports.storage.debug; } catch(e) {} diff --git a/src/debug.js b/src/debug.js index 7b0632db..4d3c7f27 100644 --- a/src/debug.js +++ b/src/debug.js @@ -110,7 +110,7 @@ function createDebug(namespace) { // apply env-specific formatting (colors, etc.) exports.formatArgs.call(self, args); - var logFn = enabled.log || exports.log || console.log.bind(console); + var logFn = debug.log || exports.log || console.log.bind(console); logFn.apply(self, args); } diff --git a/test/debug_spec.js b/test/debug_spec.js index 8eff678d..f7a6e51d 100644 --- a/test/debug_spec.js +++ b/test/debug_spec.js @@ -32,4 +32,26 @@ describe('debug', function () { log('Hello world'); //expect(dummyConsole.log).to.have.been.called; }); +<<<<<<< HEAD +======= + }); + + describe('custom functions', () => { + let log; + + beforeEach(() => { + debug.enable('test'); + log = debug('test'); + }); + + context('with log function', () => { + it('uses it', () => { + log.log = spy(); + log('using custom log function'); + + assert.calledOnce(log.log); + }); + }); + }); +>>>>>>> upstream/master }); From 67182fdb001d51c4dde667dc43d8ccbc791bd716 Mon Sep 17 00:00:00 2001 From: Yami Date: Tue, 20 Dec 2016 12:33:56 +0000 Subject: [PATCH 073/257] fix: Whoops, didn't merge the tests properly. Resolved. --- test/debug_spec.js | 45 +++++++++++++-------------------------------- 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/test/debug_spec.js b/test/debug_spec.js index f7a6e51d..2df05235 100644 --- a/test/debug_spec.js +++ b/test/debug_spec.js @@ -1,5 +1,5 @@ -/* global describe, it */ -'use strict' +/* global describe, it, context, beforeEach */ +'use strict'; if (typeof module !== 'undefined') { var chai = require('chai'); @@ -11,47 +11,28 @@ if (typeof module !== 'undefined') { chai.use(sinonChai); } -var dummyConsole = { - log: function() { - //dummy function - } -}; - describe('debug', function () { var log = debug('test'); log.log = sinon.stub(); - it('passes a basic sanity check', function () { - expect(log('hello world')).to.not.throw; - }); - - it('Should output to the log function', function () { - debug.log = dummyConsole.log; - sinon.spy(dummyConsole, 'log'); - log('Hello world'); - //expect(dummyConsole.log).to.have.been.called; - }); -<<<<<<< HEAD -======= - }); - describe('custom functions', () => { - let log; + it('passes a basic sanity check', function () { + expect(log('hello world')).to.not.throw; + }); - beforeEach(() => { + context('with log function', function () { + + beforeEach(function () { debug.enable('test'); log = debug('test'); }); + + it('uses it', function () { + log.log = sinon.stub(); + log('using custom log function'); - context('with log function', () => { - it('uses it', () => { - log.log = spy(); - log('using custom log function'); - - assert.calledOnce(log.log); - }); + expect(log.log).to.have.been.calledOnce; }); }); ->>>>>>> upstream/master }); From 3e1a15d06215f4ed33098bf1f6da7377f4680f42 Mon Sep 17 00:00:00 2001 From: Yami Date: Tue, 20 Dec 2016 12:53:42 +0000 Subject: [PATCH 074/257] fix: merged again, because it didn't take. Guess I did it wrong? --- test/debug_spec.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/debug_spec.js b/test/debug_spec.js index 2df05235..84304d9e 100644 --- a/test/debug_spec.js +++ b/test/debug_spec.js @@ -35,4 +35,5 @@ describe('debug', function () { expect(log.log).to.have.been.calledOnce; }); }); + }); From f484cfedc446f2f75298a14971f63e26ac7d8c52 Mon Sep 17 00:00:00 2001 From: Accalia de Elementia Date: Tue, 20 Dec 2016 13:28:20 +0000 Subject: [PATCH 075/257] fix merge errors --- test/debug_spec.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/debug_spec.js b/test/debug_spec.js index d2096789..b6f4e9d2 100644 --- a/test/debug_spec.js +++ b/test/debug_spec.js @@ -6,7 +6,7 @@ if (typeof module !== 'undefined') { var expect = chai.expect; var debug = require('../src/index'); - var = require('sinon'); + var sinon = require('sinon'); var sinonChai = require("sinon-chai"); chai.use(sinonChai); } @@ -36,20 +36,20 @@ describe('debug', function () { }); }); - describe('custom functions', () => { - let log; + describe('custom functions', function () { + var log; - beforeEach(() => { + beforeEach(function () { debug.enable('test'); log = debug('test'); }); - context('with log function', () => { - it('uses it', () => { + context('with log function', function () { + it('uses it', function () { log.log = sinon.spy(); log('using custom log function'); - chai.assert.calledOnce(log.log); + expect(log.log).to.have.been.calledOnce; }); }); }); From 408ae94373aaa8693b23b5b402bbeb4320c9e210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristoffer=20Lund=C3=A9n?= Date: Tue, 20 Dec 2016 21:33:50 +0100 Subject: [PATCH 076/257] Use typeof window.process !== 'undefined' 'process' in window returns true after window.process = null --- browser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser.js b/browser.js index 52f3a972..8d013bc2 100644 --- a/browser.js +++ b/browser.js @@ -40,7 +40,7 @@ function useColors() { // NB: In an Electron preload script, document will be defined but not fully // initialized. Since we know we're in Chrome, we'll just detect this case // explicitly - if (typeof window !== 'undefined' && 'process' in window && window.process.type === 'renderer') { + if (typeof window !== 'undefined' && typeof window.process !== 'undefined' && window.process.type === 'renderer') { return true; } From 78e31a8e73826702fa75611f06ee788c5f42ce71 Mon Sep 17 00:00:00 2001 From: Ashley Date: Tue, 20 Dec 2016 22:11:32 +0100 Subject: [PATCH 077/257] Update browser.js --- browser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser.js b/browser.js index 52f3a972..91bea91f 100644 --- a/browser.js +++ b/browser.js @@ -95,7 +95,7 @@ function formatArgs(args) { // figure out the correct index to insert the CSS into var index = 0; var lastC = 0; - args[0].replace(/%[a-z%]/g, function(match) { + args[0].replace(/%[a-zA-Z%]/g, function(match) { if ('%%' === match) return; index++; if ('%c' === match) { From d85c0c613d4c9a89c86802ac3014daccafa00b4f Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Tue, 20 Dec 2016 20:25:34 -0800 Subject: [PATCH 078/257] build perf, fix for bowerfile, fix for webworker --- .eslintrc | 5 - .gitignore | 1 + .npmignore | 1 + CHANGELOG.md | 1 - Makefile | 32 +- README.md | 2 +- bower.json | 2 +- component.json | 2 +- dist/browser.js | 715 ------------------------------------------ dist/debug.js | 720 ------------------------------------------- package.json | 11 +- scripts/precommit.sh | 29 -- src/browser.js | 6 +- test/debug_spec.js | 16 +- 14 files changed, 38 insertions(+), 1505 deletions(-) delete mode 100644 dist/browser.js delete mode 100644 dist/debug.js delete mode 100755 scripts/precommit.sh diff --git a/.eslintrc b/.eslintrc index 658f7d8f..8a37ae2c 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,9 +1,4 @@ { - "parserOptions": { - "ecmaVersion": 6, - "sourceType": "module" - }, - "parser": "babel-eslint", "env": { "browser": true, "node": true diff --git a/.gitignore b/.gitignore index 84f7efc1..be347060 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ node_modules *.sock build yarn.lock +coverage diff --git a/.npmignore b/.npmignore index 35b0dc77..db2fbb9d 100644 --- a/.npmignore +++ b/.npmignore @@ -5,3 +5,4 @@ example *.sock dist yarn.lock +coverage diff --git a/CHANGELOG.md b/CHANGELOG.md index 58143e7e..fa37bea2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,3 @@ - 2.4.5 / 2016-12-17 ================== diff --git a/Makefile b/Makefile index 5d1d4cdd..1a2c195a 100644 --- a/Makefile +++ b/Makefile @@ -20,21 +20,7 @@ BROWSERIFY ?= $(NODE) $(BIN)/browserify all: dist/debug.js install: node_modules - -clean: - @rm -rf dist - -dist: - @mkdir -p $@ - -dist/debug.js: node_modules browser.js debug.js dist - @$(BROWSERIFY) \ - --standalone debug \ - . > $@ - -distclean: clean - @rm -rf node_modules - + node_modules: package.json @NODE_ENV= $(PKG) install @touch node_modules @@ -42,9 +28,23 @@ node_modules: package.json lint: .FORCE eslint browser.js debug.js index.js node.js -test: .FORCE +test-node: .FORCE istanbul cover node_modules/mocha/bin/_mocha -- test/**.js + +test-browser: .FORCE + mkdir -p dist + + @$(BROWSERIFY) \ + --standalone debug \ + . > dist/debug.js + karma start --single-run + rimraf dist + +test: .FORCE + concurrently \ + "make test-node" \ + "make test-browser" coveralls: cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js diff --git a/README.md b/README.md index 89e7f576..948c1a87 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # debug -[![Build Status](https://travis-ci.org/visionmedia/debug.svg?branch=master)](https://travis-ci.org/visionmedia/debug) +[![Build Status](https://travis-ci.org/visionmedia/debug.svg?branch=master)](https://travis-ci.org/visionmedia/debug) [![Coverage Status](https://coveralls.io/repos/github/visionmedia/debug/badge.svg?branch=master)](https://coveralls.io/github/visionmedia/debug?branch=master) A tiny node.js debugging utility modelled after node core's debugging technique. diff --git a/bower.json b/bower.json index ad6589ef..027804ce 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "visionmedia-debug", - "main": "./src/debug.js", + "main": "./src/browser.js", "homepage": "https://github.com/visionmedia/debug", "authors": [ "TJ Holowaychuk ", diff --git a/component.json b/component.json index 00a036a1..6bf22fa5 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "debug", "repo": "visionmedia/debug", "description": "small debugging utility", - "version": "2.4.5", + "version": "2.4.6", "keywords": [ "debug", "log", diff --git a/dist/browser.js b/dist/browser.js deleted file mode 100644 index 4437883d..00000000 --- a/dist/browser.js +++ /dev/null @@ -1,715 +0,0 @@ -(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } -}; - -// v8 likes predictible objects -function Item(fun, array) { - this.fun = fun; - this.array = array; -} -Item.prototype.run = function () { - this.fun.apply(null, this.array); -}; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; - -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; - -},{}],2:[function(require,module,exports){ -/** - * Helpers. - */ - -var s = 1000 -var m = s * 60 -var h = m * 60 -var d = h * 24 -var y = d * 365.25 - -/** - * Parse or format the given `val`. - * - * Options: - * - * - `long` verbose formatting [false] - * - * @param {String|Number} val - * @param {Object} options - * @throws {Error} throw an error if val is not a non-empty string or a number - * @return {String|Number} - * @api public - */ - -module.exports = function (val, options) { - options = options || {} - var type = typeof val - if (type === 'string' && val.length > 0) { - return parse(val) - } else if (type === 'number' && isNaN(val) === false) { - return options.long ? - fmtLong(val) : - fmtShort(val) - } - throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val)) -} - -/** - * Parse the given `str` and return milliseconds. - * - * @param {String} str - * @return {Number} - * @api private - */ - -function parse(str) { - str = String(str) - if (str.length > 10000) { - return - } - var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str) - if (!match) { - return - } - var n = parseFloat(match[1]) - var type = (match[2] || 'ms').toLowerCase() - switch (type) { - case 'years': - case 'year': - case 'yrs': - case 'yr': - case 'y': - return n * y - case 'days': - case 'day': - case 'd': - return n * d - case 'hours': - case 'hour': - case 'hrs': - case 'hr': - case 'h': - return n * h - case 'minutes': - case 'minute': - case 'mins': - case 'min': - case 'm': - return n * m - case 'seconds': - case 'second': - case 'secs': - case 'sec': - case 's': - return n * s - case 'milliseconds': - case 'millisecond': - case 'msecs': - case 'msec': - case 'ms': - return n - default: - return undefined - } -} - -/** - * Short format for `ms`. - * - * @param {Number} ms - * @return {String} - * @api private - */ - -function fmtShort(ms) { - if (ms >= d) { - return Math.round(ms / d) + 'd' - } - if (ms >= h) { - return Math.round(ms / h) + 'h' - } - if (ms >= m) { - return Math.round(ms / m) + 'm' - } - if (ms >= s) { - return Math.round(ms / s) + 's' - } - return ms + 'ms' -} - -/** - * Long format for `ms`. - * - * @param {Number} ms - * @return {String} - * @api private - */ - -function fmtLong(ms) { - return plural(ms, d, 'day') || - plural(ms, h, 'hour') || - plural(ms, m, 'minute') || - plural(ms, s, 'second') || - ms + ' ms' -} - -/** - * Pluralization helper. - */ - -function plural(ms, n, name) { - if (ms < n) { - return - } - if (ms < n * 1.5) { - return Math.floor(ms / n) + ' ' + name - } - return Math.ceil(ms / n) + ' ' + name + 's' -} - -},{}],3:[function(require,module,exports){ -(function (process){ -/** - * This is the web browser implementation of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = require('./debug'); -exports.log = log; -exports.formatArgs = formatArgs; -exports.save = save; -exports.load = load; -exports.useColors = useColors; -exports.storage = 'undefined' != typeof chrome - && 'undefined' != typeof chrome.storage - ? chrome.storage.local - : localstorage(); - -/** - * Colors. - */ - -exports.colors = [ - 'lightseagreen', - 'forestgreen', - 'goldenrod', - 'dodgerblue', - 'darkorchid', - 'crimson' -]; - -/** - * Currently only WebKit-based Web Inspectors, Firefox >= v31, - * and the Firebug extension (any Firefox version) are known - * to support "%c" CSS customizations. - * - * TODO: add a `localStorage` variable to explicitly enable/disable colors - */ - -function useColors() { - // is webkit? http://stackoverflow.com/a/16459606/376773 - // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 - return (typeof document !== 'undefined' && 'WebkitAppearance' in document.documentElement.style) || - // is firebug? http://stackoverflow.com/a/398120/376773 - (typeof window !== 'undefined' && window.console && (console.firebug || (console.exception && console.table))) || - // is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || - // double check webkit in userAgent just in case we are in a worker - (navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); -} - -/** - * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. - */ - -exports.formatters.j = function(v) { - try { - return JSON.stringify(v); - } catch (err) { - return '[UnexpectedJSONParseError]: ' + err.message; - } -}; - - -/** - * Colorize log arguments if enabled. - * - * @api public - */ - -function formatArgs(args) { - var useColors = this.useColors; - - args[0] = (useColors ? '%c' : '') - + this.namespace - + (useColors ? ' %c' : ' ') - + args[0] - + (useColors ? '%c ' : ' ') - + '+' + exports.humanize(this.diff); - - if (!useColors) return; - - var c = 'color: ' + this.color; - args.splice(1, 0, c, 'color: inherit') - - // the final "%c" is somewhat tricky, because there could be other - // arguments passed either before or after the %c, so we need to - // figure out the correct index to insert the CSS into - var index = 0; - var lastC = 0; - args[0].replace(/%[a-z%]/g, function(match) { - if ('%%' === match) return; - index++; - if ('%c' === match) { - // we only are interested in the *last* %c - // (the user may have provided their own) - lastC = index; - } - }); - - args.splice(lastC, 0, c); -} - -/** - * Invokes `console.log()` when available. - * No-op when `console.log` is not a "function". - * - * @api public - */ - -function log() { - // this hackery is required for IE8/9, where - // the `console.log` function doesn't have 'apply' - return 'object' === typeof console - && console.log - && Function.prototype.apply.call(console.log, console, arguments); -} - -/** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ - -function save(namespaces) { - try { - if (null == namespaces) { - exports.storage.removeItem('debug'); - } else { - exports.storage.debug = namespaces; - } - } catch(e) {} -} - -/** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ - -function load() { - var r; - try { - return exports.storage.debug; - } catch(e) {} - - // If debug isn't set in LS, and we're in Electron, try to load $DEBUG - if (typeof process !== 'undefined' && 'env' in process) { - return process.env.DEBUG; - } -} - -/** - * Enable namespaces listed in `localStorage.debug` initially. - */ - -exports.enable(load()); - -/** - * Localstorage attempts to return the localstorage. - * - * This is necessary because safari throws - * when a user disables cookies/localstorage - * and you attempt to access it. - * - * @return {LocalStorage} - * @api private - */ - -function localstorage() { - try { - return window.localStorage; - } catch (e) {} -} - -}).call(this,require('_process')) -},{"./debug":4,"_process":1}],4:[function(require,module,exports){ - -/** - * This is the common logic for both the Node.js and web browser - * implementations of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = createDebug.debug = createDebug.default = createDebug; -exports.coerce = coerce; -exports.disable = disable; -exports.enable = enable; -exports.enabled = enabled; -exports.humanize = require('ms'); - -/** - * The currently active debug mode names, and names to skip. - */ - -exports.names = []; -exports.skips = []; - -/** - * Map of special "%n" handling functions, for the debug "format" argument. - * - * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". - */ - -exports.formatters = {}; - -/** - * Previous log timestamp. - */ - -var prevTime; - -/** - * Select a color. - * @param {String} namespace - * @return {Number} - * @api private - */ - -function selectColor(namespace) { - var hash = 0, i; - - for (i in namespace) { - hash = ((hash << 5) - hash) + namespace.charCodeAt(i); - hash |= 0; // Convert to 32bit integer - } - - return exports.colors[Math.abs(hash) % exports.colors.length]; -} - -/** - * Create a debugger with the given `namespace`. - * - * @param {String} namespace - * @return {Function} - * @api public - */ - -function createDebug(namespace) { - - function debug() { - // disabled? - if (!debug.enabled) return; - - var self = debug; - - // set `diff` timestamp - var curr = +new Date(); - var ms = curr - (prevTime || curr); - self.diff = ms; - self.prev = prevTime; - self.curr = curr; - prevTime = curr; - - // turn the `arguments` into a proper Array - var args = new Array(arguments.length); - for (var i = 0; i < args.length; i++) { - args[i] = arguments[i]; - } - - args[0] = exports.coerce(args[0]); - - if ('string' !== typeof args[0]) { - // anything else let's inspect with %O - args.unshift('%O'); - } - - // apply any `formatters` transformations - var index = 0; - args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) { - // if we encounter an escaped % then don't increase the array index - if (match === '%%') return match; - index++; - var formatter = exports.formatters[format]; - if ('function' === typeof formatter) { - var val = args[index]; - match = formatter.call(self, val); - - // now we need to remove `args[index]` since it's inlined in the `format` - args.splice(index, 1); - index--; - } - return match; - }); - - // apply env-specific formatting (colors, etc.) - exports.formatArgs.call(self, args); - - var logFn = enabled.log || exports.log || console.log.bind(console); - logFn.apply(self, args); - } - - debug.namespace = namespace; - debug.enabled = exports.enabled(namespace); - debug.useColors = exports.useColors(); - debug.color = selectColor(namespace); - - // env-specific initialization logic for debug instances - if ('function' === typeof exports.init) { - exports.init(debug); - } - - return debug; -} - -/** - * Enables a debug mode by namespaces. This can include modes - * separated by a colon and wildcards. - * - * @param {String} namespaces - * @api public - */ - -function enable(namespaces) { - exports.save(namespaces); - - var split = (namespaces || '').split(/[\s,]+/); - var len = split.length; - - for (var i = 0; i < len; i++) { - if (!split[i]) continue; // ignore empty strings - namespaces = split[i].replace(/\*/g, '.*?'); - if (namespaces[0] === '-') { - exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); - } else { - exports.names.push(new RegExp('^' + namespaces + '$')); - } - } -} - -/** - * Disable debug output. - * - * @api public - */ - -function disable() { - exports.enable(''); -} - -/** - * Returns true if the given mode name is enabled, false otherwise. - * - * @param {String} name - * @return {Boolean} - * @api public - */ - -function enabled(name) { - var i, len; - for (i = 0, len = exports.skips.length; i < len; i++) { - if (exports.skips[i].test(name)) { - return false; - } - } - for (i = 0, len = exports.names.length; i < len; i++) { - if (exports.names[i].test(name)) { - return true; - } - } - return false; -} - -/** - * Coerce `val`. - * - * @param {Mixed} val - * @return {Mixed} - * @api private - */ - -function coerce(val) { - if (val instanceof Error) return val.stack || val.message; - return val; -} - -},{"ms":2}]},{},[3]); diff --git a/dist/debug.js b/dist/debug.js deleted file mode 100644 index a57f060e..00000000 --- a/dist/debug.js +++ /dev/null @@ -1,720 +0,0 @@ -(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } -}; - -// v8 likes predictible objects -function Item(fun, array) { - this.fun = fun; - this.array = array; -} -Item.prototype.run = function () { - this.fun.apply(null, this.array); -}; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; - -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; - -},{}],2:[function(require,module,exports){ -/** - * Helpers. - */ - -var s = 1000 -var m = s * 60 -var h = m * 60 -var d = h * 24 -var y = d * 365.25 - -/** - * Parse or format the given `val`. - * - * Options: - * - * - `long` verbose formatting [false] - * - * @param {String|Number} val - * @param {Object} options - * @throws {Error} throw an error if val is not a non-empty string or a number - * @return {String|Number} - * @api public - */ - -module.exports = function (val, options) { - options = options || {} - var type = typeof val - if (type === 'string' && val.length > 0) { - return parse(val) - } else if (type === 'number' && isNaN(val) === false) { - return options.long ? - fmtLong(val) : - fmtShort(val) - } - throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val)) -} - -/** - * Parse the given `str` and return milliseconds. - * - * @param {String} str - * @return {Number} - * @api private - */ - -function parse(str) { - str = String(str) - if (str.length > 10000) { - return - } - var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str) - if (!match) { - return - } - var n = parseFloat(match[1]) - var type = (match[2] || 'ms').toLowerCase() - switch (type) { - case 'years': - case 'year': - case 'yrs': - case 'yr': - case 'y': - return n * y - case 'days': - case 'day': - case 'd': - return n * d - case 'hours': - case 'hour': - case 'hrs': - case 'hr': - case 'h': - return n * h - case 'minutes': - case 'minute': - case 'mins': - case 'min': - case 'm': - return n * m - case 'seconds': - case 'second': - case 'secs': - case 'sec': - case 's': - return n * s - case 'milliseconds': - case 'millisecond': - case 'msecs': - case 'msec': - case 'ms': - return n - default: - return undefined - } -} - -/** - * Short format for `ms`. - * - * @param {Number} ms - * @return {String} - * @api private - */ - -function fmtShort(ms) { - if (ms >= d) { - return Math.round(ms / d) + 'd' - } - if (ms >= h) { - return Math.round(ms / h) + 'h' - } - if (ms >= m) { - return Math.round(ms / m) + 'm' - } - if (ms >= s) { - return Math.round(ms / s) + 's' - } - return ms + 'ms' -} - -/** - * Long format for `ms`. - * - * @param {Number} ms - * @return {String} - * @api private - */ - -function fmtLong(ms) { - return plural(ms, d, 'day') || - plural(ms, h, 'hour') || - plural(ms, m, 'minute') || - plural(ms, s, 'second') || - ms + ' ms' -} - -/** - * Pluralization helper. - */ - -function plural(ms, n, name) { - if (ms < n) { - return - } - if (ms < n * 1.5) { - return Math.floor(ms / n) + ' ' + name - } - return Math.ceil(ms / n) + ' ' + name + 's' -} - -},{}],3:[function(require,module,exports){ - -/** - * This is the common logic for both the Node.js and web browser - * implementations of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = createDebug.debug = createDebug.default = createDebug; -exports.coerce = coerce; -exports.disable = disable; -exports.enable = enable; -exports.enabled = enabled; -exports.humanize = require('ms'); - -/** - * The currently active debug mode names, and names to skip. - */ - -exports.names = []; -exports.skips = []; - -/** - * Map of special "%n" handling functions, for the debug "format" argument. - * - * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". - */ - -exports.formatters = {}; - -/** - * Previous log timestamp. - */ - -var prevTime; - -/** - * Select a color. - * @param {String} namespace - * @return {Number} - * @api private - */ - -function selectColor(namespace) { - var hash = 0, i; - - for (i in namespace) { - hash = ((hash << 5) - hash) + namespace.charCodeAt(i); - hash |= 0; // Convert to 32bit integer - } - - return exports.colors[Math.abs(hash) % exports.colors.length]; -} - -/** - * Create a debugger with the given `namespace`. - * - * @param {String} namespace - * @return {Function} - * @api public - */ - -function createDebug(namespace) { - - function debug() { - // disabled? - if (!debug.enabled) return; - - var self = debug; - - // set `diff` timestamp - var curr = +new Date(); - var ms = curr - (prevTime || curr); - self.diff = ms; - self.prev = prevTime; - self.curr = curr; - prevTime = curr; - - // turn the `arguments` into a proper Array - var args = new Array(arguments.length); - for (var i = 0; i < args.length; i++) { - args[i] = arguments[i]; - } - - args[0] = exports.coerce(args[0]); - - if ('string' !== typeof args[0]) { - // anything else let's inspect with %O - args.unshift('%O'); - } - - // apply any `formatters` transformations - var index = 0; - args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) { - // if we encounter an escaped % then don't increase the array index - if (match === '%%') return match; - index++; - var formatter = exports.formatters[format]; - if ('function' === typeof formatter) { - var val = args[index]; - match = formatter.call(self, val); - - // now we need to remove `args[index]` since it's inlined in the `format` - args.splice(index, 1); - index--; - } - return match; - }); - - // apply env-specific formatting (colors, etc.) - exports.formatArgs.call(self, args); - - var logFn = enabled.log || exports.log || console.log.bind(console); - logFn.apply(self, args); - } - - debug.namespace = namespace; - debug.enabled = exports.enabled(namespace); - debug.useColors = exports.useColors(); - debug.color = selectColor(namespace); - - // env-specific initialization logic for debug instances - if ('function' === typeof exports.init) { - exports.init(debug); - } - - return debug; -} - -/** - * Enables a debug mode by namespaces. This can include modes - * separated by a colon and wildcards. - * - * @param {String} namespaces - * @api public - */ - -function enable(namespaces) { - exports.save(namespaces); - - var split = (namespaces || '').split(/[\s,]+/); - var len = split.length; - - for (var i = 0; i < len; i++) { - if (!split[i]) continue; // ignore empty strings - namespaces = split[i].replace(/\*/g, '.*?'); - if (namespaces[0] === '-') { - exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); - } else { - exports.names.push(new RegExp('^' + namespaces + '$')); - } - } -} - -/** - * Disable debug output. - * - * @api public - */ - -function disable() { - exports.enable(''); -} - -/** - * Returns true if the given mode name is enabled, false otherwise. - * - * @param {String} name - * @return {Boolean} - * @api public - */ - -function enabled(name) { - var i, len; - for (i = 0, len = exports.skips.length; i < len; i++) { - if (exports.skips[i].test(name)) { - return false; - } - } - for (i = 0, len = exports.names.length; i < len; i++) { - if (exports.names[i].test(name)) { - return true; - } - } - return false; -} - -/** - * Coerce `val`. - * - * @param {Mixed} val - * @return {Mixed} - * @api private - */ - -function coerce(val) { - if (val instanceof Error) return val.stack || val.message; - return val; -} - -},{"ms":2}],4:[function(require,module,exports){ -(function (process){ -/** - * This is the web browser implementation of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = require('./debug'); -exports.log = log; -exports.formatArgs = formatArgs; -exports.save = save; -exports.load = load; -exports.useColors = useColors; -exports.storage = 'undefined' != typeof chrome - && 'undefined' != typeof chrome.storage - ? chrome.storage.local - : localstorage(); - -/** - * Colors. - */ - -exports.colors = [ - 'lightseagreen', - 'forestgreen', - 'goldenrod', - 'dodgerblue', - 'darkorchid', - 'crimson' -]; - -/** - * Currently only WebKit-based Web Inspectors, Firefox >= v31, - * and the Firebug extension (any Firefox version) are known - * to support "%c" CSS customizations. - * - * TODO: add a `localStorage` variable to explicitly enable/disable colors - */ - -function useColors() { - // is webkit? http://stackoverflow.com/a/16459606/376773 - // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 - return (typeof document !== 'undefined' && 'WebkitAppearance' in document.documentElement.style) || - // is firebug? http://stackoverflow.com/a/398120/376773 - (typeof window !== 'undefined' && window.console && (console.firebug || (console.exception && console.table))) || - // is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || - // double check webkit in userAgent just in case we are in a worker - (navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); -} - -/** - * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. - */ - -exports.formatters.j = function(v) { - try { - return JSON.stringify(v); - } catch (err) { - return '[UnexpectedJSONParseError]: ' + err.message; - } -}; - - -/** - * Colorize log arguments if enabled. - * - * @api public - */ - -function formatArgs(args) { - var useColors = this.useColors; - - args[0] = (useColors ? '%c' : '') - + this.namespace - + (useColors ? ' %c' : ' ') - + args[0] - + (useColors ? '%c ' : ' ') - + '+' + exports.humanize(this.diff); - - if (!useColors) return; - - var c = 'color: ' + this.color; - args.splice(1, 0, c, 'color: inherit') - - // the final "%c" is somewhat tricky, because there could be other - // arguments passed either before or after the %c, so we need to - // figure out the correct index to insert the CSS into - var index = 0; - var lastC = 0; - args[0].replace(/%[a-z%]/g, function(match) { - if ('%%' === match) return; - index++; - if ('%c' === match) { - // we only are interested in the *last* %c - // (the user may have provided their own) - lastC = index; - } - }); - - args.splice(lastC, 0, c); -} - -/** - * Invokes `console.log()` when available. - * No-op when `console.log` is not a "function". - * - * @api public - */ - -function log() { - // this hackery is required for IE8/9, where - // the `console.log` function doesn't have 'apply' - return 'object' === typeof console - && console.log - && Function.prototype.apply.call(console.log, console, arguments); -} - -/** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ - -function save(namespaces) { - try { - if (null == namespaces) { - exports.storage.removeItem('debug'); - } else { - exports.storage.debug = namespaces; - } - } catch(e) {} -} - -/** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ - -function load() { - var r; - try { - return exports.storage.debug; - } catch(e) {} - - // If debug isn't set in LS, and we're in Electron, try to load $DEBUG - if (typeof process !== 'undefined' && 'env' in process) { - return process.env.DEBUG; - } -} - -/** - * Enable namespaces listed in `localStorage.debug` initially. - */ - -exports.enable(load()); - -/** - * Localstorage attempts to return the localstorage. - * - * This is necessary because safari throws - * when a user disables cookies/localstorage - * and you attempt to access it. - * - * @return {LocalStorage} - * @api private - */ - -function localstorage() { - try { - return window.localStorage; - } catch (e) {} -} - -/** Attach to Window*/ -if (window) { - window.debug = exports; -} - -}).call(this,require('_process')) -},{"./debug":3,"_process":1}]},{},[4]); diff --git a/package.json b/package.json index 62bed8d1..c158e574 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "2.4.5", + "version": "2.4.6", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" @@ -23,10 +23,9 @@ "devDependencies": { "browserify": "9.0.3", "chai": "^3.5.0", + "concurrently": "^3.1.0", "coveralls": "^2.11.15", "eslint": "^3.12.1", - "eslint-plugin-babel": "^4.0.0", - "ghooks": "^1.3.2", "istanbul": "^0.4.5", "karma": "^1.3.0", "karma-chai": "^0.1.0", @@ -35,6 +34,7 @@ "karma-sinon": "^1.0.5", "mocha": "^3.2.0", "mocha-lcov-reporter": "^1.2.0", + "rimraf": "^2.5.4", "sinon": "^1.17.6", "sinon-chai": "^2.8.0" }, @@ -45,10 +45,5 @@ "debug/index.js": "browser.js", "debug/debug.js": "debug.js" } - }, - "config": { - "ghooks": { - "pre-commit": "scripts/precommit.sh" - } } } diff --git a/scripts/precommit.sh b/scripts/precommit.sh deleted file mode 100755 index 071ca416..00000000 --- a/scripts/precommit.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# -# An example hook script to verify what is about to be committed. -# Called by "git commit" with no arguments. The hook should -# exit with non-zero status after issuing an appropriate message if -# it wants to stop the commit. -# -# To enable this hook, rename this file to "pre-commit". - -# Stash anything not being committed -git stash -q --keep-index - -echo -echo "Generating dist" -echo -# Make the dist files -make dist -echo -echo -echo "Distribution generation complete" -echo -echo "Adding updated files to commit" -echo -# add them -git add dist/ -git add -u dist/ - -# Restore uncommitted changes -git stash pop -q diff --git a/src/browser.js b/src/browser.js index 10a3586c..b11dd2da 100644 --- a/src/browser.js +++ b/src/browser.js @@ -10,9 +10,9 @@ exports.formatArgs = formatArgs; exports.save = save; exports.load = load; exports.useColors = useColors; -exports.storage = 'undefined' != typeof window.chrome - && 'undefined' != typeof window.chrome.storage - ? window.chrome.storage.local +exports.storage = 'undefined' != typeof chrome + && 'undefined' != typeof chrome.storage + ? chrome.storage.local : localstorage(); /** diff --git a/test/debug_spec.js b/test/debug_spec.js index b6f4e9d2..4ab4d88d 100644 --- a/test/debug_spec.js +++ b/test/debug_spec.js @@ -1,13 +1,19 @@ /* global describe, it, context, beforeEach */ 'use strict'; +var chai + , expect + , debug + , sinon + , sinonChai; + if (typeof module !== 'undefined') { - var chai = require('chai'); - var expect = chai.expect; + chai = require('chai'); + expect = chai.expect; - var debug = require('../src/index'); - var sinon = require('sinon'); - var sinonChai = require("sinon-chai"); + debug = require('../src/index'); + sinon = require('sinon'); + sinonChai = require("sinon-chai"); chai.use(sinonChai); } From 355e327c94e03aaf0c215b32244eeeacd8a298c8 Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Tue, 20 Dec 2016 21:03:06 -0800 Subject: [PATCH 079/257] release 2.5.0 --- CHANGELOG.md | 14 ++++++++++++++ component.json | 2 +- package.json | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa37bea2..4a67da11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ + +2.5.0 / 2016-12-20 +================== + + * Fix: wrong reference in bower file (@thebigredgeek) + * Fix: webworker compatibility (@thebigredgeek) + * Fix: output formatting issue (#388, @kribblo) + * Fix: babel-loader compatibility (#383, @escwald) + * Misc: removed built asset from repo and publications (@thebigredgeek) + * Misc: moved source files to /src (#378, @yamikuronue) + * Test: added karma integration and replaced babel with browserify for browser tests (#378, @yamikuronue) + * Test: coveralls integration (#378, @yamikuronue) + * Docs: simplified language in the opening paragraph (#373, @yamikuronue) + 2.4.5 / 2016-12-17 ================== diff --git a/component.json b/component.json index 6bf22fa5..5fc5f41c 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "debug", "repo": "visionmedia/debug", "description": "small debugging utility", - "version": "2.4.6", + "version": "2.5.0", "keywords": [ "debug", "log", diff --git a/package.json b/package.json index c158e574..80194482 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "2.4.6", + "version": "2.5.0", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From 86d8245268d6c6f488bfdb54c270a427ff78aee6 Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Tue, 20 Dec 2016 21:03:06 -0800 Subject: [PATCH 080/257] release 2.5.0 --- .coveralls.yml | 1 + CHANGELOG.md | 14 ++++++++++++++ component.json | 2 +- package.json | 2 +- 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 .coveralls.yml diff --git a/.coveralls.yml b/.coveralls.yml new file mode 100644 index 00000000..20a70685 --- /dev/null +++ b/.coveralls.yml @@ -0,0 +1 @@ +repo_token: SIAeZjKYlHK74rbcFvNHMUzjRiMpflxve diff --git a/CHANGELOG.md b/CHANGELOG.md index fa37bea2..4a67da11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ + +2.5.0 / 2016-12-20 +================== + + * Fix: wrong reference in bower file (@thebigredgeek) + * Fix: webworker compatibility (@thebigredgeek) + * Fix: output formatting issue (#388, @kribblo) + * Fix: babel-loader compatibility (#383, @escwald) + * Misc: removed built asset from repo and publications (@thebigredgeek) + * Misc: moved source files to /src (#378, @yamikuronue) + * Test: added karma integration and replaced babel with browserify for browser tests (#378, @yamikuronue) + * Test: coveralls integration (#378, @yamikuronue) + * Docs: simplified language in the opening paragraph (#373, @yamikuronue) + 2.4.5 / 2016-12-17 ================== diff --git a/component.json b/component.json index 6bf22fa5..5fc5f41c 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "debug", "repo": "visionmedia/debug", "description": "small debugging utility", - "version": "2.4.6", + "version": "2.5.0", "keywords": [ "debug", "log", diff --git a/package.json b/package.json index c158e574..80194482 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "2.4.6", + "version": "2.5.0", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From 5a1a36c3025abb5750a7fd12b5deac7fcca65ea5 Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Tue, 20 Dec 2016 21:29:23 -0800 Subject: [PATCH 081/257] fix --- .gitignore | 1 + .travis.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index be347060..ccaa248a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ node_modules *.sock build yarn.lock +dist coverage diff --git a/.travis.yml b/.travis.yml index 4db6e14e..6c6090c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,4 +11,4 @@ install: script: - make lint - make test - - make coveralls \ No newline at end of file + - make coveralls From a31178c8d842c192261b70085b9da9ec1333c6a8 Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Tue, 20 Dec 2016 21:31:53 -0800 Subject: [PATCH 082/257] hotfix for babel-core --- node.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 node.js diff --git a/node.js b/node.js new file mode 100644 index 00000000..7fc36fe6 --- /dev/null +++ b/node.js @@ -0,0 +1 @@ +module.exports = require('./src/node'); From 3950daef4c63058e4c2c130b7e90666416b3d5d1 Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Tue, 20 Dec 2016 21:32:58 -0800 Subject: [PATCH 083/257] release 2.5.1 --- CHANGELOG.md | 5 +++++ component.json | 2 +- package.json | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a67da11..5ea785a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ +2.5.1 / 2016-12-20 +================== + + * Fix: babel-core compatibility + 2.5.0 / 2016-12-20 ================== diff --git a/component.json b/component.json index 5fc5f41c..3767637c 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "debug", "repo": "visionmedia/debug", "description": "small debugging utility", - "version": "2.5.0", + "version": "2.5.1", "keywords": [ "debug", "log", diff --git a/package.json b/package.json index 80194482..67fb9945 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "2.5.0", + "version": "2.5.1", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From ea43614db8349ae8f1083de00f187f2e5611375f Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Tue, 20 Dec 2016 22:04:55 -0800 Subject: [PATCH 084/257] added notice about v3 api discussion --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 948c1a87..75dcabb8 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ A tiny node.js debugging utility modelled after node core's debugging technique. +**Discussion around the V3 API is under way [here](https://github.com/visionmedia/debug/issues/370)** ## Installation From 146d0d1c0aa4f515ce5df0510f7c26481781ccd3 Mon Sep 17 00:00:00 2001 From: Andrew Scheller Date: Wed, 21 Dec 2016 06:17:41 +0000 Subject: [PATCH 085/257] Fix README typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 75dcabb8..ff244814 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ setInterval(function(){ set DEBUG=*,-not_this ``` - Note that PowerShell using different syntax to set environment variables. + Note that PowerShell uses different syntax to set environment variables. ```cmd $env:DEBUG = "*,-not_this" From eba68cec1a154508f3f48d552b79af0dac193432 Mon Sep 17 00:00:00 2001 From: Klaus Trainer Date: Mon, 26 Dec 2016 03:34:37 +0100 Subject: [PATCH 086/257] fix(browser): prevent ReferenceError in workers (#393) fixes #382 --- src/browser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/browser.js b/src/browser.js index b11dd2da..006a8c11 100644 --- a/src/browser.js +++ b/src/browser.js @@ -182,6 +182,6 @@ function localstorage() { } /** Attach to Window*/ -if (window) { +if (typeof window !== 'undefined') { window.debug = exports; } From 9a18d66282caa2e237d270a0f2cd150362cbf636 Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Sun, 25 Dec 2016 20:39:21 -0600 Subject: [PATCH 087/257] release 2.5.2 --- CHANGELOG.md | 7 +++++++ component.json | 2 +- package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ea785a0..8dbe6ada 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,11 @@ +2.5.2 / 2016-12-25 +================== + + * Fix: reference error on window within webworkers (#393, @KlausTrainer) + * Docs: fixed README typo (#391, @lurch) + * Docs: added notice about v3 api discussion (@thebigredgeek) + 2.5.1 / 2016-12-20 ================== diff --git a/component.json b/component.json index 3767637c..0d2e04e1 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "debug", "repo": "visionmedia/debug", "description": "small debugging utility", - "version": "2.5.1", + "version": "2.5.2", "keywords": [ "debug", "log", diff --git a/package.json b/package.json index 67fb9945..9f944229 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "2.5.1", + "version": "2.5.2", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From 62df220d205eddb382b98efb5a44b16076284fb7 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 27 Dec 2016 16:25:09 -0800 Subject: [PATCH 088/257] Deprecate DEBUG_FD (#405) * remove DEBUG_FD from readme * deprecate DEBUG_FD * remove arrow function ES6 habbits hit hard :D --- README.md | 19 ++----------------- src/node.js | 4 ++++ 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index ff244814..2c57ddfa 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,6 @@ Then, run the program to be debugged as usual. |-----------|-------------------------------------------------| | `DEBUG` | Enables/disabled specific debugging namespaces. | | `DEBUG_COLORS`| Whether or not to use colors in the debug output. | -| `DEBUG_FD`| File descriptor to output debug logs to. Defaults to stderr. | | `DEBUG_DEPTH` | Object inspection depth. | | `DEBUG_SHOW_HIDDEN` | Shows hidden properties on inspected objects. | @@ -110,8 +109,6 @@ Then, run the program to be debugged as usual. [`util.inspect()`](https://nodejs.org/api/util.html#util_util_inspect_object_options) for the complete list. - __Note:__ Certain IDEs (such as WebStorm) don't support colors on stderr. In these cases you must set `DEBUG_COLORS` to `1` and additionally change `DEBUG_FD` to `1`. - ## Formatters @@ -181,13 +178,10 @@ setInterval(function(){ ![](https://cloud.githubusercontent.com/assets/71256/3139768/b98c5fd8-e8ef-11e3-862a-f7253b6f47c6.png) -## Output streams - -### stderr vs stdout - By default `debug` will log to stderr, however this can be changed by setting the environment variable `DEBUG_FD` to `1` for stdout and `2` for stderr (the default value). +## Output streams -You can also set an alternative logging method per-namespace by overriding the `log` method on a per-namespace or globally: + By default `debug` will log to stderr, however this can be configured per-namespace by overriding the `log` method: Example _stdout.js_: @@ -211,15 +205,6 @@ error('now goes to stdout via console.info'); log('still goes to stdout, but via console.info now'); ``` -### Save debug output to a file - -You can save all debug statements to a file by piping them. - -Example: - -```bash -$ DEBUG_FD=3 node your-app.js 3> whatever.log -``` ## Authors diff --git a/src/node.js b/src/node.js index 15bf55af..ea6a8967 100644 --- a/src/node.js +++ b/src/node.js @@ -58,6 +58,10 @@ exports.inspectOpts = Object.keys(process.env).filter(function (key) { * $ DEBUG_FD=3 node script.js 3>debug.log */ +if ('DEBUG_FD' in process.env) { + util.deprecate(function(){}, '`DEBUG_FD` is deprecated. Override `debug.log` if you want to use a different log function (https://git.io/vMUyr)')() +} + var fd = parseInt(process.env.DEBUG_FD, 10) || 2; var stream = 1 === fd ? process.stdout : 2 === fd ? process.stderr : From 664613047c696b050520de0b3af012ee55bd9882 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Wed, 28 Dec 2016 21:27:52 -0800 Subject: [PATCH 089/257] remove explicit `window.debug` export (#404) Exporting to the "outer" scope of the module is more the responsibility of the module loader (i.e. browserify, webpack, etc.) and thus this is not necessary. `make test-browser` still passes after this patch. --- src/browser.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/browser.js b/src/browser.js index 006a8c11..2c10d4d6 100644 --- a/src/browser.js +++ b/src/browser.js @@ -180,8 +180,3 @@ function localstorage() { return window.localStorage; } catch (e) {} } - -/** Attach to Window*/ -if (typeof window !== 'undefined') { - window.debug = exports; -} From 589559502a1d4ea4a7258123a7f516cc88c5bebb Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Wed, 28 Dec 2016 23:46:46 -0600 Subject: [PATCH 090/257] better null pointer checks for browser useColors --- src/browser.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/browser.js b/src/browser.js index 2c10d4d6..38d6391e 100644 --- a/src/browser.js +++ b/src/browser.js @@ -40,20 +40,20 @@ function useColors() { // NB: In an Electron preload script, document will be defined but not fully // initialized. Since we know we're in Chrome, we'll just detect this case // explicitly - if (typeof window !== 'undefined' && typeof window.process !== 'undefined' && window.process.type === 'renderer') { + if (typeof window !== 'undefined' && window && typeof window.process !== 'undefined' && window.process.type === 'renderer') { return true; } // is webkit? http://stackoverflow.com/a/16459606/376773 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 - return (typeof document !== 'undefined' && 'WebkitAppearance' in document.documentElement.style) || + return (typeof document !== 'undefined' && document && 'WebkitAppearance' in document.documentElement.style) || // is firebug? http://stackoverflow.com/a/398120/376773 - (typeof window !== 'undefined' && window.console && (console.firebug || (console.exception && console.table))) || + (typeof window !== 'undefined' && window && window.console && (console.firebug || (console.exception && console.table))) || // is firefox >= v31? // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || + (typeof navigator !== 'undefined' && navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || // double check webkit in userAgent just in case we are in a worker - (navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); + (typeof navigator !== 'undefined' && navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); } /** From ac5ccae70358a2bccc71d288e5f9c656a7678748 Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Wed, 28 Dec 2016 23:49:38 -0600 Subject: [PATCH 091/257] release 2.6.0 --- CHANGELOG.md | 7 +++++++ component.json | 2 +- package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dbe6ada..5c7f1037 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,11 @@ +2.6.0 / 2016-12-28 +================== + + * Fix: added better null pointer checks for browser useColors (@thebigredgeek) + * Improvement: removed explicit `window.debug` export (#404, @tootallnate) + * Improvement: deprecated `DEBUG_FD` environment variable (#405, @tootallnate) + 2.5.2 / 2016-12-25 ================== diff --git a/component.json b/component.json index 0d2e04e1..128e3b89 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "debug", "repo": "visionmedia/debug", "description": "small debugging utility", - "version": "2.5.2", + "version": "2.6.0", "keywords": [ "debug", "log", diff --git a/package.json b/package.json index 9f944229..9415f7d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "2.5.2", + "version": "2.6.0", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From 1c163a48c16fdfcaff734d2233bec6fff3d6f0f0 Mon Sep 17 00:00:00 2001 From: Mykyta Usikov Date: Wed, 4 Jan 2017 21:58:28 +0200 Subject: [PATCH 092/257] added names and skips arrays erasing on enable call (#409) --- src/debug.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/debug.js b/src/debug.js index 4d3c7f27..25cb6890 100644 --- a/src/debug.js +++ b/src/debug.js @@ -138,6 +138,9 @@ function createDebug(namespace) { function enable(namespaces) { exports.save(namespaces); + exports.names = []; + exports.skips = []; + var split = (namespaces || '').split(/[\s,]+/); var len = split.length; From 78ae6c94122a5c23263b6ea6def0d7ead474fc66 Mon Sep 17 00:00:00 2001 From: vgoma Date: Mon, 16 Jan 2017 22:00:27 +0300 Subject: [PATCH 093/257] Fixed IE8 "Expected identifier" error --- CHANGELOG.md | 4 ++++ component.json | 2 +- package.json | 2 +- src/debug.js | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c7f1037..237843ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +2.6.1 / 2017-01-16 +================== + + * Fix: Module's `export default` syntax fix for IE8 `Expected identifier` error 2.6.0 / 2016-12-28 ================== diff --git a/component.json b/component.json index 128e3b89..4861027d 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "debug", "repo": "visionmedia/debug", "description": "small debugging utility", - "version": "2.6.0", + "version": "2.6.1", "keywords": [ "debug", "log", diff --git a/package.json b/package.json index 9415f7d1..0bd80e28 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "2.6.0", + "version": "2.6.1", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" diff --git a/src/debug.js b/src/debug.js index 25cb6890..d5d6d167 100644 --- a/src/debug.js +++ b/src/debug.js @@ -6,7 +6,7 @@ * Expose `debug()` as the module. */ -exports = module.exports = createDebug.debug = createDebug.default = createDebug; +exports = module.exports = createDebug.debug = createDebug['default'] = createDebug; exports.coerce = coerce; exports.disable = disable; exports.enable = enable; From 37e14d6aad739c565cf225da7a204d2a1d1907ea Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Tue, 24 Jan 2017 05:12:32 +0330 Subject: [PATCH 094/257] Whitelist DEBUG_FD for values 1 and 2 only Fixes #410 (#415) * Hide in DEBUG_FD deprecation warning in Webstorm Fixes #410 + Intellij idea * Hide in DEBUG_FD deprecation warning in Webstorm Fixes #410 * whitelist DEBUG_FD for values 1 and 2 only * Use appreciate depreciation message --- src/node.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/node.js b/src/node.js index ea6a8967..4fa564b0 100644 --- a/src/node.js +++ b/src/node.js @@ -58,11 +58,12 @@ exports.inspectOpts = Object.keys(process.env).filter(function (key) { * $ DEBUG_FD=3 node script.js 3>debug.log */ -if ('DEBUG_FD' in process.env) { - util.deprecate(function(){}, '`DEBUG_FD` is deprecated. Override `debug.log` if you want to use a different log function (https://git.io/vMUyr)')() +var fd = parseInt(process.env.DEBUG_FD, 10) || 2; + +if (1 !== fd && 2 !== fd) { + util.deprecate(function(){}, 'except for stderr(2) and stdout(1), any other usage of DEBUG_FD is deprecated. Override debug.log if you want to use a different log function (https://git.io/debug_fd)')() } -var fd = parseInt(process.env.DEBUG_FD, 10) || 2; var stream = 1 === fd ? process.stdout : 2 === fd ? process.stderr : createWritableStdioStream(fd); From 941653e3334e9e3e2cca87cad9bbf6c5cb245215 Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Fri, 10 Feb 2017 11:00:05 -0800 Subject: [PATCH 095/257] release 2.6.1 --- CHANGELOG.md | 5 ++++- Makefile | 22 ++++++++++------------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 237843ad..99abf97f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,10 @@ -2.6.1 / 2017-01-16 +2.6.1 / 2017-02-10 ================== * Fix: Module's `export default` syntax fix for IE8 `Expected identifier` error + * Fix: Whitelist DEBUG_FD for values 1 and 2 only (#415, @pi0) + * Fix: IE8 "Expected identifier" error (#414, @vgoma) + * Fix: Namespaces would not disable once enabled (#409, @musikov) 2.6.0 / 2016-12-28 ================== diff --git a/Makefile b/Makefile index 1a2c195a..584da8bf 100644 --- a/Makefile +++ b/Makefile @@ -17,36 +17,34 @@ BROWSERIFY ?= $(NODE) $(BIN)/browserify .FORCE: -all: dist/debug.js - install: node_modules - + node_modules: package.json @NODE_ENV= $(PKG) install @touch node_modules - + lint: .FORCE eslint browser.js debug.js index.js node.js - + test-node: .FORCE istanbul cover node_modules/mocha/bin/_mocha -- test/**.js - + test-browser: .FORCE mkdir -p dist - + @$(BROWSERIFY) \ --standalone debug \ . > dist/debug.js - + karma start --single-run rimraf dist - + test: .FORCE concurrently \ "make test-node" \ "make test-browser" - -coveralls: + +coveralls: cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js - + .PHONY: all install clean distclean From 9f33c9a8a84636ae1c46489e10b2e919b9551f36 Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Fri, 10 Feb 2017 11:24:08 -0800 Subject: [PATCH 096/257] added slackin --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2c57ddfa..0b7b5fd5 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # debug -[![Build Status](https://travis-ci.org/visionmedia/debug.svg?branch=master)](https://travis-ci.org/visionmedia/debug) [![Coverage Status](https://coveralls.io/repos/github/visionmedia/debug/badge.svg?branch=master)](https://coveralls.io/github/visionmedia/debug?branch=master) +[![Build Status](https://travis-ci.org/visionmedia/debug.svg?branch=master)](https://travis-ci.org/visionmedia/debug) [![Coverage Status](https://coveralls.io/repos/github/visionmedia/debug/badge.svg?branch=master)](https://coveralls.io/github/visionmedia/debug?branch=master) [![Slack](https://rauchg-slackin-yybwjekgeo.now.sh/badge.svg)](https://rauchg-slackin-yybwjekgeo.now.sh/) + A tiny node.js debugging utility modelled after node core's debugging technique. @@ -13,7 +14,7 @@ $ npm install debug ## Usage -`debug` exposes a function; simply pass this function the name of your module, and it will return a decorated version of `console.error` for you to pass debug statements to. This will allow you to toggle the debug output for different parts of your module as well as the module as a whole. +`debug` exposes a function; simply pass this function the name of your module, and it will return a decorated version of `console.error` for you to pass debug statements to. This will allow you to toggle the debug output for different parts of your module as well as the module as a whole. Example _app.js_: From 580a7a18b3c7ee260ed95730676d5064fd1b50a4 Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Fri, 10 Feb 2017 11:30:25 -0800 Subject: [PATCH 097/257] changed slackin url --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0b7b5fd5..8bb4d424 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # debug -[![Build Status](https://travis-ci.org/visionmedia/debug.svg?branch=master)](https://travis-ci.org/visionmedia/debug) [![Coverage Status](https://coveralls.io/repos/github/visionmedia/debug/badge.svg?branch=master)](https://coveralls.io/github/visionmedia/debug?branch=master) [![Slack](https://rauchg-slackin-yybwjekgeo.now.sh/badge.svg)](https://rauchg-slackin-yybwjekgeo.now.sh/) +[![Build Status](https://travis-ci.org/visionmedia/debug.svg?branch=master)](https://travis-ci.org/visionmedia/debug) [![Coverage Status](https://coveralls.io/repos/github/visionmedia/debug/badge.svg?branch=master)](https://coveralls.io/github/visionmedia/debug?branch=master) [![Slack](https://visionmedia-community-slackin.now.sh/badge.svg)](https://visionmedia-community-slackin.now.sh/) A tiny node.js debugging utility modelled after node core's debugging technique. From f46d67144d78a081c45a0d02cfec9da48b44e105 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Fri, 10 Feb 2017 12:28:39 -0800 Subject: [PATCH 098/257] add Slackin invite badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8bb4d424..6ee96ff2 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # debug -[![Build Status](https://travis-ci.org/visionmedia/debug.svg?branch=master)](https://travis-ci.org/visionmedia/debug) [![Coverage Status](https://coveralls.io/repos/github/visionmedia/debug/badge.svg?branch=master)](https://coveralls.io/github/visionmedia/debug?branch=master) [![Slack](https://visionmedia-community-slackin.now.sh/badge.svg)](https://visionmedia-community-slackin.now.sh/) +[![Build Status](https://travis-ci.org/visionmedia/debug.svg?branch=master)](https://travis-ci.org/visionmedia/debug) [![Coverage Status](https://coveralls.io/repos/github/visionmedia/debug/badge.svg?branch=master)](https://coveralls.io/github/visionmedia/debug?branch=master) [![Slack](https://visionmedia-community-slackin.now.sh/badge.svg)](https://visionmedia-community-slackin.now.sh/) [![Slackin](https://visionmedia-community-slackin.now.sh/badge.svg)](https://visionmedia-community-slackin.now.sh) A tiny node.js debugging utility modelled after node core's debugging technique. From 918d686521d3f8b4a0f6e0448351cdc06fdb84f6 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Fri, 10 Feb 2017 12:29:08 -0800 Subject: [PATCH 099/257] Revert "add Slackin invite badge" This reverts commit f46d67144d78a081c45a0d02cfec9da48b44e105. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6ee96ff2..8bb4d424 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # debug -[![Build Status](https://travis-ci.org/visionmedia/debug.svg?branch=master)](https://travis-ci.org/visionmedia/debug) [![Coverage Status](https://coveralls.io/repos/github/visionmedia/debug/badge.svg?branch=master)](https://coveralls.io/github/visionmedia/debug?branch=master) [![Slack](https://visionmedia-community-slackin.now.sh/badge.svg)](https://visionmedia-community-slackin.now.sh/) [![Slackin](https://visionmedia-community-slackin.now.sh/badge.svg)](https://visionmedia-community-slackin.now.sh) +[![Build Status](https://travis-ci.org/visionmedia/debug.svg?branch=master)](https://travis-ci.org/visionmedia/debug) [![Coverage Status](https://coveralls.io/repos/github/visionmedia/debug/badge.svg?branch=master)](https://coveralls.io/github/visionmedia/debug?branch=master) [![Slack](https://visionmedia-community-slackin.now.sh/badge.svg)](https://visionmedia-community-slackin.now.sh/) A tiny node.js debugging utility modelled after node core's debugging technique. From 065cbfb1bf93cb4ea5f6bdd956aaba8e7e9f3822 Mon Sep 17 00:00:00 2001 From: Pia Mancini Date: Fri, 17 Feb 2017 10:38:15 -0800 Subject: [PATCH 100/257] Add backers and sponsors from Open Collective (#422) Now your open collective backers and sponsors can to appear directly on your README. see how it'll look [here](https://github.com/apex/apex#backers) [More info](https://github.com/opencollective/opencollective/wiki/Github-banner) Also add badges on top. --- README.md | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8bb4d424..4aeab13f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # debug -[![Build Status](https://travis-ci.org/visionmedia/debug.svg?branch=master)](https://travis-ci.org/visionmedia/debug) [![Coverage Status](https://coveralls.io/repos/github/visionmedia/debug/badge.svg?branch=master)](https://coveralls.io/github/visionmedia/debug?branch=master) [![Slack](https://visionmedia-community-slackin.now.sh/badge.svg)](https://visionmedia-community-slackin.now.sh/) +[![Build Status](https://travis-ci.org/visionmedia/debug.svg?branch=master)](https://travis-ci.org/visionmedia/debug) [![Coverage Status](https://coveralls.io/repos/github/visionmedia/debug/badge.svg?branch=master)](https://coveralls.io/github/visionmedia/debug?branch=master) [![Slack](https://visionmedia-community-slackin.now.sh/badge.svg)](https://visionmedia-community-slackin.now.sh/) [![OpenCollective](https://opencollective.com/debug/backers/badge.svg)](#backers) +[![OpenCollective](https://opencollective.com/debug/sponsors/badge.svg)](#sponsors) + A tiny node.js debugging utility modelled after node core's debugging technique. @@ -212,6 +214,77 @@ log('still goes to stdout, but via console.info now'); - TJ Holowaychuk - Nathan Rajlich - Andrew Rhyne + +## Backers + +Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/debug#backer)] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +## Sponsors + +Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/debug#sponsor)] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ## License From 23bc780b840da7f6eaffed6f90098fde27c5f4ca Mon Sep 17 00:00:00 2001 From: slavaGanzin Date: Mon, 6 Feb 2017 15:23:59 +0200 Subject: [PATCH 101/257] fix DEBUG_MAX_ARRAY_LENGTH --- src/node.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node.js b/src/node.js index 4fa564b0..3c7407b6 100644 --- a/src/node.js +++ b/src/node.js @@ -38,7 +38,7 @@ exports.inspectOpts = Object.keys(process.env).filter(function (key) { var prop = key .substring(6) .toLowerCase() - .replace(/_([a-z])/, function (_, k) { return k.toUpperCase() }); + .replace(/_([a-z])/g, function (_, k) { return k.toUpperCase() }); // coerce string value into JS value var val = process.env[key]; From 017a9d68568fd24113bd73a477e0221aa969b732 Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Fri, 10 Mar 2017 11:44:00 -0800 Subject: [PATCH 102/257] release 2.6.2 --- CHANGELOG.md | 7 +++++++ component.json | 2 +- package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99abf97f..90e6cf3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ + +n.n.n / 2017-03-10 +================== + + * Fix: DEBUG_MAX_ARRAY_LENGTH (#420, @slavaGanzin) + * Docs: Add backers and sponsors from Open Collective (#422, @piamancini) + * Docs: Add Slackin invite badge (@tootallnate) 2.6.1 / 2017-02-10 ================== diff --git a/component.json b/component.json index 4861027d..e31b5135 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "debug", "repo": "visionmedia/debug", "description": "small debugging utility", - "version": "2.6.1", + "version": "2.6.2", "keywords": [ "debug", "log", diff --git a/package.json b/package.json index 0bd80e28..cf045e32 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "2.6.1", + "version": "2.6.2", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From ce4d93e71d367f79ebc0f5aa73f9695a86831cdc Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Fri, 10 Mar 2017 11:45:08 -0800 Subject: [PATCH 103/257] changelog fix --- CHANGELOG.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90e6cf3a..9b0fb0ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,11 @@ -n.n.n / 2017-03-10 +2.6.2 / 2017-03-10 ================== * Fix: DEBUG_MAX_ARRAY_LENGTH (#420, @slavaGanzin) * Docs: Add backers and sponsors from Open Collective (#422, @piamancini) * Docs: Add Slackin invite badge (@tootallnate) + 2.6.1 / 2017-02-10 ================== @@ -24,7 +25,7 @@ n.n.n / 2017-03-10 ================== * Fix: reference error on window within webworkers (#393, @KlausTrainer) - * Docs: fixed README typo (#391, @lurch) + * Docs: fixed README typo (#391, @lurch) * Docs: added notice about v3 api discussion (@thebigredgeek) 2.5.1 / 2016-12-20 @@ -39,7 +40,7 @@ n.n.n / 2017-03-10 * Fix: webworker compatibility (@thebigredgeek) * Fix: output formatting issue (#388, @kribblo) * Fix: babel-loader compatibility (#383, @escwald) - * Misc: removed built asset from repo and publications (@thebigredgeek) + * Misc: removed built asset from repo and publications (@thebigredgeek) * Misc: moved source files to /src (#378, @yamikuronue) * Test: added karma integration and replaced babel with browserify for browser tests (#378, @yamikuronue) * Test: coveralls integration (#378, @yamikuronue) From 0fb8ea4730ae06e6018d8723bee494b0dada30ad Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Mon, 13 Mar 2017 20:43:57 -0700 Subject: [PATCH 104/257] LocalStorage returns undefined for any key not present (#431) --- src/browser.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/browser.js b/src/browser.js index 38d6391e..e21c1e0b 100644 --- a/src/browser.js +++ b/src/browser.js @@ -148,14 +148,17 @@ function save(namespaces) { */ function load() { + var r; try { - return exports.storage.debug; + r = exports.storage.debug; } catch(e) {} // If debug isn't set in LS, and we're in Electron, try to load $DEBUG - if (typeof process !== 'undefined' && 'env' in process) { - return process.env.DEBUG; + if (!r && typeof process !== 'undefined' && 'env' in process) { + r = process.env.DEBUG; } + + return r; } /** From 9dc30f8378cc12192635cc6a31f0d96bb39be8bb Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Mon, 13 Mar 2017 20:49:55 -0700 Subject: [PATCH 105/257] release 2.6.3 --- CHANGELOG.md | 6 ++++++ component.json | 2 +- package.json | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b0fb0ac..07ba5396 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,10 @@ +2.6.3 / 2017-03-13 +================== + + * Fix: Fix for electron reference to `process.env.DEBUG` (#431, @paulcbetts) + * Docs: Changelog fix (@thebigredgeeK) + 2.6.2 / 2017-03-10 ================== diff --git a/component.json b/component.json index e31b5135..e150dc47 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "debug", "repo": "visionmedia/debug", "description": "small debugging utility", - "version": "2.6.2", + "version": "2.6.3", "keywords": [ "debug", "log", diff --git a/package.json b/package.json index cf045e32..377ea962 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "2.6.2", + "version": "2.6.3", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From 27d93a37f7f6cd76e273826ee7d8252be2d5f457 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Thu, 16 Mar 2017 11:44:29 -0700 Subject: [PATCH 106/257] update "debug" to v0.7.3 Closes #428. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 377ea962..e38b3da4 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ ], "license": "MIT", "dependencies": { - "ms": "0.7.2" + "ms": "0.7.3" }, "devDependencies": { "browserify": "9.0.3", From 9742c5f383a6f8046241920156236ade8ec30d53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Vieira?= Date: Tue, 4 Apr 2017 17:54:50 +0100 Subject: [PATCH 107/257] chore(): ignore bower.json in npm installations. (#437) --- .npmignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.npmignore b/.npmignore index db2fbb9d..5f60eecc 100644 --- a/.npmignore +++ b/.npmignore @@ -6,3 +6,4 @@ example dist yarn.lock coverage +bower.json From f5ae33211a3026e8d45a2f7c880caa6da2e35629 Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Fri, 7 Apr 2017 09:49:13 -0700 Subject: [PATCH 108/257] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07ba5396..35e50e1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ================== * Fix: Fix for electron reference to `process.env.DEBUG` (#431, @paulcbetts) - * Docs: Changelog fix (@thebigredgeeK) + * Docs: Changelog fix (@thebigredgeek) 2.6.2 / 2017-03-10 ================== From 2f3ebf49c16dc0807a1c125a089129f98583aff5 Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Fri, 7 Apr 2017 09:49:45 -0700 Subject: [PATCH 109/257] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35e50e1b..259e0c20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ 2.6.3 / 2017-03-13 ================== - * Fix: Fix for electron reference to `process.env.DEBUG` (#431, @paulcbetts) + * Fix: Electron reference to `process.env.DEBUG` (#431, @paulcbetts) * Docs: Changelog fix (@thebigredgeek) 2.6.2 / 2017-03-10 From 1f01b70f88202c22deaa3df70e343fc409504147 Mon Sep 17 00:00:00 2001 From: Lucian Buzzo Date: Thu, 20 Apr 2017 19:04:28 +0100 Subject: [PATCH 110/257] Fix bug that would occure if process.env.DEBUG is a non-string value. (#444) Connects to #443 --- src/debug.js | 2 +- test/debug_spec.js | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/debug.js b/src/debug.js index d5d6d167..6a5e3fc9 100644 --- a/src/debug.js +++ b/src/debug.js @@ -141,7 +141,7 @@ function enable(namespaces) { exports.names = []; exports.skips = []; - var split = (namespaces || '').split(/[\s,]+/); + var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); var len = split.length; for (var i = 0; i < len; i++) { diff --git a/test/debug_spec.js b/test/debug_spec.js index 4ab4d88d..142fbe79 100644 --- a/test/debug_spec.js +++ b/test/debug_spec.js @@ -6,11 +6,11 @@ var chai , debug , sinon , sinonChai; - + if (typeof module !== 'undefined') { chai = require('chai'); expect = chai.expect; - + debug = require('../src/index'); sinon = require('sinon'); sinonChai = require("sinon-chai"); @@ -20,20 +20,24 @@ if (typeof module !== 'undefined') { describe('debug', function () { var log = debug('test'); - + log.log = sinon.stub(); - + it('passes a basic sanity check', function () { expect(log('hello world')).to.not.throw; }); + it('allows namespaces to be a non-string value', function () { + expect(debug.enable(true)).to.not.throw; + }); + context('with log function', function () { - + beforeEach(function () { debug.enable('test'); log = debug('test'); }); - + it('uses it', function () { log.log = sinon.stub(); log('using custom log function'); @@ -41,7 +45,7 @@ describe('debug', function () { expect(log.log).to.have.been.calledOnce; }); }); - + describe('custom functions', function () { var log; @@ -59,4 +63,5 @@ describe('debug', function () { }); }); }); + }); From f311b10b7b79efb33f4e23898ae6bbb152e94b16 Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Thu, 20 Apr 2017 11:07:44 -0700 Subject: [PATCH 111/257] release 2.6.4 --- CHANGELOG.md | 7 +++++++ component.json | 2 +- package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 259e0c20..37a62926 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,11 @@ +2.6.4 / 2017-04-20 +================== + + * Fix: bug that would occure if process.env.DEBUG is a non-string value. (#444, @LucianBuzzo) + * Chore: ignore bower.json in npm installations. (#437, @joaovieira) + * Misc: update "ms" to v0.7.3 (@tootallnate) + 2.6.3 / 2017-03-13 ================== diff --git a/component.json b/component.json index e150dc47..dd403078 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "debug", "repo": "visionmedia/debug", "description": "small debugging utility", - "version": "2.6.3", + "version": "2.6.4", "keywords": [ "debug", "log", diff --git a/package.json b/package.json index e38b3da4..3ff4e5e2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "2.6.3", + "version": "2.6.4", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From cae07b70c968bdcadffff452dee8613522857888 Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Thu, 27 Apr 2017 08:59:02 -0700 Subject: [PATCH 112/257] cleanup browser tests and fix null reference check on window.documentElement.style.WebkitAppearance (#447) --- src/browser.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/browser.js b/src/browser.js index e21c1e0b..7978ce72 100644 --- a/src/browser.js +++ b/src/browser.js @@ -40,20 +40,20 @@ function useColors() { // NB: In an Electron preload script, document will be defined but not fully // initialized. Since we know we're in Chrome, we'll just detect this case // explicitly - if (typeof window !== 'undefined' && window && typeof window.process !== 'undefined' && window.process.type === 'renderer') { + if (window && window.process && window.process.type === 'renderer') { return true; } // is webkit? http://stackoverflow.com/a/16459606/376773 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 - return (typeof document !== 'undefined' && document && 'WebkitAppearance' in document.documentElement.style) || + return (document && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || // is firebug? http://stackoverflow.com/a/398120/376773 - (typeof window !== 'undefined' && window && window.console && (console.firebug || (console.exception && console.table))) || + (window && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || // is firefox >= v31? // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (typeof navigator !== 'undefined' && navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || + (navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || // double check webkit in userAgent just in case we are in a worker - (typeof navigator !== 'undefined' && navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); + (navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); } /** From 14df14c3585bbeb10262f96f5ce61549669709d8 Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Thu, 27 Apr 2017 09:03:42 -0700 Subject: [PATCH 113/257] release 2.6.5 --- .gitignore | 1 + CHANGELOG.md | 8 ++++++++ package.json | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ccaa248a..f459ae9f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,6 @@ node_modules *.sock build yarn.lock +npm-debug.log dist coverage diff --git a/CHANGELOG.md b/CHANGELOG.md index 37a62926..3eaa74b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,12 @@ +2.6.5 / 2017-04-27 +================== + + * Fix: null reference check on window.documentElement.style.WebkitAppearance (#447, @thebigredgeek) + * Misc: clean up browser reference checks (#447, @thebigredgeek) + * Misc: add npm-debug.log to .gitignore (@thebigredgeek) + + 2.6.4 / 2017-04-20 ================== diff --git a/package.json b/package.json index 3ff4e5e2..288e632a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "2.6.4", + "version": "2.6.5", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From c211947ea37e1b08ee78653d78defbda7438783d Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Thu, 27 Apr 2017 09:05:43 -0700 Subject: [PATCH 114/257] update version for component --- component.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/component.json b/component.json index dd403078..2ca5172f 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "debug", "repo": "visionmedia/debug", "description": "small debugging utility", - "version": "2.6.4", + "version": "2.6.5", "keywords": [ "debug", "log", From 1351d2f91f20da46316be67265216761548db53c Mon Sep 17 00:00:00 2001 From: Douglas Wilson Date: Wed, 10 May 2017 18:51:27 -0400 Subject: [PATCH 115/257] Inline extend function in node implementation (#452) --- src/node.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/node.js b/src/node.js index 3c7407b6..af612976 100644 --- a/src/node.js +++ b/src/node.js @@ -231,7 +231,12 @@ function createWritableStdioStream (fd) { */ function init (debug) { - debug.inspectOpts = util._extend({}, exports.inspectOpts); + debug.inspectOpts = {}; + + var keys = Object.keys(exports.inspectOpts); + for (var i = 0; i < keys.length; i++) { + debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]]; + } } /** From b68dbf8cd4a8111dd4ccef56b8e2e3d463c5aadc Mon Sep 17 00:00:00 2001 From: Mohammad Asad Siddiqui Date: Sat, 13 May 2017 05:24:14 +0530 Subject: [PATCH 116/257] Fix typo (#455) Enables/disabled -> Enables/disabled --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4aeab13f..f67be6b3 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ Then, run the program to be debugged as usual. | Name | Purpose | |-----------|-------------------------------------------------| -| `DEBUG` | Enables/disabled specific debugging namespaces. | +| `DEBUG` | Enables/disables specific debugging namespaces. | | `DEBUG_COLORS`| Whether or not to use colors in the debug output. | | `DEBUG_DEPTH` | Object inspection depth. | | `DEBUG_SHOW_HIDDEN` | Shows hidden properties on inspected objects. | From 4a6c85c6018a4a4cff4b04f40173ca9d2c72c1da Mon Sep 17 00:00:00 2001 From: Douglas Wilson Date: Fri, 12 May 2017 19:54:37 -0400 Subject: [PATCH 117/257] update "debug" to v1.0.0 (#454) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 288e632a..9b5615a6 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ ], "license": "MIT", "dependencies": { - "ms": "0.7.3" + "ms": "1.0.0" }, "devDependencies": { "browserify": "9.0.3", From 15850cb89debc3a2cd0b61ef7f9e298f257506cc Mon Sep 17 00:00:00 2001 From: Jamie Date: Tue, 16 May 2017 16:06:36 +0100 Subject: [PATCH 118/257] Fix Regular Expression Denial of Service (ReDoS) https://snyk.io/vuln/npm:ms:20170412 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9b5615a6..609bf4d6 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ ], "license": "MIT", "dependencies": { - "ms": "1.0.0" + "ms": "2.0.0" }, "devDependencies": { "browserify": "9.0.3", From 6bb07f7e1bafa33631d8f36a779f17eb8abf5fea Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Tue, 16 May 2017 21:33:08 -0700 Subject: [PATCH 119/257] release 2.6.7 --- CHANGELOG.md | 7 +++++++ component.json | 2 +- package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3eaa74b5..189dbc82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,11 @@ +2.6.7 / 2017-05-16 +================== + + * Fix: Update ms to 2.0.0 to fix regular expression denial of service vulnerability (#458, @hubdotcom) + * Fix: Inline extend function in node implementation (#452, @dougwilson) + * Docs: Fix typo (#455, @msasad) + 2.6.5 / 2017-04-27 ================== diff --git a/component.json b/component.json index 2ca5172f..d7118d2f 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "debug", "repo": "visionmedia/debug", "description": "small debugging utility", - "version": "2.6.5", + "version": "2.6.7", "keywords": [ "debug", "log", diff --git a/package.json b/package.json index 609bf4d6..02ae1486 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "2.6.5", + "version": "2.6.7", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From 2482e08e4ef36416154ee27e9a2d60e568a01d48 Mon Sep 17 00:00:00 2001 From: Marc MacLeod Date: Thu, 18 May 2017 12:38:54 -0400 Subject: [PATCH 120/257] Check for undefined on browser globals (#462) * Check for undefined on browser globals. Not all environments include these globals. For example, web workers do not have global window objects. * remove redundant global checks --- src/browser.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/browser.js b/src/browser.js index 7978ce72..71069249 100644 --- a/src/browser.js +++ b/src/browser.js @@ -40,20 +40,20 @@ function useColors() { // NB: In an Electron preload script, document will be defined but not fully // initialized. Since we know we're in Chrome, we'll just detect this case // explicitly - if (window && window.process && window.process.type === 'renderer') { + if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') { return true; } // is webkit? http://stackoverflow.com/a/16459606/376773 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 - return (document && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || + return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || // is firebug? http://stackoverflow.com/a/398120/376773 - (window && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || + (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || // is firefox >= v31? // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || // double check webkit in userAgent just in case we are in a worker - (navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); } /** From 52e1f21284322f167839e5d3a60f635c8b2dc842 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Thu, 18 May 2017 13:06:48 -0700 Subject: [PATCH 121/257] Release 2.6.8 --- CHANGELOG.md | 5 +++++ component.json | 2 +- package.json | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 189dbc82..a1a270cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ +2.6.8 / 2017-05-18 +================== + + * Fix: Check for undefined on browser globals (#462, @marbemac) + 2.6.7 / 2017-05-16 ================== diff --git a/component.json b/component.json index d7118d2f..94cd36d8 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "debug", "repo": "visionmedia/debug", "description": "small debugging utility", - "version": "2.6.7", + "version": "2.6.8", "keywords": [ "debug", "log", diff --git a/package.json b/package.json index 02ae1486..df863517 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "2.6.7", + "version": "2.6.8", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From a45d4a0239f071634804dd7901dd33b0d0d407c9 Mon Sep 17 00:00:00 2001 From: Tim Ruffles Date: Thu, 15 Jun 2017 22:39:48 +0100 Subject: [PATCH 122/257] document .enabled flag (#465) Was added in #15, should be documented (e.g #423) --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index f67be6b3..15f2a17e 100644 --- a/README.md +++ b/README.md @@ -208,6 +208,18 @@ error('now goes to stdout via console.info'); log('still goes to stdout, but via console.info now'); ``` +## Checking whether a debug target is enabled + +Afer you've created a debug instance, you can check whether it is enabled by its `.enabled` property: + +```javascript +const debug = require('debug')('http'); + +if(debug.enabled) { + // ... +} +``` + ## Authors From da51af8314436ab532c151583f7fd52b2ebf2a3e Mon Sep 17 00:00:00 2001 From: Eirik Birkeland Date: Mon, 17 Jul 2017 18:45:45 +0200 Subject: [PATCH 123/257] Simplify and improve The browser version assumes that chrome.storage.local uses an API which is compatible with localStorage; which is not the case. Even though I am using chrome.storage.local for my Chrome extension, I would much prefer to keep debug's variable in localStorage, as I consider chrome.storage.local the 'private space' of my extension. This change obviates the need to support multiple storage types. But if storage type is important, how about supporting a custom storage facility, including chrome.storage.sync? I.e. the user would provide an object that follows the conventions. Just a thought - I certainly don't see the need at this point though. --- src/browser.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/browser.js b/src/browser.js index 71069249..3db740c2 100644 --- a/src/browser.js +++ b/src/browser.js @@ -10,10 +10,7 @@ exports.formatArgs = formatArgs; exports.save = save; exports.load = load; exports.useColors = useColors; -exports.storage = 'undefined' != typeof chrome - && 'undefined' != typeof chrome.storage - ? chrome.storage.local - : localstorage(); +exports.storage = localstorage(); /** * Colors. From 659ac0252cd3bba115b02a4545b752ac9dcc3064 Mon Sep 17 00:00:00 2001 From: "Mattias Kindborg @FantasticFiasco" Date: Fri, 4 Aug 2017 20:51:36 +0200 Subject: [PATCH 124/257] docs(readme): fix typo (#473) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 15f2a17e..441cbecd 100644 --- a/README.md +++ b/README.md @@ -210,7 +210,7 @@ log('still goes to stdout, but via console.info now'); ## Checking whether a debug target is enabled -Afer you've created a debug instance, you can check whether it is enabled by its `.enabled` property: +After you've created a debug instance, you can check whether it is enabled by its `.enabled` property: ```javascript const debug = require('debug')('http'); From ff432e76e98f4224917af75a2d2dd1057edff3ac Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 27 Dec 2016 16:25:36 -0800 Subject: [PATCH 125/257] Remove DEBUG_FD (#406) * remove DEBUG_FD Now simply uses `process.stderr`. Breaking API change, for the v3 branch. Previously used internal and undocumented Node.js APIs to support this underly used API. Fixes #280 Closes #386 * remove DEBUG_FD from readme --- src/node.js | 91 ++--------------------------------------------------- 1 file changed, 3 insertions(+), 88 deletions(-) diff --git a/src/node.js b/src/node.js index af612976..f4119f47 100644 --- a/src/node.js +++ b/src/node.js @@ -51,23 +51,6 @@ exports.inspectOpts = Object.keys(process.env).filter(function (key) { return obj; }, {}); -/** - * The file descriptor to write the `debug()` calls to. - * Set the `DEBUG_FD` env variable to override with another value. i.e.: - * - * $ DEBUG_FD=3 node script.js 3>debug.log - */ - -var fd = parseInt(process.env.DEBUG_FD, 10) || 2; - -if (1 !== fd && 2 !== fd) { - util.deprecate(function(){}, 'except for stderr(2) and stdout(1), any other usage of DEBUG_FD is deprecated. Override debug.log if you want to use a different log function (https://git.io/debug_fd)')() -} - -var stream = 1 === fd ? process.stdout : - 2 === fd ? process.stderr : - createWritableStdioStream(fd); - /** * Is stdout a TTY? Colored output is enabled when `true`. */ @@ -75,7 +58,7 @@ var stream = 1 === fd ? process.stdout : function useColors() { return 'colors' in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) - : tty.isatty(fd); + : tty.isatty(process.stderr.fd); } /** @@ -120,11 +103,11 @@ function formatArgs(args) { } /** - * Invokes `util.format()` with the specified arguments and writes to `stream`. + * Invokes `util.format()` with the specified arguments and writes to stderr. */ function log() { - return stream.write(util.format.apply(util, arguments) + '\n'); + return process.stderr.write(util.format.apply(util, arguments) + '\n'); } /** @@ -155,74 +138,6 @@ function load() { return process.env.DEBUG; } -/** - * Copied from `node/src/node.js`. - * - * XXX: It's lame that node doesn't expose this API out-of-the-box. It also - * relies on the undocumented `tty_wrap.guessHandleType()` which is also lame. - */ - -function createWritableStdioStream (fd) { - var stream; - var tty_wrap = process.binding('tty_wrap'); - - // Note stream._type is used for test-module-load-list.js - - switch (tty_wrap.guessHandleType(fd)) { - case 'TTY': - stream = new tty.WriteStream(fd); - stream._type = 'tty'; - - // Hack to have stream not keep the event loop alive. - // See https://github.com/joyent/node/issues/1726 - if (stream._handle && stream._handle.unref) { - stream._handle.unref(); - } - break; - - case 'FILE': - var fs = require('fs'); - stream = new fs.SyncWriteStream(fd, { autoClose: false }); - stream._type = 'fs'; - break; - - case 'PIPE': - case 'TCP': - var net = require('net'); - stream = new net.Socket({ - fd: fd, - readable: false, - writable: true - }); - - // FIXME Should probably have an option in net.Socket to create a - // stream from an existing fd which is writable only. But for now - // we'll just add this hack and set the `readable` member to false. - // Test: ./node test/fixtures/echo.js < /etc/passwd - stream.readable = false; - stream.read = null; - stream._type = 'pipe'; - - // FIXME Hack to have stream not keep the event loop alive. - // See https://github.com/joyent/node/issues/1726 - if (stream._handle && stream._handle.unref) { - stream._handle.unref(); - } - break; - - default: - // Probably an error on in uv_guess_handle() - throw new Error('Implement me. Unknown stream file type!'); - } - - // For supporting legacy API we put the FD here. - stream.fd = fd; - - stream._isStdio = true; - - return stream; -} - /** * Init logic for `debug` instances. * From 9d7c997992416bc9b358aaa5aa9e9396bab54baa Mon Sep 17 00:00:00 2001 From: George Joseph Date: Wed, 4 Jan 2017 12:59:29 -0700 Subject: [PATCH 126/257] Make millisecond timer namespace specific and allow 'always enabled' output (#408) * Make millisecond timer namespace specific When debugging node apps, I find it much more useful for the millisecond timer to be relative to last message from the same namespace instead of any message. This is especially true when I'm debugging across multiple libraries or multiple levels in the same module and I'm interested in seeing all the messages but also need to compare times from specific levels. * Enable 'always enabled' output Having to deal with 2 different logging mechanisms, one for debugging and one for normal output, can be a nuisance. It would be much easier to always use the same facility and semantics for both. This patch allows an 'always enabled' namespace to be specified by appending a single '*' to the namespace name. var alwaysOn = require('debug')('normal:messages*'); alwaysOn('This will always display regardless of DEBUG'); --- README.md | 2 +- src/debug.js | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 441cbecd..3748db94 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ Then, run the program to be debugged as usual. ## Conventions - If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". + If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". If you append a "*" to the end of your name, it will always be enabled regardless of the setting of the DEBUG environment variable. You can then use it for normal output as well as debug output. ## Wildcards diff --git a/src/debug.js b/src/debug.js index 6a5e3fc9..ee31a398 100644 --- a/src/debug.js +++ b/src/debug.js @@ -28,12 +28,6 @@ exports.skips = []; exports.formatters = {}; -/** - * Previous log timestamp. - */ - -var prevTime; - /** * Select a color. * @param {String} namespace @@ -62,6 +56,8 @@ function selectColor(namespace) { function createDebug(namespace) { + var prevTime; + function debug() { // disabled? if (!debug.enabled) return; @@ -174,6 +170,9 @@ function disable() { */ function enabled(name) { + if (name[name.length - 1] === '*') { + return true; + } var i, len; for (i = 0, len = exports.skips.length; i < len; i++) { if (exports.skips[i].test(name)) { From bf88540737e3908eeac253ffd2bbde0b46d5b56d Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Wed, 12 Apr 2017 13:25:31 -0700 Subject: [PATCH 127/257] `enabled()` updates existing debug instances, add `destroy()` function (#440) * dynamically updatable instances * add a `destroy()` function to debug instances So that "dynamically created instances" can clean up after themselves --- src/debug.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/debug.js b/src/debug.js index ee31a398..ed2956d6 100644 --- a/src/debug.js +++ b/src/debug.js @@ -13,6 +13,11 @@ exports.enable = enable; exports.enabled = enabled; exports.humanize = require('ms'); +/** + * Active `debug` instances. + */ +exports.instances = []; + /** * The currently active debug mode names, and names to skip. */ @@ -114,15 +119,23 @@ function createDebug(namespace) { debug.enabled = exports.enabled(namespace); debug.useColors = exports.useColors(); debug.color = selectColor(namespace); + debug.destroy = destroy; // env-specific initialization logic for debug instances if ('function' === typeof exports.init) { exports.init(debug); } + exports.instances.push(debug); + return debug; } +function destroy () { + const index = exports.instances.indexOf(this) + exports.instances.splice(index, 1) +} + /** * Enables a debug mode by namespaces. This can include modes * separated by a colon and wildcards. @@ -149,6 +162,11 @@ function enable(namespaces) { exports.names.push(new RegExp('^' + namespaces + '$')); } } + + for (var i = 0; i < exports.instances.length; i++) { + var instance = exports.instances[i]; + instance.enabled = exports.enabled(instance.namespace); + } } /** From d5854f4eb6868c3d424091648ab92a3575b0b55e Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Mon, 7 Aug 2017 21:51:55 -0700 Subject: [PATCH 128/257] support 256 colors Closes #481. --- src/node.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/node.js b/src/node.js index f4119f47..bc3d8d0d 100644 --- a/src/node.js +++ b/src/node.js @@ -25,6 +25,23 @@ exports.useColors = useColors; exports.colors = [6, 2, 3, 4, 5, 1]; +try { + var supportsColor = require('supports-color'); + if (supportsColor && supportsColor.level >= 2) { + exports.colors = [ + 20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 56, 57, 62, 63, 68, 69, 74, 75, 76, 77, 78, 79, 80, 81, + 82, 83, 84, 85, 86, 87, 92, 93, 98, 99, 112, 113, 118, 119, 128, 129, + 134, 135, 148, 149, 154, 155, 160, 161, 162, 163, 164, 165, 166, 167, + 168, 169, 170, 171, 172, 173, 178, 179, 184, 185, 190, 191, 196, 197, + 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 214, 215, + 220, 221, 226, 227 + ]; + } +} catch (err) { + // swallow - we only care if `supports-color` is available; it doesn't have to be. +} + /** * Build up the default `inspectOpts` object from the environment variables. * @@ -92,10 +109,11 @@ function formatArgs(args) { if (useColors) { var c = this.color; - var prefix = ' \u001b[3' + c + ';1m' + name + ' ' + '\u001b[0m'; + var colorCode = '\u001b[3' + (c < 8 ? c : '8;5;' + c); + var prefix = ' ' + colorCode + ';1m' + name + ' ' + '\u001b[0m'; args[0] = prefix + args[0].split('\n').join('\n' + prefix); - args.push('\u001b[3' + c + 'm+' + exports.humanize(this.diff) + '\u001b[0m'); + args.push(colorCode + 'm+' + exports.humanize(this.diff) + '\u001b[0m'); } else { args[0] = new Date().toUTCString() + ' ' + name + ' ' + args[0]; From 39eb2770a2ae2e9cd51356d2f6324616484274c3 Mon Sep 17 00:00:00 2001 From: "antoine.leveugle" Date: Sun, 29 Jan 2017 17:10:42 +0100 Subject: [PATCH 129/257] Use Date#toISOString() instead to Date#toUTCString() when output is not a TTY Easier to parse programatically and contains milliseconds. Closes #418. --- README.md | 2 +- src/node.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3748db94..bca8417e 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ Then, run the program to be debugged as usual. ![](http://f.cl.ly/items/2i3h1d3t121M2Z1A3Q0N/Screenshot.png) - When stdout is not a TTY, `Date#toUTCString()` is used, making it more useful for logging the debug information as shown below: + When stdout is not a TTY, `Date#toISOString()` is used, making it more useful for logging the debug information as shown below: ![](http://f.cl.ly/items/112H3i0e0o0P0a2Q2r11/Screenshot.png) diff --git a/src/node.js b/src/node.js index bc3d8d0d..ae556fc0 100644 --- a/src/node.js +++ b/src/node.js @@ -115,7 +115,7 @@ function formatArgs(args) { args[0] = prefix + args[0].split('\n').join('\n' + prefix); args.push(colorCode + 'm+' + exports.humanize(this.diff) + '\u001b[0m'); } else { - args[0] = new Date().toUTCString() + args[0] = new Date().toISOString() + ' ' + name + ' ' + args[0]; } } From 826fd94639efeaa3c5701b50d335caead084a5d6 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 8 Aug 2017 11:46:13 -0700 Subject: [PATCH 130/257] update "browserify" to v14.4.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index df863517..bad6f09b 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "ms": "2.0.0" }, "devDependencies": { - "browserify": "9.0.3", + "browserify": "14.4.0", "chai": "^3.5.0", "concurrently": "^3.1.0", "coveralls": "^2.11.15", From cefbd07bd8168a0352f858129562fb9d480b76b2 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 8 Aug 2017 11:54:27 -0700 Subject: [PATCH 131/257] update `make lint` --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 584da8bf..304b6a5e 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ node_modules: package.json @touch node_modules lint: .FORCE - eslint browser.js debug.js index.js node.js + eslint *.js src/*.js test-node: .FORCE istanbul cover node_modules/mocha/bin/_mocha -- test/**.js From 65192b755dcbaef9e958c28a70833e5bd6758264 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Tue, 8 Aug 2017 11:59:22 -0700 Subject: [PATCH 132/257] use contrast-bounded colors --- src/node.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/node.js b/src/node.js index ae556fc0..b85ec7e3 100644 --- a/src/node.js +++ b/src/node.js @@ -23,19 +23,17 @@ exports.useColors = useColors; * Colors. */ -exports.colors = [6, 2, 3, 4, 5, 1]; +exports.colors = [ 6, 2, 3, 4, 5, 1 ]; try { var supportsColor = require('supports-color'); if (supportsColor && supportsColor.level >= 2) { exports.colors = [ - 20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 56, 57, 62, 63, 68, 69, 74, 75, 76, 77, 78, 79, 80, 81, - 82, 83, 84, 85, 86, 87, 92, 93, 98, 99, 112, 113, 118, 119, 128, 129, - 134, 135, 148, 149, 154, 155, 160, 161, 162, 163, 164, 165, 166, 167, - 168, 169, 170, 171, 172, 173, 178, 179, 184, 185, 190, 191, 196, 197, - 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 214, 215, - 220, 221, 226, 227 + 20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 62, 63, 68, + 69, 74, 75, 76, 77, 78, 79, 80, 81, 92, 93, 98, 99, 112, 113, 128, 129, 134, + 135, 148, 149, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, + 172, 173, 178, 179, 184, 185, 196, 197, 198, 199, 200, 201, 202, 203, 204, + 205, 206, 207, 208, 209, 214, 215, 220, 221 ]; } } catch (err) { From 5ed41f6d92b639cdaa1b2e93fc4071886b5a82db Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 8 Aug 2017 11:59:56 -0700 Subject: [PATCH 133/257] add Web Browser 256 colors Like #481, but for the web browser. --- src/browser.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/browser.js b/src/browser.js index 71069249..879aaa79 100644 --- a/src/browser.js +++ b/src/browser.js @@ -20,12 +20,17 @@ exports.storage = 'undefined' != typeof chrome */ exports.colors = [ - 'lightseagreen', - 'forestgreen', - 'goldenrod', - 'dodgerblue', - 'darkorchid', - 'crimson' + '#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', + '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', + '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', + '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', + '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', + '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', + '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', + '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', + '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', + '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', + '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33' ]; /** From 02eb3c607e38d709b79701a0d0140da77b006bdf Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 8 Aug 2017 12:01:01 -0700 Subject: [PATCH 134/257] fix lint --- src/debug.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/debug.js b/src/debug.js index ed2956d6..7c49039c 100644 --- a/src/debug.js +++ b/src/debug.js @@ -150,10 +150,11 @@ function enable(namespaces) { exports.names = []; exports.skips = []; + var i; var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); var len = split.length; - for (var i = 0; i < len; i++) { + for (i = 0; i < len; i++) { if (!split[i]) continue; // ignore empty strings namespaces = split[i].replace(/\*/g, '.*?'); if (namespaces[0] === '-') { @@ -163,7 +164,7 @@ function enable(namespaces) { } } - for (var i = 0; i < exports.instances.length; i++) { + for (i = 0; i < exports.instances.length; i++) { var instance = exports.instances[i]; instance.enabled = exports.enabled(instance.namespace); } From 25e07c78fc5eec5a593ebf51b2a1ed3605897e0e Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 8 Aug 2017 12:01:09 -0700 Subject: [PATCH 135/257] don't call splice() when indexOf() returns -1 --- src/debug.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/debug.js b/src/debug.js index 7c49039c..77e6384a 100644 --- a/src/debug.js +++ b/src/debug.js @@ -132,8 +132,13 @@ function createDebug(namespace) { } function destroy () { - const index = exports.instances.indexOf(this) - exports.instances.splice(index, 1) + var index = exports.instances.indexOf(this); + if (index !== -1) { + exports.instances.splice(index, 1); + return true; + } else { + return false; + } } /** From 87880f6ae1f48b12d9f3346bce564a66cba6b93e Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 8 Aug 2017 12:30:57 -0700 Subject: [PATCH 136/257] separate Node.js and web browser examples --- example/browser.html | 26 -------------------------- example/wildcards.js | 10 ---------- examples/browser/colors.html | 26 ++++++++++++++++++++++++++ {example => examples/node}/app.js | 4 ++-- examples/node/colors.js | 7 +++++++ {example => examples/node}/stdout.js | 2 +- examples/node/wildcards.js | 10 ++++++++++ {example => examples/node}/worker.js | 4 ++-- 8 files changed, 48 insertions(+), 41 deletions(-) delete mode 100644 example/browser.html delete mode 100644 example/wildcards.js create mode 100644 examples/browser/colors.html rename {example => examples/node}/app.js (82%) create mode 100644 examples/node/colors.js rename {example => examples/node}/stdout.js (94%) create mode 100644 examples/node/wildcards.js rename {example => examples/node}/worker.js (84%) diff --git a/example/browser.html b/example/browser.html deleted file mode 100644 index 00904189..00000000 --- a/example/browser.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - debug() - - - - - - - - diff --git a/example/wildcards.js b/example/wildcards.js deleted file mode 100644 index 1fdac20a..00000000 --- a/example/wildcards.js +++ /dev/null @@ -1,10 +0,0 @@ - -var debug = { - foo: require('../')('test:foo'), - bar: require('../')('test:bar'), - baz: require('../')('test:baz') -}; - -debug.foo('foo') -debug.bar('bar') -debug.baz('baz') \ No newline at end of file diff --git a/examples/browser/colors.html b/examples/browser/colors.html new file mode 100644 index 00000000..5d023bb2 --- /dev/null +++ b/examples/browser/colors.html @@ -0,0 +1,26 @@ + + + + debug() + + + + + + + Open your + Web Inspector + to see the debug output + + diff --git a/example/app.js b/examples/node/app.js similarity index 82% rename from example/app.js rename to examples/node/app.js index 05374d98..011b63ad 100644 --- a/example/app.js +++ b/examples/node/app.js @@ -1,5 +1,5 @@ -var debug = require('../')('http') +var debug = require('../../')('http') , http = require('http') , name = 'My App'; @@ -16,4 +16,4 @@ http.createServer(function(req, res){ // fake worker of some kind -require('./worker'); \ No newline at end of file +require('./worker'); diff --git a/examples/node/colors.js b/examples/node/colors.js new file mode 100644 index 00000000..bcc52d94 --- /dev/null +++ b/examples/node/colors.js @@ -0,0 +1,7 @@ +var debug = require('../../') + +debug.enable('*') + +for (var i=0; i < debug.colors.length; i++) { + debug('example:' + i)('The color is %o', debug.colors[i]) +} diff --git a/example/stdout.js b/examples/node/stdout.js similarity index 94% rename from example/stdout.js rename to examples/node/stdout.js index e15322da..c999c4c0 100644 --- a/example/stdout.js +++ b/examples/node/stdout.js @@ -1,4 +1,4 @@ -var debug = require('../'); +var debug = require('../../'); var error = debug('app:error'); // by default stderr is used diff --git a/examples/node/wildcards.js b/examples/node/wildcards.js new file mode 100644 index 00000000..ca99aeff --- /dev/null +++ b/examples/node/wildcards.js @@ -0,0 +1,10 @@ + +var debug = { + foo: require('../../')('test:foo'), + bar: require('../../')('test:bar'), + baz: require('../../')('test:baz') +}; + +debug.foo('foo') +debug.bar('bar') +debug.baz('baz') diff --git a/example/worker.js b/examples/node/worker.js similarity index 84% rename from example/worker.js rename to examples/node/worker.js index 22225f60..07e3bc59 100644 --- a/example/worker.js +++ b/examples/node/worker.js @@ -4,8 +4,8 @@ // DEBUG=worker:a node example/worker // DEBUG=worker:b node example/worker -var a = require('../')('worker:a') - , b = require('../')('worker:b'); +var a = require('../../')('worker:a') + , b = require('../../')('worker:b'); function work() { a('doing lots of uninteresting work'); From ce1a236d93a971dc74930972a03d4d0fe409effd Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 8 Aug 2017 12:31:21 -0700 Subject: [PATCH 137/257] Makefile tweaks Re-introduce `make browser` to make a standalone build of `debug.js` for the web browser. --- Makefile | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 304b6a5e..b86958ab 100644 --- a/Makefile +++ b/Makefile @@ -15,31 +15,31 @@ YARN ?= $(shell which yarn) PKG ?= $(if $(YARN),$(YARN),$(NODE) $(shell which npm)) BROWSERIFY ?= $(NODE) $(BIN)/browserify -.FORCE: - install: node_modules +browser: dist/debug.js + node_modules: package.json @NODE_ENV= $(PKG) install @touch node_modules -lint: .FORCE - eslint *.js src/*.js - -test-node: .FORCE - istanbul cover node_modules/mocha/bin/_mocha -- test/**.js - -test-browser: .FORCE - mkdir -p dist - +dist/debug.js: src/*.js node_modules + @mkdir -p dist @$(BROWSERIFY) \ --standalone debug \ . > dist/debug.js +lint: + eslint *.js src/*.js + +test-node: + istanbul cover node_modules/mocha/bin/_mocha -- test/**.js + +test-browser: + $(MAKE) browser karma start --single-run - rimraf dist -test: .FORCE +test: concurrently \ "make test-node" \ "make test-browser" @@ -47,4 +47,7 @@ test: .FORCE coveralls: cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js +clean: + rimraf dist + .PHONY: all install clean distclean From dfbac9c30f7f3af8c44802197d47450bcbd94952 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 8 Aug 2017 12:54:19 -0700 Subject: [PATCH 138/257] readme refactor --- README.md | 118 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 69 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index bca8417e..861f2993 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,10 @@ [![Build Status](https://travis-ci.org/visionmedia/debug.svg?branch=master)](https://travis-ci.org/visionmedia/debug) [![Coverage Status](https://coveralls.io/repos/github/visionmedia/debug/badge.svg?branch=master)](https://coveralls.io/github/visionmedia/debug?branch=master) [![Slack](https://visionmedia-community-slackin.now.sh/badge.svg)](https://visionmedia-community-slackin.now.sh/) [![OpenCollective](https://opencollective.com/debug/backers/badge.svg)](#backers) [![OpenCollective](https://opencollective.com/debug/sponsors/badge.svg)](#sponsors) + - -A tiny node.js debugging utility modelled after node core's debugging technique. +A tiny JavaScript debugging utility modelled after Node.js core's debugging +technique. Works in Node.js and web browsers. **Discussion around the V3 API is under way [here](https://github.com/visionmedia/debug/issues/370)** @@ -27,7 +28,7 @@ var debug = require('debug')('http') // fake app -debug('booting %s', name); +debug('booting %o', name); http.createServer(function(req, res){ debug(req.method + ' ' + req.url); @@ -51,52 +52,62 @@ setInterval(function(){ }, 1000); ``` - The __DEBUG__ environment variable is then used to enable these based on space or comma-delimited names. Here are some examples: +The `DEBUG` environment variable is then used to enable these based on space or +comma-delimited names. - ![debug http and worker](http://f.cl.ly/items/18471z1H402O24072r1J/Screenshot.png) +Here are some examples: - ![debug worker](http://f.cl.ly/items/1X413v1a3M0d3C2c1E0i/Screenshot.png) +screen shot 2017-08-08 at 12 53 04 pm +screen shot 2017-08-08 at 12 53 38 pm +screen shot 2017-08-08 at 12 53 25 pm #### Windows note - On Windows the environment variable is set using the `set` command. +On Windows the environment variable is set using the `set` command. - ```cmd - set DEBUG=*,-not_this - ``` +```cmd +set DEBUG=*,-not_this +``` - Note that PowerShell uses different syntax to set environment variables. +Note that PowerShell uses different syntax to set environment variables. - ```cmd - $env:DEBUG = "*,-not_this" - ``` +```cmd +$env:DEBUG = "*,-not_this" +``` Then, run the program to be debugged as usual. ## Millisecond diff - When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls. +When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls. - ![](http://f.cl.ly/items/2i3h1d3t121M2Z1A3Q0N/Screenshot.png) +![](http://f.cl.ly/items/2i3h1d3t121M2Z1A3Q0N/Screenshot.png) - When stdout is not a TTY, `Date#toISOString()` is used, making it more useful for logging the debug information as shown below: +When stdout is not a TTY, `Date#toISOString()` is used, making it more useful for logging the debug information as shown below: + +![](http://f.cl.ly/items/112H3i0e0o0P0a2Q2r11/Screenshot.png) - ![](http://f.cl.ly/items/112H3i0e0o0P0a2Q2r11/Screenshot.png) ## Conventions - If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". If you append a "*" to the end of your name, it will always be enabled regardless of the setting of the DEBUG environment variable. You can then use it for normal output as well as debug output. +If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". If you append a "*" to the end of your name, it will always be enabled regardless of the setting of the DEBUG environment variable. You can then use it for normal output as well as debug output. ## Wildcards - The `*` character may be used as a wildcard. Suppose for example your library has debuggers named "connect:bodyParser", "connect:compress", "connect:session", instead of listing all three with `DEBUG=connect:bodyParser,connect:compress,connect:session`, you may simply do `DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`. +The `*` character may be used as a wildcard. Suppose for example your library has +debuggers named "connect:bodyParser", "connect:compress", "connect:session", +instead of listing all three with +`DEBUG=connect:bodyParser,connect:compress,connect:session`, you may simply do +`DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`. - You can also exclude specific debuggers by prefixing them with a "-" character. For example, `DEBUG=*,-connect:*` would include all debuggers except those starting with "connect:". +You can also exclude specific debuggers by prefixing them with a "-" character. +For example, `DEBUG=*,-connect:*` would include all debuggers except those +starting with "connect:". ## Environment Variables - When running through Node.js, you can set a few environment variables that will - change the behavior of the debug logging: +When running through Node.js, you can set a few environment variables that will +change the behavior of the debug logging: | Name | Purpose | |-----------|-------------------------------------------------| @@ -106,16 +117,16 @@ Then, run the program to be debugged as usual. | `DEBUG_SHOW_HIDDEN` | Shows hidden properties on inspected objects. | - __Note:__ The environment variables beginning with `DEBUG_` end up being - converted into an Options object that gets used with `%o`/`%O` formatters. - See the Node.js documentation for - [`util.inspect()`](https://nodejs.org/api/util.html#util_util_inspect_object_options) - for the complete list. +__Note:__ The environment variables beginning with `DEBUG_` end up being +converted into an Options object that gets used with `%o`/`%O` formatters. +See the Node.js documentation for +[`util.inspect()`](https://nodejs.org/api/util.html#util_util_inspect_object_options) +for the complete list. ## Formatters - - Debug uses [printf-style](https://wikipedia.org/wiki/Printf_format_string) formatting. Below are the officially supported formatters: +Debug uses [printf-style](https://wikipedia.org/wiki/Printf_format_string) formatting. +Below are the officially supported formatters: | Formatter | Representation | |-----------|----------------| @@ -126,9 +137,12 @@ Then, run the program to be debugged as usual. | `%j` | JSON. Replaced with the string '[Circular]' if the argument contains circular references. | | `%%` | Single percent sign ('%'). This does not consume an argument. | + ### Custom formatters - You can add custom formatters by extending the `debug.formatters` object. For example, if you wanted to add support for rendering a Buffer as hex with `%h`, you could do something like: +You can add custom formatters by extending the `debug.formatters` object. +For example, if you wanted to add support for rendering a Buffer as hex with +`%h`, you could do something like: ```js const createDebug = require('debug') @@ -142,14 +156,16 @@ debug('this is hex: %h', new Buffer('hello world')) // foo this is hex: 68656c6c6f20776f726c6421 +0ms ``` -## Browser support - You can build a browser-ready script using [browserify](https://github.com/substack/node-browserify), - or just use the [browserify-as-a-service](https://wzrd.in/) [build](https://wzrd.in/standalone/debug@latest), - if you don't want to build it yourself. - Debug's enable state is currently persisted by `localStorage`. - Consider the situation shown below where you have `worker:a` and `worker:b`, - and wish to debug both. You can enable this using `localStorage.debug`: +## Browser Support + +You can build a browser-ready script using [browserify](https://github.com/substack/node-browserify), +or just use the [browserify-as-a-service](https://wzrd.in/) [build](https://wzrd.in/standalone/debug@latest), +if you don't want to build it yourself. + +Debug's enable state is currently persisted by `localStorage`. +Consider the situation shown below where you have `worker:a` and `worker:b`, +and wish to debug both. You can enable this using `localStorage.debug`: ```js localStorage.debug = 'worker:*' @@ -172,21 +188,21 @@ setInterval(function(){ #### Web Inspector Colors - Colors are also enabled on "Web Inspectors" that understand the `%c` formatting - option. These are WebKit web inspectors, Firefox ([since version - 31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/)) - and the Firebug plugin for Firefox (any version). +Colors are also enabled on "Web Inspectors" that understand the `%c` formatting +option. These are WebKit web inspectors, Firefox ([since version +31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/)) +and the Firebug plugin for Firefox (any version). - Colored output looks something like: +Colored output looks something like: - ![](https://cloud.githubusercontent.com/assets/71256/3139768/b98c5fd8-e8ef-11e3-862a-f7253b6f47c6.png) +![](https://cloud.githubusercontent.com/assets/71256/3139768/b98c5fd8-e8ef-11e3-862a-f7253b6f47c6.png) ## Output streams By default `debug` will log to stderr, however this can be configured per-namespace by overriding the `log` method: -Example _stdout.js_: +Example [_stdout.js_](./examples/node/stdout.js): ```js var debug = require('debug'); @@ -210,16 +226,20 @@ log('still goes to stdout, but via console.info now'); ## Checking whether a debug target is enabled -After you've created a debug instance, you can check whether it is enabled by its `.enabled` property: +After you've created a debug instance, you can determine whether or not it is +enabled by checking the `enabled` property: ```javascript const debug = require('debug')('http'); -if(debug.enabled) { - // ... +if (debug.enabled) { + // do stuff... } ``` +You can also manually toggle this property to force the debug instance to be +enabled or disabled. + ## Authors @@ -302,7 +322,7 @@ Become a sponsor and get your logo on our README on Github with a link to your s (The MIT License) -Copyright (c) 2014-2016 TJ Holowaychuk <tj@vision-media.ca> +Copyright (c) 2014-2017 TJ Holowaychuk <tj@vision-media.ca> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the From 31f3343de76cb8687041387a1b811745c6e84473 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 8 Aug 2017 12:56:04 -0700 Subject: [PATCH 139/257] example: use %o formatter --- examples/node/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/node/app.js b/examples/node/app.js index 011b63ad..d4a19914 100644 --- a/examples/node/app.js +++ b/examples/node/app.js @@ -5,7 +5,7 @@ var debug = require('../../')('http') // fake app -debug('booting %s', name); +debug('booting %o', name); http.createServer(function(req, res){ debug(req.method + ' ' + req.url); From 25eb545324912dd2863658d0ba35426c0f617619 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 8 Aug 2017 13:02:54 -0700 Subject: [PATCH 140/257] more readme screenshots replaced --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 861f2993..a09db3a7 100644 --- a/README.md +++ b/README.md @@ -81,11 +81,11 @@ Then, run the program to be debugged as usual. When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls. -![](http://f.cl.ly/items/2i3h1d3t121M2Z1A3Q0N/Screenshot.png) + When stdout is not a TTY, `Date#toISOString()` is used, making it more useful for logging the debug information as shown below: -![](http://f.cl.ly/items/112H3i0e0o0P0a2Q2r11/Screenshot.png) + ## Conventions @@ -193,9 +193,9 @@ option. These are WebKit web inspectors, Firefox ([since version 31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/)) and the Firebug plugin for Firefox (any version). -Colored output looks something like: +Colored output looks like: -![](https://cloud.githubusercontent.com/assets/71256/3139768/b98c5fd8-e8ef-11e3-862a-f7253b6f47c6.png) + ## Output streams From 8b5c438a222167bd0cc66db046bac073f01b3c01 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 8 Aug 2017 13:10:08 -0700 Subject: [PATCH 141/257] add Namespace Colors section to readme --- README.md | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index a09db3a7..46c22a9b 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,31 @@ $env:DEBUG = "*,-not_this" Then, run the program to be debugged as usual. + +## Namespace Colors + +Every debug instance has a color generated for it based on its namespace name. +This helps when visually parsing the debug output to identify which debug instance +a debug line belongs to. + +#### Node.js + +In Node.js, colors are enabled when stderr is a TTY. You also _should_ install +the [`supports-color`](https://npmjs.org/supports-color) module alongside debug, +otherwise debug will only use a small handful of basic colors. + + + +#### Web Browser + +Colors are also enabled on "Web Inspectors" that understand the `%c` formatting +option. These are WebKit web inspectors, Firefox ([since version +31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/)) +and the Firebug plugin for Firefox (any version). + + + + ## Millisecond diff When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls. @@ -186,17 +211,6 @@ setInterval(function(){ }, 1200); ``` -#### Web Inspector Colors - -Colors are also enabled on "Web Inspectors" that understand the `%c` formatting -option. These are WebKit web inspectors, Firefox ([since version -31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/)) -and the Firebug plugin for Firefox (any version). - -Colored output looks like: - - - ## Output streams From 87e7399fd7e6c4196082bcbfd02bedf95d1b9c76 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 8 Aug 2017 13:12:42 -0700 Subject: [PATCH 142/257] readme++ --- README.md | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 46c22a9b..a2b122e9 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ $ npm install debug `debug` exposes a function; simply pass this function the name of your module, and it will return a decorated version of `console.error` for you to pass debug statements to. This will allow you to toggle the debug output for different parts of your module as well as the module as a whole. -Example _app.js_: +Example [_app.js_](./examples/node/app.js): ```js var debug = require('debug')('http') @@ -42,14 +42,25 @@ http.createServer(function(req, res){ require('./worker'); ``` -Example _worker.js_: +Example [_worker.js_](./examples/node/worker.js): ```js -var debug = require('debug')('worker'); +var a = require('debug')('worker:a') + , b = require('debug')('worker:b'); -setInterval(function(){ - debug('doing some work'); -}, 1000); +function work() { + a('doing lots of uninteresting work'); + setTimeout(work, Math.random() * 1000); +} + +work(); + +function workb() { + b('doing some work'); + setTimeout(workb, Math.random() * 2000); +} + +workb(); ``` The `DEBUG` environment variable is then used to enable these based on space or From 402c8567ee3e01e36464ba9591ac436de6fbf0a9 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 8 Aug 2017 13:30:21 -0700 Subject: [PATCH 143/257] fix lint --- .eslintrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.eslintrc b/.eslintrc index 8a37ae2c..146371ed 100644 --- a/.eslintrc +++ b/.eslintrc @@ -3,6 +3,9 @@ "browser": true, "node": true }, + "globals": { + "chrome": true + }, "rules": { "no-console": 0, "no-empty": [1, { "allowEmptyCatch": true }] From d73c4aec194f98a3075adf530b020d4b3098c6cc Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 8 Aug 2017 14:17:03 -0700 Subject: [PATCH 144/257] fix `make test` --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b86958ab..5d400023 100644 --- a/Makefile +++ b/Makefile @@ -50,4 +50,4 @@ coveralls: clean: rimraf dist -.PHONY: all install clean distclean +.PHONY: browser install clean coveralls lint test test-node test-browser From f178d861df18abacac6e9e4607c7306a1147bf3d Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 8 Aug 2017 14:26:59 -0700 Subject: [PATCH 145/257] attempt to separate the Node and Browser tests in Travis --- .travis.yml | 13 ++++++++++--- Makefile | 25 +++++++++++++++---------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6c6090c3..1a5bde09 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,21 @@ +sudo: false language: node_js + node_js: - - "6" - - "5" - "4" + - "6" + - "8" install: - - make node_modules + - make install script: - make lint - make test - make coveralls + +matrix: + include: + - node_js: '8' + env: BROWSER=1 diff --git a/Makefile b/Makefile index 5d400023..f4f89d02 100644 --- a/Makefile +++ b/Makefile @@ -30,24 +30,29 @@ dist/debug.js: src/*.js node_modules . > dist/debug.js lint: - eslint *.js src/*.js + @eslint *.js src/*.js test-node: - istanbul cover node_modules/mocha/bin/_mocha -- test/**.js + @istanbul cover node_modules/mocha/bin/_mocha -- test/**.js + @cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js test-browser: - $(MAKE) browser - karma start --single-run + @$(MAKE) browser + @karma start --single-run -test: - concurrently \ +test-all: + @concurrently \ "make test-node" \ "make test-browser" -coveralls: - cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js +test: + @if [ "x$(BROWSER_NAME)" = "x" ]; then \ + $(MAKE) test-node; \ + else \ + $(MAKE) test-browser; \ + fi clean: - rimraf dist + rimraf dist coverage -.PHONY: browser install clean coveralls lint test test-node test-browser +.PHONY: browser install clean lint test test-all test-node test-browser From f6f621327796a92d75362e48dff2a1f51299a9ba Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 8 Aug 2017 14:30:26 -0700 Subject: [PATCH 146/257] remove `make coveralls` from travis --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1a5bde09..a7643003 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,6 @@ install: script: - make lint - make test - - make coveralls matrix: include: From 67529535431ea0c7368131683e7454266884e2fc Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 8 Aug 2017 14:34:35 -0700 Subject: [PATCH 147/257] =?UTF-8?q?fix=20browser=20test=20=F0=9F=98=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f4f89d02..3ddd1360 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,7 @@ test-all: "make test-browser" test: - @if [ "x$(BROWSER_NAME)" = "x" ]; then \ + @if [ "x$(BROWSER)" = "x" ]; then \ $(MAKE) test-node; \ else \ $(MAKE) test-browser; \ From d2dd80aeaf1b037f0b3be21838c4594bbedc4a9c Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 8 Aug 2017 14:49:27 -0700 Subject: [PATCH 148/257] component: update "ms" to v2.0.0 --- component.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/component.json b/component.json index 94cd36d8..d1f6e22b 100644 --- a/component.json +++ b/component.json @@ -14,6 +14,6 @@ "src/debug.js" ], "dependencies": { - "rauchg/ms.js": "0.7.1" + "rauchg/ms.js": "2.0.0" } } From 52b894cd798f492ead1866fca4d76a649f0e62c6 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 8 Aug 2017 14:55:46 -0700 Subject: [PATCH 149/257] Release 3.0.0 --- CHANGELOG.md | 16 ++++++++++++++++ component.json | 2 +- package.json | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a1a270cd..404d5bef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,20 @@ +3.0.0 / 2017-08-08 +================== + + * Breaking: Remove DEBUG_FD (#406) + * Breaking: Use `Date#toISOString()` instead to `Date#toUTCString()` when output is not a TTY (#418) + * Breaking: Make millisecond timer namespace specific and allow 'always enabled' output (#408) + * Addition: document `enabled` flag (#465) + * Addition: add 256 colors mode (#481) + * Addition: `enabled()` updates existing debug instances, add `destroy()` function (#440) + * Update: component: update "ms" to v2.0.0 + * Update: separate the Node and Browser tests in Travis-CI + * Update: refactor Readme, fixed documentation, added "Namespace Colors" section, redid screenshots + * Update: separate Node.js and web browser examples for organization + * Update: update "browserify" to v14.4.0 + * Fix: fix Readme typo (#473) + 2.6.8 / 2017-05-18 ================== diff --git a/component.json b/component.json index d1f6e22b..531e0123 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "debug", "repo": "visionmedia/debug", "description": "small debugging utility", - "version": "2.6.8", + "version": "3.0.0", "keywords": [ "debug", "log", diff --git a/package.json b/package.json index bad6f09b..869b045d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "2.6.8", + "version": "3.0.0", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From 13e1d068e9265b2c9a160ba242a6be200b9811f0 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 8 Aug 2017 15:23:50 -0700 Subject: [PATCH 150/257] remove v3 discussion note for now --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index a2b122e9..1f3b08e1 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,6 @@ A tiny JavaScript debugging utility modelled after Node.js core's debugging technique. Works in Node.js and web browsers. -**Discussion around the V3 API is under way [here](https://github.com/visionmedia/debug/issues/370)** - ## Installation ```bash From b3ea123cc45828af926efbf5e5a4c63bd11b7aab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Thu, 24 Aug 2017 21:40:18 +0200 Subject: [PATCH 151/257] Disable colors in Edge and Internet Explorer (#489) Fixes #417. --- src/browser.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/browser.js b/src/browser.js index 879aaa79..f5149ff5 100644 --- a/src/browser.js +++ b/src/browser.js @@ -49,6 +49,11 @@ function useColors() { return true; } + // Internet Explorer and Edge do not support colors. + if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { + return false; + } + // is webkit? http://stackoverflow.com/a/16459606/376773 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || From 3e1849d3aaa1b9a325ad6d054acf695fddb4efe9 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Thu, 24 Aug 2017 12:44:17 -0700 Subject: [PATCH 152/257] Release 3.0.1 --- CHANGELOG.md | 5 +++++ component.json | 2 +- package.json | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 404d5bef..a1c0eaf5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ +3.0.1 / 2017-08-24 +================== + + * Fix: Disable colors in Edge and Internet Explorer (#489) + 3.0.0 / 2017-08-08 ================== diff --git a/component.json b/component.json index 531e0123..a2e9ad39 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "debug", "repo": "visionmedia/debug", "description": "small debugging utility", - "version": "3.0.0", + "version": "3.0.1", "keywords": [ "debug", "log", diff --git a/package.json b/package.json index 869b045d..1514200b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "3.0.0", + "version": "3.0.1", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From daf1a7c8c0f62f5dbc8d48158d6748d0527cc551 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Fri, 1 Sep 2017 19:49:50 +0100 Subject: [PATCH 153/257] correct spelling mistake --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a1c0eaf5..1cf73043 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,7 +43,7 @@ 2.6.4 / 2017-04-20 ================== - * Fix: bug that would occure if process.env.DEBUG is a non-string value. (#444, @LucianBuzzo) + * Fix: bug that would occur if process.env.DEBUG is a non-string value. (#444, @LucianBuzzo) * Chore: ignore bower.json in npm installations. (#437, @joaovieira) * Misc: update "ms" to v0.7.3 (@tootallnate) From 7cd9e539ce571fc3314d34d9d1dac3124839dbac Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Wed, 13 Sep 2017 15:39:28 +0200 Subject: [PATCH 154/257] examples: fix colors printout Fixes #502. --- examples/browser/colors.html | 4 +++- examples/node/colors.js | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/browser/colors.html b/examples/browser/colors.html index 5d023bb2..ce969072 100644 --- a/examples/browser/colors.html +++ b/examples/browser/colors.html @@ -8,13 +8,15 @@ debug.enable('*') for (var i=0; i < debug.colors.length; i++) { - debug('example:' + i)('The color is %o', debug.colors[i]) + const d = debug('example:' + i); + d('The color is %o', d.color); } diff --git a/examples/node/colors.js b/examples/node/colors.js index bcc52d94..c144ee4e 100644 --- a/examples/node/colors.js +++ b/examples/node/colors.js @@ -3,5 +3,6 @@ var debug = require('../../') debug.enable('*') for (var i=0; i < debug.colors.length; i++) { - debug('example:' + i)('The color is %o', debug.colors[i]) + const d = debug('example:' + i); + d('The color is %o', d.color); } From fdfa0f5f6cc7e83fd60b6cf1e7b990cbf6388621 Mon Sep 17 00:00:00 2001 From: Mariusz Nowak Date: Mon, 15 May 2017 10:48:24 +0200 Subject: [PATCH 155/257] Fix browser detection --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index e12cf4d5..cabcbcda 100644 --- a/src/index.js +++ b/src/index.js @@ -3,7 +3,7 @@ * treat as a browser. */ -if (typeof process !== 'undefined' && process.type === 'renderer') { +if (typeof process === 'undefined' || process.type === 'renderer') { module.exports = require('./browser.js'); } else { module.exports = require('./node.js'); From e7e568a24736486721882282eb21beb31c741647 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Fri, 15 Sep 2017 00:25:50 +0200 Subject: [PATCH 156/257] ignore package-lock.json --- .gitignore | 5 ++++- src/{debug.js => common.js} | 0 2 files changed, 4 insertions(+), 1 deletion(-) rename src/{debug.js => common.js} (100%) diff --git a/.gitignore b/.gitignore index f459ae9f..f0cf3a35 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,10 @@ node_modules *.sock build -yarn.lock npm-debug.log dist coverage + +# lockfiles +yarn.lock +package-lock.json diff --git a/src/debug.js b/src/common.js similarity index 100% rename from src/debug.js rename to src/common.js From a0601e5e65ca80ce2f39b1243db332c64c124214 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Fri, 15 Sep 2017 02:28:44 +0200 Subject: [PATCH 157/257] fix --- src/{common.js => debug.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{common.js => debug.js} (100%) diff --git a/src/common.js b/src/debug.js similarity index 100% rename from src/common.js rename to src/debug.js From 47747f329fe159e94262318b52b87a48f6c0acd4 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 19 Sep 2017 00:09:21 +0200 Subject: [PATCH 158/257] remove `component.json` The project has been deprected since 2015. We should be encouraging the community to move forward and thus this file should be removed. --- component.json | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 component.json diff --git a/component.json b/component.json deleted file mode 100644 index a2e9ad39..00000000 --- a/component.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "debug", - "repo": "visionmedia/debug", - "description": "small debugging utility", - "version": "3.0.1", - "keywords": [ - "debug", - "log", - "debugger" - ], - "main": "src/browser.js", - "scripts": [ - "src/browser.js", - "src/debug.js" - ], - "dependencies": { - "rauchg/ms.js": "2.0.0" - } -} From c38a0166c266a679c8de012d4eaccec3f944e685 Mon Sep 17 00:00:00 2001 From: Ya Zhuang Date: Fri, 22 Sep 2017 06:26:33 +0800 Subject: [PATCH 159/257] remove ReDoS regexp in %o formatter (#504) --- src/node.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/node.js b/src/node.js index b85ec7e3..2bc75713 100644 --- a/src/node.js +++ b/src/node.js @@ -83,7 +83,9 @@ function useColors() { exports.formatters.o = function(v) { this.inspectOpts.colors = this.useColors; return util.inspect(v, this.inspectOpts) - .replace(/\s*\n\s*/g, ' '); + .split('\n').map(function(str) { + return str.trim() + }).join(' '); }; /** From bdb7e0137f84dc8bcfc95daede7c694799d38dbf Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Thu, 21 Sep 2017 20:02:06 +0200 Subject: [PATCH 160/257] remove "component" from package.json --- package.json | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/package.json b/package.json index 1514200b..8777fc3d 100644 --- a/package.json +++ b/package.json @@ -39,11 +39,5 @@ "sinon-chai": "^2.8.0" }, "main": "./src/index.js", - "browser": "./src/browser.js", - "component": { - "scripts": { - "debug/index.js": "browser.js", - "debug/debug.js": "debug.js" - } - } + "browser": "./src/browser.js" } From f53962e944a87e6ca9bb622a2a12dffc22a9bb5a Mon Sep 17 00:00:00 2001 From: Ya Zhuang Date: Fri, 22 Sep 2017 06:26:33 +0800 Subject: [PATCH 161/257] remove ReDoS regexp in %o formatter (#504) --- src/node.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/node.js b/src/node.js index af612976..b15109c9 100644 --- a/src/node.js +++ b/src/node.js @@ -85,7 +85,9 @@ function useColors() { exports.formatters.o = function(v) { this.inspectOpts.colors = this.useColors; return util.inspect(v, this.inspectOpts) - .replace(/\s*\n\s*/g, ' '); + .split('\n').map(function(str) { + return str.trim() + }).join(' '); }; /** From 13abeae468fea297d0dccc50bc55590809241083 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Fri, 22 Sep 2017 15:32:23 +0200 Subject: [PATCH 162/257] Release 2.6.9 --- CHANGELOG.md | 5 +++++ component.json | 2 +- package.json | 2 +- src/inspector-log.js | 15 +++++++++++++++ 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 src/inspector-log.js diff --git a/CHANGELOG.md b/CHANGELOG.md index a1a270cd..eadaa189 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ +2.6.9 / 2017-09-22 +================== + + * remove ReDoS regexp in %o formatter (#504) + 2.6.8 / 2017-05-18 ================== diff --git a/component.json b/component.json index 94cd36d8..9de26410 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "debug", "repo": "visionmedia/debug", "description": "small debugging utility", - "version": "2.6.8", + "version": "2.6.9", "keywords": [ "debug", "log", diff --git a/package.json b/package.json index df863517..dc787ba7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "2.6.8", + "version": "2.6.9", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" diff --git a/src/inspector-log.js b/src/inspector-log.js new file mode 100644 index 00000000..60ea6c04 --- /dev/null +++ b/src/inspector-log.js @@ -0,0 +1,15 @@ +module.exports = inspectorLog; + +// black hole +const nullStream = new (require('stream').Writable)(); +nullStream._write = () => {}; + +/** + * Outputs a `console.log()` to the Node.js Inspector console *only*. + */ +function inspectorLog() { + const stdout = console._stdout; + console._stdout = nullStream; + console.log.apply(console, arguments); + console._stdout = stdout; +} From 56a3853b95990a22079d646601aa01e93eceb1c7 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Fri, 22 Sep 2017 15:45:06 +0200 Subject: [PATCH 163/257] Add `DEBUG_HIDE_TTY_DATE` env var (#486) Squashed commit of the following: commit 62589c0a4e1babc5953ea30c7ef80b3867ed0a04 Author: Adrian Mejia Date: Sat Aug 12 15:24:45 2017 -0400 solves merge conflict commit 55e5c5e86812163293779e9bbad1afc252c83230 Author: Adrian Mejia Date: Sat Aug 12 15:21:16 2017 -0400 docs commit e09dec33c15fae136039c7ebd94c23000a35373f Author: Adrian Mejia Date: Sat Aug 12 15:19:10 2017 -0400 cleanup commit 9dd6a2b9ca3b1f0d9852ecf0e64ccc6dacf04fa7 Author: Adrian Mejia Date: Sat Aug 12 15:05:53 2017 -0400 enables DEBUG_HIDE_TTY_DATE --- README.md | 5 +++-- src/node.js | 11 +++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1f3b08e1..9157bfc4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # debug -[![Build Status](https://travis-ci.org/visionmedia/debug.svg?branch=master)](https://travis-ci.org/visionmedia/debug) [![Coverage Status](https://coveralls.io/repos/github/visionmedia/debug/badge.svg?branch=master)](https://coveralls.io/github/visionmedia/debug?branch=master) [![Slack](https://visionmedia-community-slackin.now.sh/badge.svg)](https://visionmedia-community-slackin.now.sh/) [![OpenCollective](https://opencollective.com/debug/backers/badge.svg)](#backers) +[![Build Status](https://travis-ci.org/visionmedia/debug.svg?branch=master)](https://travis-ci.org/visionmedia/debug) [![Coverage Status](https://coveralls.io/repos/github/visionmedia/debug/badge.svg?branch=master)](https://coveralls.io/github/visionmedia/debug?branch=master) [![Slack](https://visionmedia-community-slackin.now.sh/badge.svg)](https://visionmedia-community-slackin.now.sh/) [![OpenCollective](https://opencollective.com/debug/backers/badge.svg)](#backers) [![OpenCollective](https://opencollective.com/debug/sponsors/badge.svg)](#sponsors) @@ -149,6 +149,7 @@ change the behavior of the debug logging: | `DEBUG_COLORS`| Whether or not to use colors in the debug output. | | `DEBUG_DEPTH` | Object inspection depth. | | `DEBUG_SHOW_HIDDEN` | Shows hidden properties on inspected objects. | +| `DEBUG_HIDE_TTY_DATE` | Hide date from debug output on TTY. | __Note:__ The environment variables beginning with `DEBUG_` end up being @@ -269,7 +270,7 @@ enabled or disabled. - TJ Holowaychuk - Nathan Rajlich - Andrew Rhyne - + ## Backers Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/debug#backer)] diff --git a/src/node.js b/src/node.js index 2bc75713..5440d5b0 100644 --- a/src/node.js +++ b/src/node.js @@ -115,8 +115,15 @@ function formatArgs(args) { args[0] = prefix + args[0].split('\n').join('\n' + prefix); args.push(colorCode + 'm+' + exports.humanize(this.diff) + '\u001b[0m'); } else { - args[0] = new Date().toISOString() - + ' ' + name + ' ' + args[0]; + args[0] = getDate() + name + ' ' + args[0]; + } +} + +function getDate() { + if (exports.inspectOpts.hideTtyDate) { + return ''; + } else { + return new Date().toISOString() + ' '; } } From 2c0df9baf7aefae2ea830e9d5eb2be64f0e71f18 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 26 Sep 2017 21:11:45 +0200 Subject: [PATCH 164/257] rename `DEBUG_HIDE_TTY_DATE` to `DEBUG_HIDE_DATE` The date is actually only printed when output is *NOT* a TTY. Let's just genericize the name instead. --- README.md | 4 ++-- src/node.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9157bfc4..8e754d17 100644 --- a/README.md +++ b/README.md @@ -146,10 +146,10 @@ change the behavior of the debug logging: | Name | Purpose | |-----------|-------------------------------------------------| | `DEBUG` | Enables/disables specific debugging namespaces. | +| `DEBUG_HIDE_DATE` | Hide date from debug output (non-TTY). | | `DEBUG_COLORS`| Whether or not to use colors in the debug output. | -| `DEBUG_DEPTH` | Object inspection depth. | +| `DEBUG_DEPTH` | Object inspection depth. | | `DEBUG_SHOW_HIDDEN` | Shows hidden properties on inspected objects. | -| `DEBUG_HIDE_TTY_DATE` | Hide date from debug output on TTY. | __Note:__ The environment variables beginning with `DEBUG_` end up being diff --git a/src/node.js b/src/node.js index 5440d5b0..d666fb9c 100644 --- a/src/node.js +++ b/src/node.js @@ -120,7 +120,7 @@ function formatArgs(args) { } function getDate() { - if (exports.inspectOpts.hideTtyDate) { + if (exports.inspectOpts.hideDate) { return ''; } else { return new Date().toISOString() + ' '; From f073e056f33efdd5b311381eb6bca2bc850745bf Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 26 Sep 2017 21:13:38 +0200 Subject: [PATCH 165/257] Release 3.1.0 --- CHANGELOG.md | 12 ++++++++++++ package.json | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a81736c0..820d21e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,16 @@ +3.1.0 / 2017-09-26 +================== + + * Add `DEBUG_HIDE_DATE` env var (#486) + * Remove ReDoS regexp in %o formatter (#504) + * Remove "component" from package.json + * Remove `component.json` + * Ignore package-lock.json + * Examples: fix colors printout + * Fix: browser detection + * Fix: spelling mistake (#496, @EdwardBetts) + 3.0.1 / 2017-08-24 ================== diff --git a/package.json b/package.json index 8777fc3d..ada43cfe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "3.0.1", + "version": "3.1.0", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From 71169065b5262f9858ac78cc0b688c84a438f290 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Wed, 11 Oct 2017 08:31:18 -0700 Subject: [PATCH 166/257] refactor to make the common code be a setup function (#507) This is so that we can make both a Node.js instance and web browser instance for when `--inspect` is used in Node.js. --- src/browser.js | 40 ++++----- src/common.js | 235 +++++++++++++++++++++++++++++++++++++++++++++++++ src/debug.js | 225 ---------------------------------------------- src/node.js | 47 +++++----- 4 files changed, 272 insertions(+), 275 deletions(-) create mode 100644 src/common.js delete mode 100644 src/debug.js diff --git a/src/browser.js b/src/browser.js index f5149ff5..f18d63e7 100644 --- a/src/browser.js +++ b/src/browser.js @@ -1,10 +1,7 @@ /** * This is the web browser implementation of `debug()`. - * - * Expose `debug()` as the module. */ -exports = module.exports = require('./debug'); exports.log = log; exports.formatArgs = formatArgs; exports.save = save; @@ -66,19 +63,6 @@ function useColors() { (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); } -/** - * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. - */ - -exports.formatters.j = function(v) { - try { - return JSON.stringify(v); - } catch (err) { - return '[UnexpectedJSONParseError]: ' + err.message; - } -}; - - /** * Colorize log arguments if enabled. * @@ -93,7 +77,7 @@ function formatArgs(args) { + (useColors ? ' %c' : ' ') + args[0] + (useColors ? '%c ' : ' ') - + '+' + exports.humanize(this.diff); + + '+' + module.exports.humanize(this.diff); if (!useColors) return; @@ -171,12 +155,6 @@ function load() { return r; } -/** - * Enable namespaces listed in `localStorage.debug` initially. - */ - -exports.enable(load()); - /** * Localstorage attempts to return the localstorage. * @@ -193,3 +171,19 @@ function localstorage() { return window.localStorage; } catch (e) {} } + +module.exports = require('./common')(exports); + +var formatters = module.exports.formatters; + +/** + * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. + */ + +formatters.j = function(v) { + try { + return JSON.stringify(v); + } catch (err) { + return '[UnexpectedJSONParseError]: ' + err.message; + } +}; diff --git a/src/common.js b/src/common.js new file mode 100644 index 00000000..61eaf893 --- /dev/null +++ b/src/common.js @@ -0,0 +1,235 @@ + +/** + * This is the common logic for both the Node.js and web browser + * implementations of `debug()`. + */ + +module.exports = function setup(env) { + createDebug.debug = createDebug['default'] = createDebug; + createDebug.coerce = coerce; + createDebug.disable = disable; + createDebug.enable = enable; + createDebug.enabled = enabled; + createDebug.humanize = require('ms'); + + Object.keys(env).forEach(function(key) { + createDebug[key] = env[key]; + }); + + /** + * Active `debug` instances. + */ + createDebug.instances = []; + + /** + * The currently active debug mode names, and names to skip. + */ + + createDebug.names = []; + createDebug.skips = []; + + /** + * Map of special "%n" handling functions, for the debug "format" argument. + * + * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". + */ + + createDebug.formatters = {}; + + /** + * Select a color. + * @param {String} namespace + * @return {Number} + * @api private + */ + + function selectColor(namespace) { + var hash = 0, i; + + for (i in namespace) { + hash = ((hash << 5) - hash) + namespace.charCodeAt(i); + hash |= 0; // Convert to 32bit integer + } + + return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; + } + createDebug.selectColor = selectColor; + + /** + * Create a debugger with the given `namespace`. + * + * @param {String} namespace + * @return {Function} + * @api public + */ + + function createDebug(namespace) { + var prevTime; + + function debug() { + // disabled? + if (!debug.enabled) return; + + var self = debug; + + // set `diff` timestamp + var curr = +new Date(); + var ms = curr - (prevTime || curr); + self.diff = ms; + self.prev = prevTime; + self.curr = curr; + prevTime = curr; + + // turn the `arguments` into a proper Array + var args = new Array(arguments.length); + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i]; + } + + args[0] = createDebug.coerce(args[0]); + + if ('string' !== typeof args[0]) { + // anything else let's inspect with %O + args.unshift('%O'); + } + + // apply any `formatters` transformations + var index = 0; + args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) { + // if we encounter an escaped % then don't increase the array index + if (match === '%%') return match; + index++; + var formatter = createDebug.formatters[format]; + if ('function' === typeof formatter) { + var val = args[index]; + match = formatter.call(self, val); + + // now we need to remove `args[index]` since it's inlined in the `format` + args.splice(index, 1); + index--; + } + return match; + }); + + // apply env-specific formatting (colors, etc.) + createDebug.formatArgs.call(self, args); + + var logFn = self.log || createDebug.log; + logFn.apply(self, args); + } + + debug.namespace = namespace; + debug.enabled = createDebug.enabled(namespace); + debug.useColors = createDebug.useColors(); + debug.color = selectColor(namespace); + debug.destroy = destroy; + //debug.formatArgs = formatArgs; + //debug.rawLog = rawLog; + + // env-specific initialization logic for debug instances + if ('function' === typeof createDebug.init) { + createDebug.init(debug); + } + + createDebug.instances.push(debug); + + return debug; + } + + function destroy () { + var index = createDebug.instances.indexOf(this); + if (index !== -1) { + createDebug.instances.splice(index, 1); + return true; + } else { + return false; + } + } + + /** + * Enables a debug mode by namespaces. This can include modes + * separated by a colon and wildcards. + * + * @param {String} namespaces + * @api public + */ + + function enable(namespaces) { + createDebug.save(namespaces); + + createDebug.names = []; + createDebug.skips = []; + + var i; + var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); + var len = split.length; + + for (i = 0; i < len; i++) { + if (!split[i]) continue; // ignore empty strings + namespaces = split[i].replace(/\*/g, '.*?'); + if (namespaces[0] === '-') { + createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); + } else { + createDebug.names.push(new RegExp('^' + namespaces + '$')); + } + } + + for (i = 0; i < createDebug.instances.length; i++) { + var instance = createDebug.instances[i]; + instance.enabled = createDebug.enabled(instance.namespace); + } + } + + /** + * Disable debug output. + * + * @api public + */ + + function disable() { + createDebug.enable(''); + } + + /** + * Returns true if the given mode name is enabled, false otherwise. + * + * @param {String} name + * @return {Boolean} + * @api public + */ + + function enabled(name) { + if (name[name.length - 1] === '*') { + return true; + } + var i, len; + for (i = 0, len = createDebug.skips.length; i < len; i++) { + if (createDebug.skips[i].test(name)) { + return false; + } + } + for (i = 0, len = createDebug.names.length; i < len; i++) { + if (createDebug.names[i].test(name)) { + return true; + } + } + return false; + } + + /** + * Coerce `val`. + * + * @param {Mixed} val + * @return {Mixed} + * @api private + */ + + function coerce(val) { + if (val instanceof Error) return val.stack || val.message; + return val; + } + + createDebug.enable(createDebug.load()); + + return createDebug; +} diff --git a/src/debug.js b/src/debug.js deleted file mode 100644 index 77e6384a..00000000 --- a/src/debug.js +++ /dev/null @@ -1,225 +0,0 @@ - -/** - * This is the common logic for both the Node.js and web browser - * implementations of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = createDebug.debug = createDebug['default'] = createDebug; -exports.coerce = coerce; -exports.disable = disable; -exports.enable = enable; -exports.enabled = enabled; -exports.humanize = require('ms'); - -/** - * Active `debug` instances. - */ -exports.instances = []; - -/** - * The currently active debug mode names, and names to skip. - */ - -exports.names = []; -exports.skips = []; - -/** - * Map of special "%n" handling functions, for the debug "format" argument. - * - * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". - */ - -exports.formatters = {}; - -/** - * Select a color. - * @param {String} namespace - * @return {Number} - * @api private - */ - -function selectColor(namespace) { - var hash = 0, i; - - for (i in namespace) { - hash = ((hash << 5) - hash) + namespace.charCodeAt(i); - hash |= 0; // Convert to 32bit integer - } - - return exports.colors[Math.abs(hash) % exports.colors.length]; -} - -/** - * Create a debugger with the given `namespace`. - * - * @param {String} namespace - * @return {Function} - * @api public - */ - -function createDebug(namespace) { - - var prevTime; - - function debug() { - // disabled? - if (!debug.enabled) return; - - var self = debug; - - // set `diff` timestamp - var curr = +new Date(); - var ms = curr - (prevTime || curr); - self.diff = ms; - self.prev = prevTime; - self.curr = curr; - prevTime = curr; - - // turn the `arguments` into a proper Array - var args = new Array(arguments.length); - for (var i = 0; i < args.length; i++) { - args[i] = arguments[i]; - } - - args[0] = exports.coerce(args[0]); - - if ('string' !== typeof args[0]) { - // anything else let's inspect with %O - args.unshift('%O'); - } - - // apply any `formatters` transformations - var index = 0; - args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) { - // if we encounter an escaped % then don't increase the array index - if (match === '%%') return match; - index++; - var formatter = exports.formatters[format]; - if ('function' === typeof formatter) { - var val = args[index]; - match = formatter.call(self, val); - - // now we need to remove `args[index]` since it's inlined in the `format` - args.splice(index, 1); - index--; - } - return match; - }); - - // apply env-specific formatting (colors, etc.) - exports.formatArgs.call(self, args); - - var logFn = debug.log || exports.log || console.log.bind(console); - logFn.apply(self, args); - } - - debug.namespace = namespace; - debug.enabled = exports.enabled(namespace); - debug.useColors = exports.useColors(); - debug.color = selectColor(namespace); - debug.destroy = destroy; - - // env-specific initialization logic for debug instances - if ('function' === typeof exports.init) { - exports.init(debug); - } - - exports.instances.push(debug); - - return debug; -} - -function destroy () { - var index = exports.instances.indexOf(this); - if (index !== -1) { - exports.instances.splice(index, 1); - return true; - } else { - return false; - } -} - -/** - * Enables a debug mode by namespaces. This can include modes - * separated by a colon and wildcards. - * - * @param {String} namespaces - * @api public - */ - -function enable(namespaces) { - exports.save(namespaces); - - exports.names = []; - exports.skips = []; - - var i; - var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); - var len = split.length; - - for (i = 0; i < len; i++) { - if (!split[i]) continue; // ignore empty strings - namespaces = split[i].replace(/\*/g, '.*?'); - if (namespaces[0] === '-') { - exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); - } else { - exports.names.push(new RegExp('^' + namespaces + '$')); - } - } - - for (i = 0; i < exports.instances.length; i++) { - var instance = exports.instances[i]; - instance.enabled = exports.enabled(instance.namespace); - } -} - -/** - * Disable debug output. - * - * @api public - */ - -function disable() { - exports.enable(''); -} - -/** - * Returns true if the given mode name is enabled, false otherwise. - * - * @param {String} name - * @return {Boolean} - * @api public - */ - -function enabled(name) { - if (name[name.length - 1] === '*') { - return true; - } - var i, len; - for (i = 0, len = exports.skips.length; i < len; i++) { - if (exports.skips[i].test(name)) { - return false; - } - } - for (i = 0, len = exports.names.length; i < len; i++) { - if (exports.names[i].test(name)) { - return true; - } - } - return false; -} - -/** - * Coerce `val`. - * - * @param {Mixed} val - * @return {Mixed} - * @api private - */ - -function coerce(val) { - if (val instanceof Error) return val.stack || val.message; - return val; -} diff --git a/src/node.js b/src/node.js index d666fb9c..b32d831a 100644 --- a/src/node.js +++ b/src/node.js @@ -7,11 +7,8 @@ var util = require('util'); /** * This is the Node.js implementation of `debug()`. - * - * Expose `debug()` as the module. */ -exports = module.exports = require('./debug'); exports.init = init; exports.log = log; exports.formatArgs = formatArgs; @@ -76,27 +73,6 @@ function useColors() { : tty.isatty(process.stderr.fd); } -/** - * Map %o to `util.inspect()`, all on a single line. - */ - -exports.formatters.o = function(v) { - this.inspectOpts.colors = this.useColors; - return util.inspect(v, this.inspectOpts) - .split('\n').map(function(str) { - return str.trim() - }).join(' '); -}; - -/** - * Map %o to `util.inspect()`, allowing multiple lines if needed. - */ - -exports.formatters.O = function(v) { - this.inspectOpts.colors = this.useColors; - return util.inspect(v, this.inspectOpts); -}; - /** * Adds ANSI color escape codes if enabled. * @@ -113,7 +89,7 @@ function formatArgs(args) { var prefix = ' ' + colorCode + ';1m' + name + ' ' + '\u001b[0m'; args[0] = prefix + args[0].split('\n').join('\n' + prefix); - args.push(colorCode + 'm+' + exports.humanize(this.diff) + '\u001b[0m'); + args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001b[0m'); } else { args[0] = getDate() + name + ' ' + args[0]; } @@ -179,8 +155,25 @@ function init (debug) { } } +module.exports = require('./common')(exports); + +var formatters = module.exports.formatters; + +/** + * Map %o to `util.inspect()`, all on a single line. + */ + +formatters.o = function(v) { + this.inspectOpts.colors = this.useColors; + return util.inspect(v, this.inspectOpts) + .replace(/\s*\n\s*/g, ' '); +}; + /** - * Enable namespaces listed in `process.env.DEBUG` initially. + * Map %O to `util.inspect()`, allowing multiple lines if needed. */ -exports.enable(load()); +formatters.O = function(v) { + this.inspectOpts.colors = this.useColors; + return util.inspect(v, this.inspectOpts); +}; From ab5083f68a7e4c1ab474ff06cd5995d706abf143 Mon Sep 17 00:00:00 2001 From: Arnaud Benhamdine Date: Wed, 8 Nov 2017 23:24:04 +0100 Subject: [PATCH 167/257] Document `enable()` (#517) Document enable, and help to avoid pitfall of https://github.com/visionmedia/debug/issues/425 --- README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/README.md b/README.md index 8e754d17..8a3b70bf 100644 --- a/README.md +++ b/README.md @@ -248,6 +248,41 @@ error('now goes to stdout via console.info'); log('still goes to stdout, but via console.info now'); ``` +## Set dynamically + +You can also enable debug dynamically by calling the `enable()` method : + +```js +let debug = require('debug'); + +console.log(1, debug.enabled('test')); + +debug.enable('test'); +console.log(2, debug.enabled('test')); + +debug.disable(); +console.log(3, debug.enabled('test')); + +``` + +print : +``` +1 false +2 true +3 false +``` + +Usage : +`enable(namespaces)` +`namespaces` can include modes separated by a colon and wildcards. + +Note that calling `enable()` completely overrides previously set DEBUG variable : + +``` +$ DEBUG=foo node -e 'var dbg = require("debug"); dbg.enable("bar"); console.log(dbg.enabled("foo"))' +=> false +``` + ## Checking whether a debug target is enabled After you've created a debug instance, you can determine whether or not it is From 285dfe10a5c06d4a86176b54bef2d7591eedaf40 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Thu, 9 Nov 2017 12:35:02 -0800 Subject: [PATCH 168/257] fix colors with `supports-color@5` --- src/node.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node.js b/src/node.js index b32d831a..c13b932c 100644 --- a/src/node.js +++ b/src/node.js @@ -24,7 +24,7 @@ exports.colors = [ 6, 2, 3, 4, 5, 1 ]; try { var supportsColor = require('supports-color'); - if (supportsColor && supportsColor.level >= 2) { + if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) { exports.colors = [ 20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 62, 63, 68, 69, 74, 75, 76, 77, 78, 79, 80, 81, 92, 93, 98, 99, 112, 113, 128, 129, 134, From a5ca7a20860e78a4ea47f80770c09c0c663bae1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Rodr=C3=ADguez=20Baquero?= Date: Tue, 5 Dec 2017 19:51:50 -0500 Subject: [PATCH 169/257] Update .npmignore (#527) Don't upload to npm unneeded files --- .npmignore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.npmignore b/.npmignore index 5f60eecc..9c93383c 100644 --- a/.npmignore +++ b/.npmignore @@ -7,3 +7,9 @@ dist yarn.lock coverage bower.json +.coveralls.yml +.eslintrc +.travis.yml +.npmignore +karma.conf.js +Makefile From 22f993216dcdcee07eb0601ea71a917e4925a30a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rouven=20We=C3=9Fling?= Date: Sun, 7 Jan 2018 22:45:57 +0100 Subject: [PATCH 170/257] Update ms to 2.1.1 (#539) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ada43cfe..9af3874d 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ ], "license": "MIT", "dependencies": { - "ms": "2.0.0" + "ms": "^2.1.1" }, "devDependencies": { "browserify": "14.4.0", From 225c66f7198d2995e8232f9486aa9e087dc2a469 Mon Sep 17 00:00:00 2001 From: Alexey Pelykh Date: Fri, 20 Apr 2018 17:48:41 +0300 Subject: [PATCH 171/257] Detect 'process' package --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index cabcbcda..9b44b967 100644 --- a/src/index.js +++ b/src/index.js @@ -3,7 +3,7 @@ * treat as a browser. */ -if (typeof process === 'undefined' || process.type === 'renderer') { +if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true) { module.exports = require('./browser.js'); } else { module.exports = require('./node.js'); From 1ad1e4a79ff36981c1972bb4e61f93c7d4ade68d Mon Sep 17 00:00:00 2001 From: KyleStay Date: Wed, 20 Jun 2018 18:49:49 -0400 Subject: [PATCH 172/257] Improve usability of Windows notes w/ examples for prompts & npm script (#577) * Improve usability of Windows notes w/ examples for prompts & npm script * Made changes requested for pull request https://github.com/visionmedia/debug/pull/577#pullrequestreview-130549763 --- README.md | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8a3b70bf..b9f4b49a 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,9 @@ Here are some examples: screen shot 2017-08-08 at 12 53 38 pm screen shot 2017-08-08 at 12 53 25 pm -#### Windows note +#### Windows command prompt notes + +##### CMD On Windows the environment variable is set using the `set` command. @@ -78,14 +80,32 @@ On Windows the environment variable is set using the `set` command. set DEBUG=*,-not_this ``` -Note that PowerShell uses different syntax to set environment variables. +Example: + +```cmd +set DEBUG=* & node app.js +``` + +##### PowerShell (VS Code default) + +PowerShell uses different syntax to set environment variables. ```cmd $env:DEBUG = "*,-not_this" ``` +Example: + +```cmd +$env:DEBUG='app';node app.js +``` + Then, run the program to be debugged as usual. +npm script example: +```js + "windowsDebug": "@powershell -Command $env:DEBUG='*';node app.js", +``` ## Namespace Colors From 02b9ea9fd7ec95c42de47da13b4b6bb8e50025d8 Mon Sep 17 00:00:00 2001 From: Frank Febbraro Date: Thu, 21 Jun 2018 13:13:12 -0700 Subject: [PATCH 173/257] Add TVMLKit support (#579) * Adding TVMLKit support * removed the check for window/navigationDocument, instead relying on localStorage in the global context on all 'browser' based platforms --- src/browser.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/browser.js b/src/browser.js index a4f1fcb6..4d61d080 100644 --- a/src/browser.js +++ b/src/browser.js @@ -126,7 +126,7 @@ function save(namespaces) { if (null == namespaces) { exports.storage.removeItem('debug'); } else { - exports.storage.debug = namespaces; + exports.storage.setItem('debug', namespaces); } } catch(e) {} } @@ -141,7 +141,7 @@ function save(namespaces) { function load() { var r; try { - r = exports.storage.debug; + r = exports.storage.getItem('debug'); } catch(e) {} // If debug isn't set in LS, and we're in Electron, try to load $DEBUG @@ -165,7 +165,9 @@ function load() { function localstorage() { try { - return window.localStorage; + // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context + // The Browser also has localStorage in the global context. + return localStorage; } catch (e) {} } From 05b0ceb8856bc7b6bb0f2adc3de5cae3cea9c872 Mon Sep 17 00:00:00 2001 From: Daniel Ruf Date: Sun, 24 Jun 2018 04:31:31 +0200 Subject: [PATCH 174/257] add Node.js 10, remove Node.js 4 (#583) --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a7643003..05f3dbb2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,9 +3,9 @@ sudo: false language: node_js node_js: - - "4" - "6" - "8" + - "10" install: - make install From 207a6a2d53507ec9dd57c94c46cc7d3dd272306d Mon Sep 17 00:00:00 2001 From: Miau Lightouch Date: Thu, 26 Jul 2018 16:07:10 +0800 Subject: [PATCH 175/257] Fix nwjs support (#569) --- src/browser.js | 2 +- src/index.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/browser.js b/src/browser.js index 4d61d080..b6d94e17 100644 --- a/src/browser.js +++ b/src/browser.js @@ -39,7 +39,7 @@ function useColors() { // NB: In an Electron preload script, document will be defined but not fully // initialized. Since we know we're in Chrome, we'll just detect this case // explicitly - if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') { + if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) { return true; } diff --git a/src/index.js b/src/index.js index 9b44b967..a8792cc1 100644 --- a/src/index.js +++ b/src/index.js @@ -1,9 +1,10 @@ /** - * Detect Electron renderer process, which is node, but we should + * Detect Electron renderer / nwjs process, which is node, but we should * treat as a browser. */ -if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true) { + +if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) { module.exports = require('./browser.js'); } else { module.exports = require('./node.js'); From e43e5fed177b8698674748063f4ed1aaba1d59c8 Mon Sep 17 00:00:00 2001 From: Ruslan Boliev Date: Tue, 11 Sep 2018 06:06:24 +0300 Subject: [PATCH 176/257] add instance extends feature (#524) * instance extends feature * add .extend documentation * allow empty delimiter in extend --- README.md | 14 ++++++++++++++ src/common.js | 5 +++++ test/debug_spec.js | 26 ++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/README.md b/README.md index b9f4b49a..0ee7634d 100644 --- a/README.md +++ b/README.md @@ -268,6 +268,20 @@ error('now goes to stdout via console.info'); log('still goes to stdout, but via console.info now'); ``` +## Extend +You can simply extend debugger +```js +const log = require('debug')('auth'); + +//creates new debug instance with extended namespace +const logSign = log.extend('sign'); +const logLogin = log.extend('login'); + +log('hello'); // auth hello +logSign('hello'); //auth:sign hello +logLogin('hello'); //auth:login hello +``` + ## Set dynamically You can also enable debug dynamically by calling the `enable()` method : diff --git a/src/common.js b/src/common.js index 61eaf893..65713e4d 100644 --- a/src/common.js +++ b/src/common.js @@ -123,6 +123,7 @@ module.exports = function setup(env) { debug.useColors = createDebug.useColors(); debug.color = selectColor(namespace); debug.destroy = destroy; + debug.extend = extend; //debug.formatArgs = formatArgs; //debug.rawLog = rawLog; @@ -146,6 +147,10 @@ module.exports = function setup(env) { } } + function extend (namespace, delimiter) { + return createDebug(this.namespace + (typeof delimiter !== 'undefined' ? delimiter : ':') + namespace); + } + /** * Enables a debug mode by namespaces. This can include modes * separated by a colon and wildcards. diff --git a/test/debug_spec.js b/test/debug_spec.js index 142fbe79..7ac6d7cd 100644 --- a/test/debug_spec.js +++ b/test/debug_spec.js @@ -64,4 +64,30 @@ describe('debug', function () { }); }); + + describe('extend namespace', function () { + var log; + + beforeEach(function () { + debug.enable('foo'); + log = debug('foo'); + }); + + it('should extend namespace', function () { + var logBar = log.extend('bar'); + expect(logBar.namespace).to.be.equal('foo:bar'); + }); + + it('should extend namespace with custom delimiter', function () { + var logBar = log.extend('bar', '--'); + expect(logBar.namespace).to.be.equal('foo--bar'); + }); + + it('should extend namespace with empty delimiter', function () { + var logBar = log.extend('bar', ''); + expect(logBar.namespace).to.be.equal('foobar'); + }); + + }); + }); From 7e1d5d94f31b37b460fb8d88000ab7ed0be3597e Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Mon, 10 Sep 2018 21:33:02 -0600 Subject: [PATCH 177/257] add yarn-error.log to .gitignore --- .gitignore | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index f0cf3a35..15be2208 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,11 @@ .DS_Store -node_modules +node_modules/ *.sock -build +/build/ npm-debug.log -dist -coverage +yarn-error.log +/dist/ +/coverage/ # lockfiles yarn.lock From 853853f9f588044d76df3daf1959ca56c5f341b7 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Mon, 10 Sep 2018 21:33:29 -0600 Subject: [PATCH 178/257] bump vulnerable packages --- package.json | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 9af3874d..4e922381 100644 --- a/package.json +++ b/package.json @@ -24,19 +24,20 @@ "browserify": "14.4.0", "chai": "^3.5.0", "concurrently": "^3.1.0", - "coveralls": "^2.11.15", + "coveralls": "^3.0.2", "eslint": "^3.12.1", "istanbul": "^0.4.5", - "karma": "^1.3.0", + "karma": "^3.0.0", "karma-chai": "^0.1.0", "karma-mocha": "^1.3.0", "karma-phantomjs-launcher": "^1.0.2", "karma-sinon": "^1.0.5", - "mocha": "^3.2.0", + "mocha": "^5.2.0", "mocha-lcov-reporter": "^1.2.0", "rimraf": "^2.5.4", "sinon": "^1.17.6", - "sinon-chai": "^2.8.0" + "sinon-chai": "^2.8.0", + "xo": "^0.23.0" }, "main": "./src/index.js", "browser": "./src/browser.js" From 2d2509e26bf6df1e1954267e3b1a1cb83973fb09 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Mon, 10 Sep 2018 21:46:11 -0600 Subject: [PATCH 179/257] add .editorconfig --- .editorconfig | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..a2be8159 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,37 @@ +root = true + +[*] +indent_style = tab +indent_size = 4 +tab_width = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[{*.json,*.json.example,*.gyp,*.yml,*.yaml}] +indent_style = space +indent_size = 2 + +[{*.py,*.asm}] +indent_style = space + +[*.py] +indent_size = 4 + +[*.asm] +indent_size = 8 + +[*.md] +trim_trailing_whitespace = false + +# Ideal settings - some plugins might support these. +[*.js] +quote_type = single + +[{*.c,*.cc,*.h,*.hh,*.cpp,*.hpp,*.m,*.mm,*.mpp,*.js,*.java,*.go,*.rs,*.php,*.ng,*.jsx,*.ts,*.d,*.cs,*.swift}] +curly_bracket_next_line = false +spaces_around_operators = true +spaces_around_brackets = outside +# close enough to 1TB +indent_brace_style = K&R From ba8a424d41e9dc6129e081ac3aa9715be6a45fbd Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Mon, 10 Sep 2018 22:04:31 -0600 Subject: [PATCH 180/257] move to XO (closes #397) --- examples/node/app.js | 23 +- examples/node/colors.js | 10 +- examples/node/stdout.js | 15 +- examples/node/wildcards.js | 14 +- examples/node/worker.js | 17 +- karma.conf.js | 124 +++++----- package.json | 3 + src/browser.js | 276 ++++++++++++++-------- src/common.js | 471 +++++++++++++++++++------------------ src/index.js | 5 +- src/node.js | 236 ++++++++++++------- test/debug-spec.js | 92 ++++++++ test/debug_spec.js | 93 -------- 13 files changed, 766 insertions(+), 613 deletions(-) create mode 100644 test/debug-spec.js delete mode 100644 test/debug_spec.js diff --git a/examples/node/app.js b/examples/node/app.js index d4a19914..08d3f257 100644 --- a/examples/node/app.js +++ b/examples/node/app.js @@ -1,19 +1,20 @@ +const http = require('http'); -var debug = require('../../')('http') - , http = require('http') - , name = 'My App'; +const debug = require('../..')('http'); -// fake app +const name = 'My App'; + +// Fake app debug('booting %o', name); -http.createServer(function(req, res){ - debug(req.method + ' ' + req.url); - res.end('hello\n'); -}).listen(3000, function(){ - debug('listening'); +http.createServer((req, res) => { + debug(req.method + ' ' + req.url); + res.end('hello\n'); +}).listen(3000, () => { + debug('listening'); }); -// fake worker of some kind - +// Fake worker of some kind +// eslint-disable-next-line import/no-unassigned-import require('./worker'); diff --git a/examples/node/colors.js b/examples/node/colors.js index c144ee4e..9cbfa1f9 100644 --- a/examples/node/colors.js +++ b/examples/node/colors.js @@ -1,8 +1,8 @@ -var debug = require('../../') +const debug = require('../..'); -debug.enable('*') +debug.enable('*'); -for (var i=0; i < debug.colors.length; i++) { - const d = debug('example:' + i); - d('The color is %o', d.color); +for (let i = 0; i < debug.colors.length; i++) { + const d = debug('example:' + i); + d('The color is %o', d.color); } diff --git a/examples/node/stdout.js b/examples/node/stdout.js index c999c4c0..17558da0 100644 --- a/examples/node/stdout.js +++ b/examples/node/stdout.js @@ -1,16 +1,17 @@ -var debug = require('../../'); -var error = debug('app:error'); +const debug = require('../..'); -// by default stderr is used +const error = debug('app:error'); + +// By default stderr is used error('goes to stderr!'); -var log = debug('app:log'); -// set this namespace to log via console.log -log.log = console.log.bind(console); // don't forget to bind to console! +const log = debug('app:log'); +// Set this namespace to log via console.log +log.log = console.log.bind(console); // Don't forget to bind to console! log('goes to stdout'); error('still goes to stderr!'); -// set all output to go via console.info +// Set all output to go via console.info // overrides all per-namespace log settings debug.log = console.info.bind(console); error('now goes to stdout via console.info'); diff --git a/examples/node/wildcards.js b/examples/node/wildcards.js index ca99aeff..2cedc2d8 100644 --- a/examples/node/wildcards.js +++ b/examples/node/wildcards.js @@ -1,10 +1,10 @@ -var debug = { - foo: require('../../')('test:foo'), - bar: require('../../')('test:bar'), - baz: require('../../')('test:baz') +const debug = { + foo: require('../..')('test:foo'), + bar: require('../..')('test:bar'), + baz: require('../..')('test:baz') }; -debug.foo('foo') -debug.bar('bar') -debug.baz('baz') +debug.foo('foo'); +debug.bar('bar'); +debug.baz('baz'); diff --git a/examples/node/worker.js b/examples/node/worker.js index 07e3bc59..6f483a66 100644 --- a/examples/node/worker.js +++ b/examples/node/worker.js @@ -4,23 +4,24 @@ // DEBUG=worker:a node example/worker // DEBUG=worker:b node example/worker -var a = require('../../')('worker:a') - , b = require('../../')('worker:b'); +const a = require('../..')('worker:a'); + +const b = require('../..')('worker:b'); function work() { - a('doing lots of uninteresting work'); - setTimeout(work, Math.random() * 1000); + a('doing lots of uninteresting work'); + setTimeout(work, Math.random() * 1000); } work(); function workb() { - b('doing some work'); - setTimeout(workb, Math.random() * 2000); + b('doing some work'); + setTimeout(workb, Math.random() * 2000); } workb(); -setTimeout(function(){ - b(new Error('fail')); +setTimeout(() => { + b(new Error('fail')); }, 5000); diff --git a/karma.conf.js b/karma.conf.js index 103a82d1..82f90691 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,70 +1,60 @@ // Karma configuration // Generated on Fri Dec 16 2016 13:09:51 GMT+0000 (UTC) -module.exports = function(config) { - config.set({ - - // base path that will be used to resolve all patterns (eg. files, exclude) - basePath: '', - - - // frameworks to use - // available frameworks: https://npmjs.org/browse/keyword/karma-adapter - frameworks: ['mocha', 'chai', 'sinon'], - - - // list of files / patterns to load in the browser - files: [ - 'dist/debug.js', - 'test/*spec.js' - ], - - - // list of files to exclude - exclude: [ - 'src/node.js' - ], - - - // preprocess matching files before serving them to the browser - // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor - preprocessors: { - }, - - // test results reporter to use - // possible values: 'dots', 'progress' - // available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: ['progress'], - - - // web server port - port: 9876, - - - // enable / disable colors in the output (reporters and logs) - colors: true, - - - // level of logging - // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG - logLevel: config.LOG_INFO, - - - // enable / disable watching file and executing tests whenever any file changes - autoWatch: true, - - - // start these browsers - // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: ['PhantomJS'], - - - // Continuous Integration mode - // if true, Karma captures browsers, runs the tests and exits - singleRun: false, - - // Concurrency level - // how many browser should be started simultaneous - concurrency: Infinity - }) -} +module.exports = function (config) { + config.set({ + + // Base path that will be used to resolve all patterns (eg. files, exclude) + basePath: '', + + // Frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ['mocha', 'chai', 'sinon'], + + // List of files / patterns to load in the browser + files: [ + 'dist/debug.js', + 'test/*spec.js' + ], + + // List of files to exclude + exclude: [ + 'src/node.js' + ], + + // Preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + }, + + // Test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ['progress'], + + // Web server port + port: 9876, + + // Enable / disable colors in the output (reporters and logs) + colors: true, + + // Level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, + + // Enable / disable watching file and executing tests whenever any file changes + autoWatch: true, + + // Start these browsers + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + browsers: ['PhantomJS'], + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: false, + + // Concurrency level + // how many browser should be started simultaneous + concurrency: Infinity + }); +}; diff --git a/package.json b/package.json index 4e922381..1f9b3640 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,9 @@ "url": "git://github.com/visionmedia/debug.git" }, "description": "small debugging utility", + "scripts": { + "test": "xo && mocha" + }, "keywords": [ "debug", "log", diff --git a/src/browser.js b/src/browser.js index b6d94e17..5f34c0d0 100644 --- a/src/browser.js +++ b/src/browser.js @@ -1,3 +1,5 @@ +/* eslint-env browser */ + /** * This is the web browser implementation of `debug()`. */ @@ -14,17 +16,82 @@ exports.storage = localstorage(); */ exports.colors = [ - '#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', - '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', - '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', - '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', - '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', - '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', - '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', - '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', - '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', - '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', - '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33' + '#0000CC', + '#0000FF', + '#0033CC', + '#0033FF', + '#0066CC', + '#0066FF', + '#0099CC', + '#0099FF', + '#00CC00', + '#00CC33', + '#00CC66', + '#00CC99', + '#00CCCC', + '#00CCFF', + '#3300CC', + '#3300FF', + '#3333CC', + '#3333FF', + '#3366CC', + '#3366FF', + '#3399CC', + '#3399FF', + '#33CC00', + '#33CC33', + '#33CC66', + '#33CC99', + '#33CCCC', + '#33CCFF', + '#6600CC', + '#6600FF', + '#6633CC', + '#6633FF', + '#66CC00', + '#66CC33', + '#9900CC', + '#9900FF', + '#9933CC', + '#9933FF', + '#99CC00', + '#99CC33', + '#CC0000', + '#CC0033', + '#CC0066', + '#CC0099', + '#CC00CC', + '#CC00FF', + '#CC3300', + '#CC3333', + '#CC3366', + '#CC3399', + '#CC33CC', + '#CC33FF', + '#CC6600', + '#CC6633', + '#CC9900', + '#CC9933', + '#CCCC00', + '#CCCC33', + '#FF0000', + '#FF0033', + '#FF0066', + '#FF0099', + '#FF00CC', + '#FF00FF', + '#FF3300', + '#FF3333', + '#FF3366', + '#FF3399', + '#FF33CC', + '#FF33FF', + '#FF6600', + '#FF6633', + '#FF9900', + '#FF9933', + '#FFCC00', + '#FFCC33' ]; /** @@ -35,29 +102,30 @@ exports.colors = [ * TODO: add a `localStorage` variable to explicitly enable/disable colors */ +// eslint-disable-next-line complexity function useColors() { - // NB: In an Electron preload script, document will be defined but not fully - // initialized. Since we know we're in Chrome, we'll just detect this case - // explicitly - if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) { - return true; - } - - // Internet Explorer and Edge do not support colors. - if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { - return false; - } - - // is webkit? http://stackoverflow.com/a/16459606/376773 - // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 - return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || - // is firebug? http://stackoverflow.com/a/398120/376773 - (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || - // is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || - // double check webkit in userAgent just in case we are in a worker - (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); + // NB: In an Electron preload script, document will be defined but not fully + // initialized. Since we know we're in Chrome, we'll just detect this case + // explicitly + if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) { + return true; + } + + // Internet Explorer and Edge do not support colors. + if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { + return false; + } + + // Is webkit? http://stackoverflow.com/a/16459606/376773 + // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 + return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || + // Is firebug? http://stackoverflow.com/a/398120/376773 + (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || + // Is firefox >= v31? + // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || + // Double check webkit in userAgent just in case we are in a worker + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); } /** @@ -67,36 +135,38 @@ function useColors() { */ function formatArgs(args) { - var useColors = this.useColors; - - args[0] = (useColors ? '%c' : '') - + this.namespace - + (useColors ? ' %c' : ' ') - + args[0] - + (useColors ? '%c ' : ' ') - + '+' + module.exports.humanize(this.diff); - - if (!useColors) return; - - var c = 'color: ' + this.color; - args.splice(1, 0, c, 'color: inherit') - - // the final "%c" is somewhat tricky, because there could be other - // arguments passed either before or after the %c, so we need to - // figure out the correct index to insert the CSS into - var index = 0; - var lastC = 0; - args[0].replace(/%[a-zA-Z%]/g, function(match) { - if ('%%' === match) return; - index++; - if ('%c' === match) { - // we only are interested in the *last* %c - // (the user may have provided their own) - lastC = index; - } - }); - - args.splice(lastC, 0, c); + args[0] = (this.useColors ? '%c' : '') + + this.namespace + + (this.useColors ? ' %c' : ' ') + + args[0] + + (this.useColors ? '%c ' : ' ') + + '+' + module.exports.humanize(this.diff); + + if (!this.useColors) { + return; + } + + const c = 'color: ' + this.color; + args.splice(1, 0, c, 'color: inherit'); + + // The final "%c" is somewhat tricky, because there could be other + // arguments passed either before or after the %c, so we need to + // figure out the correct index to insert the CSS into + let index = 0; + let lastC = 0; + args[0].replace(/%[a-zA-Z%]/g, match => { + if (match === '%%') { + return; + } + index++; + if (match === '%c') { + // We only are interested in the *last* %c + // (the user may have provided their own) + lastC = index; + } + }); + + args.splice(lastC, 0, c); } /** @@ -105,13 +175,12 @@ function formatArgs(args) { * * @api public */ - -function log() { - // this hackery is required for IE8/9, where - // the `console.log` function doesn't have 'apply' - return 'object' === typeof console - && console.log - && Function.prototype.apply.call(console.log, console, arguments); +function log(...args) { + // This hackery is required for IE8/9, where + // the `console.log` function doesn't have 'apply' + return typeof console === 'object' && + console.log && + console.log(...args); } /** @@ -120,15 +189,17 @@ function log() { * @param {String} namespaces * @api private */ - function save(namespaces) { - try { - if (null == namespaces) { - exports.storage.removeItem('debug'); - } else { - exports.storage.setItem('debug', namespaces); - } - } catch(e) {} + try { + if (namespaces) { + exports.storage.setItem('debug', namespaces); + } else { + exports.storage.removeItem('debug'); + } + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } } /** @@ -137,19 +208,21 @@ function save(namespaces) { * @return {String} returns the previously persisted debug modes * @api private */ - function load() { - var r; - try { - r = exports.storage.getItem('debug'); - } catch(e) {} + let r; + try { + r = exports.storage.getItem('debug'); + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } - // If debug isn't set in LS, and we're in Electron, try to load $DEBUG - if (!r && typeof process !== 'undefined' && 'env' in process) { - r = process.env.DEBUG; - } + // If debug isn't set in LS, and we're in Electron, try to load $DEBUG + if (!r && typeof process !== 'undefined' && 'env' in process) { + r = process.env.DEBUG; + } - return r; + return r; } /** @@ -164,25 +237,28 @@ function load() { */ function localstorage() { - try { - // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context - // The Browser also has localStorage in the global context. - return localStorage; - } catch (e) {} + try { + // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context + // The Browser also has localStorage in the global context. + return localStorage; + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } } module.exports = require('./common')(exports); -var formatters = module.exports.formatters; +const {formatters} = module.exports; /** * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. */ -formatters.j = function(v) { - try { - return JSON.stringify(v); - } catch (err) { - return '[UnexpectedJSONParseError]: ' + err.message; - } +formatters.j = function (v) { + try { + return JSON.stringify(v); + } catch (error) { + return '[UnexpectedJSONParseError]: ' + error.message; + } }; diff --git a/src/common.js b/src/common.js index 65713e4d..dab9e480 100644 --- a/src/common.js +++ b/src/common.js @@ -4,237 +4,242 @@ * implementations of `debug()`. */ -module.exports = function setup(env) { - createDebug.debug = createDebug['default'] = createDebug; - createDebug.coerce = coerce; - createDebug.disable = disable; - createDebug.enable = enable; - createDebug.enabled = enabled; - createDebug.humanize = require('ms'); - - Object.keys(env).forEach(function(key) { - createDebug[key] = env[key]; - }); - - /** - * Active `debug` instances. - */ - createDebug.instances = []; - - /** - * The currently active debug mode names, and names to skip. - */ - - createDebug.names = []; - createDebug.skips = []; - - /** - * Map of special "%n" handling functions, for the debug "format" argument. - * - * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". - */ - - createDebug.formatters = {}; - - /** - * Select a color. - * @param {String} namespace - * @return {Number} - * @api private - */ - - function selectColor(namespace) { - var hash = 0, i; - - for (i in namespace) { - hash = ((hash << 5) - hash) + namespace.charCodeAt(i); - hash |= 0; // Convert to 32bit integer - } - - return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; - } - createDebug.selectColor = selectColor; - - /** - * Create a debugger with the given `namespace`. - * - * @param {String} namespace - * @return {Function} - * @api public - */ - - function createDebug(namespace) { - var prevTime; - - function debug() { - // disabled? - if (!debug.enabled) return; - - var self = debug; - - // set `diff` timestamp - var curr = +new Date(); - var ms = curr - (prevTime || curr); - self.diff = ms; - self.prev = prevTime; - self.curr = curr; - prevTime = curr; - - // turn the `arguments` into a proper Array - var args = new Array(arguments.length); - for (var i = 0; i < args.length; i++) { - args[i] = arguments[i]; - } - - args[0] = createDebug.coerce(args[0]); - - if ('string' !== typeof args[0]) { - // anything else let's inspect with %O - args.unshift('%O'); - } - - // apply any `formatters` transformations - var index = 0; - args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) { - // if we encounter an escaped % then don't increase the array index - if (match === '%%') return match; - index++; - var formatter = createDebug.formatters[format]; - if ('function' === typeof formatter) { - var val = args[index]; - match = formatter.call(self, val); - - // now we need to remove `args[index]` since it's inlined in the `format` - args.splice(index, 1); - index--; - } - return match; - }); - - // apply env-specific formatting (colors, etc.) - createDebug.formatArgs.call(self, args); - - var logFn = self.log || createDebug.log; - logFn.apply(self, args); - } - - debug.namespace = namespace; - debug.enabled = createDebug.enabled(namespace); - debug.useColors = createDebug.useColors(); - debug.color = selectColor(namespace); - debug.destroy = destroy; - debug.extend = extend; - //debug.formatArgs = formatArgs; - //debug.rawLog = rawLog; - - // env-specific initialization logic for debug instances - if ('function' === typeof createDebug.init) { - createDebug.init(debug); - } - - createDebug.instances.push(debug); - - return debug; - } - - function destroy () { - var index = createDebug.instances.indexOf(this); - if (index !== -1) { - createDebug.instances.splice(index, 1); - return true; - } else { - return false; - } - } - - function extend (namespace, delimiter) { - return createDebug(this.namespace + (typeof delimiter !== 'undefined' ? delimiter : ':') + namespace); - } - - /** - * Enables a debug mode by namespaces. This can include modes - * separated by a colon and wildcards. - * - * @param {String} namespaces - * @api public - */ - - function enable(namespaces) { - createDebug.save(namespaces); - - createDebug.names = []; - createDebug.skips = []; - - var i; - var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); - var len = split.length; - - for (i = 0; i < len; i++) { - if (!split[i]) continue; // ignore empty strings - namespaces = split[i].replace(/\*/g, '.*?'); - if (namespaces[0] === '-') { - createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); - } else { - createDebug.names.push(new RegExp('^' + namespaces + '$')); - } - } - - for (i = 0; i < createDebug.instances.length; i++) { - var instance = createDebug.instances[i]; - instance.enabled = createDebug.enabled(instance.namespace); - } - } - - /** - * Disable debug output. - * - * @api public - */ - - function disable() { - createDebug.enable(''); - } - - /** - * Returns true if the given mode name is enabled, false otherwise. - * - * @param {String} name - * @return {Boolean} - * @api public - */ - - function enabled(name) { - if (name[name.length - 1] === '*') { - return true; - } - var i, len; - for (i = 0, len = createDebug.skips.length; i < len; i++) { - if (createDebug.skips[i].test(name)) { - return false; - } - } - for (i = 0, len = createDebug.names.length; i < len; i++) { - if (createDebug.names[i].test(name)) { - return true; - } - } - return false; - } - - /** - * Coerce `val`. - * - * @param {Mixed} val - * @return {Mixed} - * @api private - */ - - function coerce(val) { - if (val instanceof Error) return val.stack || val.message; - return val; - } - - createDebug.enable(createDebug.load()); - - return createDebug; +function setup(env) { + createDebug.debug = createDebug; + createDebug.default = createDebug; + createDebug.coerce = coerce; + createDebug.disable = disable; + createDebug.enable = enable; + createDebug.enabled = enabled; + createDebug.humanize = require('ms'); + + Object.keys(env).forEach(key => { + createDebug[key] = env[key]; + }); + + /** + * Active `debug` instances. + */ + createDebug.instances = []; + + /** + * The currently active debug mode names, and names to skip. + */ + + createDebug.names = []; + createDebug.skips = []; + + /** + * Map of special "%n" handling functions, for the debug "format" argument. + * + * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". + */ + createDebug.formatters = {}; + + /** + * Selects a color for a debug namespace + * @param {String} namespace The namespace string for the for the debug instance to be colored + * @return {Number|String} An ANSI color code for the given namespace + * @api private + */ + function selectColor(namespace) { + let hash = 0; + + for (let i = 0; i < namespace.length; i++) { + hash = ((hash << 5) - hash) + namespace.charCodeAt(i); + hash |= 0; // Convert to 32bit integer + } + + return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; + } + createDebug.selectColor = selectColor; + + /** + * Create a debugger with the given `namespace`. + * + * @param {String} namespace + * @return {Function} + * @api public + */ + function createDebug(namespace) { + let prevTime; + + function debug(...args) { + // Disabled? + if (!debug.enabled) { + return; + } + + const self = debug; + + // Set `diff` timestamp + const curr = Number(new Date()); + const ms = curr - (prevTime || curr); + self.diff = ms; + self.prev = prevTime; + self.curr = curr; + prevTime = curr; + + args[0] = createDebug.coerce(args[0]); + + if (typeof args[0] !== 'string') { + // Anything else let's inspect with %O + args.unshift('%O'); + } + + // Apply any `formatters` transformations + let index = 0; + args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { + // If we encounter an escaped % then don't increase the array index + if (match === '%%') { + return match; + } + index++; + const formatter = createDebug.formatters[format]; + if (typeof formatter === 'function') { + const val = args[index]; + match = formatter.call(self, val); + + // Now we need to remove `args[index]` since it's inlined in the `format` + args.splice(index, 1); + index--; + } + return match; + }); + + // Apply env-specific formatting (colors, etc.) + createDebug.formatArgs.call(self, args); + + const logFn = self.log || createDebug.log; + logFn.apply(self, args); + } + + debug.namespace = namespace; + debug.enabled = createDebug.enabled(namespace); + debug.useColors = createDebug.useColors(); + debug.color = selectColor(namespace); + debug.destroy = destroy; + debug.extend = extend; + // Debug.formatArgs = formatArgs; + // debug.rawLog = rawLog; + + // env-specific initialization logic for debug instances + if (typeof createDebug.init === 'function') { + createDebug.init(debug); + } + + createDebug.instances.push(debug); + + return debug; + } + + function destroy() { + const index = createDebug.instances.indexOf(this); + if (index !== -1) { + createDebug.instances.splice(index, 1); + return true; + } + return false; + } + + function extend(namespace, delimiter) { + return createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace); + } + + /** + * Enables a debug mode by namespaces. This can include modes + * separated by a colon and wildcards. + * + * @param {String} namespaces + * @api public + */ + function enable(namespaces) { + createDebug.save(namespaces); + + createDebug.names = []; + createDebug.skips = []; + + let i; + const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); + const len = split.length; + + for (i = 0; i < len; i++) { + if (!split[i]) { + // ignore empty strings + continue; + } + + namespaces = split[i].replace(/\*/g, '.*?'); + + if (namespaces[0] === '-') { + createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); + } else { + createDebug.names.push(new RegExp('^' + namespaces + '$')); + } + } + + for (i = 0; i < createDebug.instances.length; i++) { + const instance = createDebug.instances[i]; + instance.enabled = createDebug.enabled(instance.namespace); + } + } + + /** + * Disable debug output. + * + * @api public + */ + function disable() { + createDebug.enable(''); + } + + /** + * Returns true if the given mode name is enabled, false otherwise. + * + * @param {String} name + * @return {Boolean} + * @api public + */ + function enabled(name) { + if (name[name.length - 1] === '*') { + return true; + } + + let i; + let len; + + for (i = 0, len = createDebug.skips.length; i < len; i++) { + if (createDebug.skips[i].test(name)) { + return false; + } + } + + for (i = 0, len = createDebug.names.length; i < len; i++) { + if (createDebug.names[i].test(name)) { + return true; + } + } + + return false; + } + + /** + * Coerce `val`. + * + * @param {Mixed} val + * @return {Mixed} + * @api private + */ + function coerce(val) { + if (val instanceof Error) { + return val.stack || val.message; + } + return val; + } + + createDebug.enable(createDebug.load()); + + return createDebug; } + +module.exports = setup; diff --git a/src/index.js b/src/index.js index a8792cc1..bf4c57f2 100644 --- a/src/index.js +++ b/src/index.js @@ -3,9 +3,8 @@ * treat as a browser. */ - if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) { - module.exports = require('./browser.js'); + module.exports = require('./browser.js'); } else { - module.exports = require('./node.js'); + module.exports = require('./node.js'); } diff --git a/src/node.js b/src/node.js index c13b932c..5e1f1541 100644 --- a/src/node.js +++ b/src/node.js @@ -2,8 +2,8 @@ * Module dependencies. */ -var tty = require('tty'); -var util = require('util'); +const tty = require('tty'); +const util = require('util'); /** * This is the Node.js implementation of `debug()`. @@ -20,21 +20,95 @@ exports.useColors = useColors; * Colors. */ -exports.colors = [ 6, 2, 3, 4, 5, 1 ]; +exports.colors = [6, 2, 3, 4, 5, 1]; try { - var supportsColor = require('supports-color'); - if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) { - exports.colors = [ - 20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 62, 63, 68, - 69, 74, 75, 76, 77, 78, 79, 80, 81, 92, 93, 98, 99, 112, 113, 128, 129, 134, - 135, 148, 149, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, - 172, 173, 178, 179, 184, 185, 196, 197, 198, 199, 200, 201, 202, 203, 204, - 205, 206, 207, 208, 209, 214, 215, 220, 221 - ]; - } -} catch (err) { - // swallow - we only care if `supports-color` is available; it doesn't have to be. + // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json) + // eslint-disable-next-line import/no-extraneous-dependencies + const supportsColor = require('supports-color'); + + if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) { + exports.colors = [ + 20, + 21, + 26, + 27, + 32, + 33, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 56, + 57, + 62, + 63, + 68, + 69, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 92, + 93, + 98, + 99, + 112, + 113, + 128, + 129, + 134, + 135, + 148, + 149, + 160, + 161, + 162, + 163, + 164, + 165, + 166, + 167, + 168, + 169, + 170, + 171, + 172, + 173, + 178, + 179, + 184, + 185, + 196, + 197, + 198, + 199, + 200, + 201, + 202, + 203, + 204, + 205, + 206, + 207, + 208, + 209, + 214, + 215, + 220, + 221 + ]; + } +} catch (error) { + // Swallow - we only care if `supports-color` is available; it doesn't have to be. } /** @@ -43,24 +117,31 @@ try { * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js */ -exports.inspectOpts = Object.keys(process.env).filter(function (key) { - return /^debug_/i.test(key); -}).reduce(function (obj, key) { - // camel-case - var prop = key - .substring(6) - .toLowerCase() - .replace(/_([a-z])/g, function (_, k) { return k.toUpperCase() }); - - // coerce string value into JS value - var val = process.env[key]; - if (/^(yes|on|true|enabled)$/i.test(val)) val = true; - else if (/^(no|off|false|disabled)$/i.test(val)) val = false; - else if (val === 'null') val = null; - else val = Number(val); - - obj[prop] = val; - return obj; +exports.inspectOpts = Object.keys(process.env).filter(key => { + return /^debug_/i.test(key); +}).reduce((obj, key) => { + // Camel-case + const prop = key + .substring(6) + .toLowerCase() + .replace(/_([a-z])/g, (_, k) => { + return k.toUpperCase(); + }); + + // Coerce string value into JS value + let val = process.env[key]; + if (/^(yes|on|true|enabled)$/i.test(val)) { + val = true; + } else if (/^(no|off|false|disabled)$/i.test(val)) { + val = false; + } else if (val === 'null') { + val = null; + } else { + val = Number(val); + } + + obj[prop] = val; + return obj; }, {}); /** @@ -68,9 +149,9 @@ exports.inspectOpts = Object.keys(process.env).filter(function (key) { */ function useColors() { - return 'colors' in exports.inspectOpts - ? Boolean(exports.inspectOpts.colors) - : tty.isatty(process.stderr.fd); + return 'colors' in exports.inspectOpts ? + Boolean(exports.inspectOpts.colors) : + tty.isatty(process.stderr.fd); } /** @@ -80,35 +161,33 @@ function useColors() { */ function formatArgs(args) { - var name = this.namespace; - var useColors = this.useColors; - - if (useColors) { - var c = this.color; - var colorCode = '\u001b[3' + (c < 8 ? c : '8;5;' + c); - var prefix = ' ' + colorCode + ';1m' + name + ' ' + '\u001b[0m'; - - args[0] = prefix + args[0].split('\n').join('\n' + prefix); - args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001b[0m'); - } else { - args[0] = getDate() + name + ' ' + args[0]; - } + const {namespace: name, useColors} = this; + + if (useColors) { + const c = this.color; + const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c); + const prefix = ` ${colorCode};1m${name} \u001B[0m`; + + args[0] = prefix + args[0].split('\n').join('\n' + prefix); + args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m'); + } else { + args[0] = getDate() + name + ' ' + args[0]; + } } function getDate() { - if (exports.inspectOpts.hideDate) { - return ''; - } else { - return new Date().toISOString() + ' '; - } + if (exports.inspectOpts.hideDate) { + return ''; + } + return new Date().toISOString() + ' '; } /** * Invokes `util.format()` with the specified arguments and writes to stderr. */ -function log() { - return process.stderr.write(util.format.apply(util, arguments) + '\n'); +function log(...args) { + return process.stderr.write(util.format(...args) + '\n'); } /** @@ -117,15 +196,14 @@ function log() { * @param {String} namespaces * @api private */ - function save(namespaces) { - if (null == namespaces) { - // If you set a process.env field to null or undefined, it gets cast to the - // string 'null' or 'undefined'. Just delete instead. - delete process.env.DEBUG; - } else { - process.env.DEBUG = namespaces; - } + if (namespaces) { + process.env.DEBUG = namespaces; + } else { + // If you set a process.env field to null or undefined, it gets cast to the + // string 'null' or 'undefined'. Just delete instead. + delete process.env.DEBUG; + } } /** @@ -136,7 +214,7 @@ function save(namespaces) { */ function load() { - return process.env.DEBUG; + return process.env.DEBUG; } /** @@ -146,34 +224,34 @@ function load() { * differently for a particular `debug` instance. */ -function init (debug) { - debug.inspectOpts = {}; +function init(debug) { + debug.inspectOpts = {}; - var keys = Object.keys(exports.inspectOpts); - for (var i = 0; i < keys.length; i++) { - debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]]; - } + const keys = Object.keys(exports.inspectOpts); + for (let i = 0; i < keys.length; i++) { + debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]]; + } } module.exports = require('./common')(exports); -var formatters = module.exports.formatters; +const {formatters} = module.exports; /** * Map %o to `util.inspect()`, all on a single line. */ -formatters.o = function(v) { - this.inspectOpts.colors = this.useColors; - return util.inspect(v, this.inspectOpts) - .replace(/\s*\n\s*/g, ' '); +formatters.o = function (v) { + this.inspectOpts.colors = this.useColors; + return util.inspect(v, this.inspectOpts) + .replace(/\s*\n\s*/g, ' '); }; /** * Map %O to `util.inspect()`, allowing multiple lines if needed. */ -formatters.O = function(v) { - this.inspectOpts.colors = this.useColors; - return util.inspect(v, this.inspectOpts); +formatters.O = function (v) { + this.inspectOpts.colors = this.useColors; + return util.inspect(v, this.inspectOpts); }; diff --git a/test/debug-spec.js b/test/debug-spec.js new file mode 100644 index 00000000..08edb3b3 --- /dev/null +++ b/test/debug-spec.js @@ -0,0 +1,92 @@ +/* global describe, it, context, beforeEach */ +'use strict'; + +let chai; + +let expect; + +let debug; + +let sinon; + +let sinonChai; + +if (typeof module !== 'undefined') { + chai = require('chai'); + expect = chai.expect; + + debug = require('../src'); + sinon = require('sinon'); + sinonChai = require('sinon-chai'); + chai.use(sinonChai); +} + +describe('debug', () => { + let log = debug('test'); + + log.log = sinon.stub(); + + it('passes a basic sanity check', () => { + expect(log('hello world')).to.not.throw(); + }); + + it('allows namespaces to be a non-string value', () => { + expect(debug.enable(true)).to.not.throw(); + }); + + context('with log function', () => { + beforeEach(() => { + debug.enable('test'); + log = debug('test'); + }); + + it('uses it', () => { + log.log = sinon.stub(); + log('using custom log function'); + + expect(log.log).to.have.been.calledOnce(); + }); + }); + + describe('custom functions', () => { + let log; + + beforeEach(() => { + debug.enable('test'); + log = debug('test'); + }); + + context('with log function', () => { + it('uses it', () => { + log.log = sinon.spy(); + log('using custom log function'); + + expect(log.log).to.have.been.calledOnce(); + }); + }); + }); + + describe('extend namespace', () => { + let log; + + beforeEach(() => { + debug.enable('foo'); + log = debug('foo'); + }); + + it('should extend namespace', () => { + const logBar = log.extend('bar'); + expect(logBar.namespace).to.be.equal('foo:bar'); + }); + + it('should extend namespace with custom delimiter', () => { + const logBar = log.extend('bar', '--'); + expect(logBar.namespace).to.be.equal('foo--bar'); + }); + + it('should extend namespace with empty delimiter', () => { + const logBar = log.extend('bar', ''); + expect(logBar.namespace).to.be.equal('foobar'); + }); + }); +}); diff --git a/test/debug_spec.js b/test/debug_spec.js deleted file mode 100644 index 7ac6d7cd..00000000 --- a/test/debug_spec.js +++ /dev/null @@ -1,93 +0,0 @@ -/* global describe, it, context, beforeEach */ -'use strict'; - -var chai - , expect - , debug - , sinon - , sinonChai; - -if (typeof module !== 'undefined') { - chai = require('chai'); - expect = chai.expect; - - debug = require('../src/index'); - sinon = require('sinon'); - sinonChai = require("sinon-chai"); - chai.use(sinonChai); -} - - -describe('debug', function () { - var log = debug('test'); - - log.log = sinon.stub(); - - it('passes a basic sanity check', function () { - expect(log('hello world')).to.not.throw; - }); - - it('allows namespaces to be a non-string value', function () { - expect(debug.enable(true)).to.not.throw; - }); - - context('with log function', function () { - - beforeEach(function () { - debug.enable('test'); - log = debug('test'); - }); - - it('uses it', function () { - log.log = sinon.stub(); - log('using custom log function'); - - expect(log.log).to.have.been.calledOnce; - }); - }); - - describe('custom functions', function () { - var log; - - beforeEach(function () { - debug.enable('test'); - log = debug('test'); - }); - - context('with log function', function () { - it('uses it', function () { - log.log = sinon.spy(); - log('using custom log function'); - - expect(log.log).to.have.been.calledOnce; - }); - }); - }); - - - describe('extend namespace', function () { - var log; - - beforeEach(function () { - debug.enable('foo'); - log = debug('foo'); - }); - - it('should extend namespace', function () { - var logBar = log.extend('bar'); - expect(logBar.namespace).to.be.equal('foo:bar'); - }); - - it('should extend namespace with custom delimiter', function () { - var logBar = log.extend('bar', '--'); - expect(logBar.namespace).to.be.equal('foo--bar'); - }); - - it('should extend namespace with empty delimiter', function () { - var logBar = log.extend('bar', ''); - expect(logBar.namespace).to.be.equal('foobar'); - }); - - }); - -}); From 833b6f84c8f8dc5b6f13da38ab0ef8a8ff86c0c9 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Mon, 10 Sep 2018 22:34:47 -0600 Subject: [PATCH 181/257] fix tests --- package.json | 3 -- test/debug-spec.js | 84 +++++++++++++++++++++------------------------- 2 files changed, 38 insertions(+), 49 deletions(-) diff --git a/package.json b/package.json index 1f9b3640..1907cda9 100644 --- a/package.json +++ b/package.json @@ -34,12 +34,9 @@ "karma-chai": "^0.1.0", "karma-mocha": "^1.3.0", "karma-phantomjs-launcher": "^1.0.2", - "karma-sinon": "^1.0.5", "mocha": "^5.2.0", "mocha-lcov-reporter": "^1.2.0", "rimraf": "^2.5.4", - "sinon": "^1.17.6", - "sinon-chai": "^2.8.0", "xo": "^0.23.0" }, "main": "./src/index.js", diff --git a/test/debug-spec.js b/test/debug-spec.js index 08edb3b3..6862497e 100644 --- a/test/debug-spec.js +++ b/test/debug-spec.js @@ -1,4 +1,4 @@ -/* global describe, it, context, beforeEach */ +/* eslint-env mocha */ 'use strict'; let chai; @@ -7,84 +7,76 @@ let expect; let debug; -let sinon; - -let sinonChai; - if (typeof module !== 'undefined') { chai = require('chai'); expect = chai.expect; - debug = require('../src'); - sinon = require('sinon'); - sinonChai = require('sinon-chai'); - chai.use(sinonChai); } describe('debug', () => { - let log = debug('test'); - - log.log = sinon.stub(); - it('passes a basic sanity check', () => { - expect(log('hello world')).to.not.throw(); + const log = debug('test'); + log.enabled = true; + log.log = () => {}; + + expect(() => log('hello world')).to.not.throw(); }); it('allows namespaces to be a non-string value', () => { - expect(debug.enable(true)).to.not.throw(); - }); + const log = debug('test'); + log.enabled = true; + log.log = () => {}; - context('with log function', () => { - beforeEach(() => { - debug.enable('test'); - log = debug('test'); - }); + expect(() => debug.enable(true)).to.not.throw(); + }); - it('uses it', () => { - log.log = sinon.stub(); - log('using custom log function'); + it('honors global debug namespace enable calls', () => { + expect(debug('test:12345').enabled).to.equal(false); + expect(debug('test:67890').enabled).to.equal(false); - expect(log.log).to.have.been.calledOnce(); - }); + debug.enable('test:12345'); + expect(debug('test:12345').enabled).to.equal(true); + expect(debug('test:67890').enabled).to.equal(false); }); - describe('custom functions', () => { - let log; + it('uses custom log function', () => { + const log = debug('test'); + log.enabled = true; - beforeEach(() => { - debug.enable('test'); - log = debug('test'); - }); + const messages = []; + log.log = (...args) => messages.push(args); - context('with log function', () => { - it('uses it', () => { - log.log = sinon.spy(); - log('using custom log function'); + log('using custom log function'); + log('using custom log function again'); + log('%O', 12345); - expect(log.log).to.have.been.calledOnce(); - }); - }); + expect(messages.length).to.equal(3); }); describe('extend namespace', () => { - let log; - - beforeEach(() => { - debug.enable('foo'); - log = debug('foo'); - }); - it('should extend namespace', () => { + const log = debug('foo'); + log.enabled = true; + log.log = () => {}; + const logBar = log.extend('bar'); expect(logBar.namespace).to.be.equal('foo:bar'); }); it('should extend namespace with custom delimiter', () => { + const log = debug('foo'); + log.enabled = true; + log.log = () => {}; + const logBar = log.extend('bar', '--'); expect(logBar.namespace).to.be.equal('foo--bar'); }); it('should extend namespace with empty delimiter', () => { + const log = debug('foo'); + log.enabled = true; + log.log = () => {}; + const logBar = log.extend('bar', ''); expect(logBar.namespace).to.be.equal('foobar'); }); From 62822f12668e8a0b1d1a4fd5a1c2fce1d8715da3 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Mon, 10 Sep 2018 22:43:04 -0600 Subject: [PATCH 182/257] clean up makefile --- Makefile | 30 +++++++----------------------- package.json | 4 ---- 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index 3ddd1360..48e66bc7 100644 --- a/Makefile +++ b/Makefile @@ -15,22 +15,16 @@ YARN ?= $(shell which yarn) PKG ?= $(if $(YARN),$(YARN),$(NODE) $(shell which npm)) BROWSERIFY ?= $(NODE) $(BIN)/browserify -install: node_modules +all: lint test browser: dist/debug.js -node_modules: package.json - @NODE_ENV= $(PKG) install - @touch node_modules - -dist/debug.js: src/*.js node_modules +dist/debug.js: src/*.js @mkdir -p dist - @$(BROWSERIFY) \ - --standalone debug \ - . > dist/debug.js + @$(BROWSERIFY) --standalone debug . > dist/debug.js lint: - @eslint *.js src/*.js + @xo test-node: @istanbul cover node_modules/mocha/bin/_mocha -- test/**.js @@ -40,19 +34,9 @@ test-browser: @$(MAKE) browser @karma start --single-run -test-all: - @concurrently \ - "make test-node" \ - "make test-browser" - -test: - @if [ "x$(BROWSER)" = "x" ]; then \ - $(MAKE) test-node; \ - else \ - $(MAKE) test-browser; \ - fi +test: test-node test-browser clean: - rimraf dist coverage + rm -rf dist coverage -.PHONY: browser install clean lint test test-all test-node test-browser +.PHONY: all browser install clean lint test test-node test-browser diff --git a/package.json b/package.json index 1907cda9..c6f613c2 100644 --- a/package.json +++ b/package.json @@ -6,9 +6,6 @@ "url": "git://github.com/visionmedia/debug.git" }, "description": "small debugging utility", - "scripts": { - "test": "xo && mocha" - }, "keywords": [ "debug", "log", @@ -28,7 +25,6 @@ "chai": "^3.5.0", "concurrently": "^3.1.0", "coveralls": "^3.0.2", - "eslint": "^3.12.1", "istanbul": "^0.4.5", "karma": "^3.0.0", "karma-chai": "^0.1.0", From 57cde56e43003f6b404d4b3d9d76b74aafaeeec8 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Mon, 10 Sep 2018 23:07:20 -0600 Subject: [PATCH 183/257] fix tests --- .babelrc | 13 +++++++++++++ .travis.yml | 5 ++--- Makefile | 14 +++++++++++--- karma.conf.js | 4 ++-- package.json | 3 +++ test/debug-spec.js => test.js | 2 +- 6 files changed, 32 insertions(+), 9 deletions(-) create mode 100644 .babelrc rename test/debug-spec.js => test.js (98%) diff --git a/.babelrc b/.babelrc new file mode 100644 index 00000000..b2799de4 --- /dev/null +++ b/.babelrc @@ -0,0 +1,13 @@ +{ + "presets": [ + [ + "@babel/preset-env", + { + "targets": { + "chrome": "58", + "ie": "8" + } + } + ] + ] +} diff --git a/.travis.yml b/.travis.yml index 05f3dbb2..fca0ce19 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,11 +8,10 @@ node_js: - "10" install: - - make install + - npm install script: - - make lint - - make test + - make all matrix: include: diff --git a/Makefile b/Makefile index 48e66bc7..3651a92d 100644 --- a/Makefile +++ b/Makefile @@ -17,17 +17,25 @@ BROWSERIFY ?= $(NODE) $(BIN)/browserify all: lint test -browser: dist/debug.js +browser: dist/debug.js dist/test.js dist/debug.js: src/*.js @mkdir -p dist - @$(BROWSERIFY) --standalone debug . > dist/debug.js + @$(BROWSERIFY) --standalone debug . > $@.es6.js + @babel $@.es6.js > $@ + @rm $@.es6.js + +dist/test.js: test.js + @mkdir -p dist + @cp $< $@.es6.js + @babel $@.es6.js > $@ + @rm $@.es6.js lint: @xo test-node: - @istanbul cover node_modules/mocha/bin/_mocha -- test/**.js + @istanbul cover node_modules/mocha/bin/_mocha -- test.js @cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js test-browser: diff --git a/karma.conf.js b/karma.conf.js index 82f90691..e503df20 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -9,12 +9,12 @@ module.exports = function (config) { // Frameworks to use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter - frameworks: ['mocha', 'chai', 'sinon'], + frameworks: ['mocha', 'chai'], // List of files / patterns to load in the browser files: [ 'dist/debug.js', - 'test/*spec.js' + 'dist/test.js' ], // List of files to exclude diff --git a/package.json b/package.json index c6f613c2..6a15aed3 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,9 @@ "ms": "^2.1.1" }, "devDependencies": { + "@babel/cli": "^7.0.0", + "@babel/core": "^7.0.0", + "@babel/preset-env": "^7.0.0", "browserify": "14.4.0", "chai": "^3.5.0", "concurrently": "^3.1.0", diff --git a/test/debug-spec.js b/test.js similarity index 98% rename from test/debug-spec.js rename to test.js index 6862497e..675d0825 100644 --- a/test/debug-spec.js +++ b/test.js @@ -10,7 +10,7 @@ let debug; if (typeof module !== 'undefined') { chai = require('chai'); expect = chai.expect; - debug = require('../src'); + debug = require('./src'); } describe('debug', () => { From 623c08ef73f8211278d5596c88041c65a2a58ee7 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Mon, 10 Sep 2018 23:11:24 -0600 Subject: [PATCH 184/257] no longer checking for BROWSER=1 --- .travis.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index fca0ce19..c160e8d3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,8 +12,3 @@ install: script: - make all - -matrix: - include: - - node_js: '8' - env: BROWSER=1 From 9f4f8f59ba745166b0c014a61c76de5e73d4841a Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Mon, 10 Sep 2018 23:11:33 -0600 Subject: [PATCH 185/257] remove needless command aliases in makefile --- Makefile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 3651a92d..663744fb 100644 --- a/Makefile +++ b/Makefile @@ -10,10 +10,7 @@ PATH := node_modules/.bin:$(PATH) SHELL := /bin/bash # applications -NODE ?= $(shell which node) -YARN ?= $(shell which yarn) -PKG ?= $(if $(YARN),$(YARN),$(NODE) $(shell which npm)) -BROWSERIFY ?= $(NODE) $(BIN)/browserify +BROWSERIFY ?= $(BIN)/browserify all: lint test From 3ca23316a470f6bc6e0d75d297179cfc19bbc763 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Mon, 10 Sep 2018 23:45:28 -0600 Subject: [PATCH 186/257] clean up builds --- .npmignore | 15 --------------- Makefile | 40 ++++++++++++++++------------------------ node.js | 1 - package.json | 6 ++++++ 4 files changed, 22 insertions(+), 40 deletions(-) delete mode 100644 .npmignore delete mode 100644 node.js diff --git a/.npmignore b/.npmignore deleted file mode 100644 index 9c93383c..00000000 --- a/.npmignore +++ /dev/null @@ -1,15 +0,0 @@ -support -test -examples -example -*.sock -dist -yarn.lock -coverage -bower.json -.coveralls.yml -.eslintrc -.travis.yml -.npmignore -karma.conf.js -Makefile diff --git a/Makefile b/Makefile index 663744fb..e28468e6 100644 --- a/Makefile +++ b/Makefile @@ -1,47 +1,39 @@ -# get Makefile directory name: http://stackoverflow.com/a/5982798/376773 +# http://stackoverflow.com/a/5982798/376773 THIS_MAKEFILE_PATH:=$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) THIS_DIR:=$(shell cd $(dir $(THIS_MAKEFILE_PATH));pwd) - -# BIN directory -BIN := $(THIS_DIR)/node_modules/.bin - -# Path -PATH := node_modules/.bin:$(PATH) +export PATH := $(THIS_DIR)/node_modules/.bin:$(PATH) SHELL := /bin/bash -# applications -BROWSERIFY ?= $(BIN)/browserify - all: lint test -browser: dist/debug.js dist/test.js +dist: dist/debug.js dist/test.js + +.INTERMEDIATE: dist/debug.es6.js +dist/debug.es6.js: src/*.js + @mkdir -p dist + browserify --standalone debug $< > $@ -dist/debug.js: src/*.js +dist/debug.js: dist/debug.es6.js @mkdir -p dist - @$(BROWSERIFY) --standalone debug . > $@.es6.js - @babel $@.es6.js > $@ - @rm $@.es6.js + babel $< > $@ dist/test.js: test.js @mkdir -p dist - @cp $< $@.es6.js - @babel $@.es6.js > $@ - @rm $@.es6.js + babel $< > $@ lint: - @xo + xo test-node: - @istanbul cover node_modules/mocha/bin/_mocha -- test.js + istanbul cover node_modules/mocha/bin/_mocha -- test.js @cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js -test-browser: - @$(MAKE) browser - @karma start --single-run +test-browser: dist + karma start --single-run test: test-node test-browser clean: rm -rf dist coverage -.PHONY: all browser install clean lint test test-node test-browser +.PHONY: all dist clean lint test test-node test-browser diff --git a/node.js b/node.js deleted file mode 100644 index 7fc36fe6..00000000 --- a/node.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./src/node'); diff --git a/package.json b/package.json index 6a15aed3..c07c03b3 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,12 @@ "log", "debugger" ], + "files": [ + "src", + "dist/debug.js", + "LICENSE", + "README.md" + ], "author": "TJ Holowaychuk ", "contributors": [ "Nathan Rajlich (http://n8.io)", From dec4b159ddf63915c94cd9d8421ad11cd06f0e76 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Tue, 11 Sep 2018 00:12:55 -0600 Subject: [PATCH 187/257] 3.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c07c03b3..1bbaa207 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "3.1.0", + "version": "3.2.0", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From b3f8f8e683915ef4fae3a77cbcebc6c410e65a8c Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Tue, 11 Sep 2018 00:25:34 -0600 Subject: [PATCH 188/257] use babel-ified distributed source for browsers --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1bbaa207..c727ec02 100644 --- a/package.json +++ b/package.json @@ -45,5 +45,5 @@ "xo": "^0.23.0" }, "main": "./src/index.js", - "browser": "./src/browser.js" + "browser": "./dist/debug.js" } From 84e41d52acfdaa00ac724277f8c73a550be6916d Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Tue, 11 Sep 2018 00:25:52 -0600 Subject: [PATCH 189/257] 3.2.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c727ec02..4852a37f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "3.2.0", + "version": "3.2.1", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From 7fb104b8cfcbc3a91d8e4a6727638c3fe24be8d2 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Tue, 11 Sep 2018 02:56:30 -0600 Subject: [PATCH 190/257] 4.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4852a37f..7b1923b9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "3.2.1", + "version": "4.0.0", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From 99c95e3d54b07a918ad65bc148a2930ea8bfdd02 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Tue, 11 Sep 2018 15:35:13 -0600 Subject: [PATCH 191/257] fix browserify and supply alternative unpkg entry point (closes #606) --- Makefile | 2 +- package.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index e28468e6..5d91c19c 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ dist: dist/debug.js dist/test.js .INTERMEDIATE: dist/debug.es6.js dist/debug.es6.js: src/*.js @mkdir -p dist - browserify --standalone debug $< > $@ + browserify --standalone debug . > $@ dist/debug.js: dist/debug.es6.js @mkdir -p dist diff --git a/package.json b/package.json index 7b1923b9..8d8df5e6 100644 --- a/package.json +++ b/package.json @@ -45,5 +45,6 @@ "xo": "^0.23.0" }, "main": "./src/index.js", - "browser": "./dist/debug.js" + "browser": "./src/browser.js", + "unpkg": "./dist/debug.js" } From 4490cd95bfb952e1ed756914ac225ddc987b2ba3 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Tue, 11 Sep 2018 17:16:06 -0600 Subject: [PATCH 192/257] 4.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8d8df5e6..cecd5ac5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "4.0.0", + "version": "4.0.1", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From 4236585a40787fe60ed625452163299600df2ce6 Mon Sep 17 00:00:00 2001 From: Outsider Date: Tue, 2 Oct 2018 22:44:35 +0900 Subject: [PATCH 193/257] migrate Makefile to npm scripts Signed-off-by: Outsider --- .travis.yml | 3 ++- Makefile | 39 --------------------------------------- package.json | 13 +++++++++++++ 3 files changed, 15 insertions(+), 40 deletions(-) delete mode 100644 Makefile diff --git a/.travis.yml b/.travis.yml index c160e8d3..24682db3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,4 +11,5 @@ install: - npm install script: - - make all + - npm run lint + - npm test diff --git a/Makefile b/Makefile deleted file mode 100644 index 5d91c19c..00000000 --- a/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -# http://stackoverflow.com/a/5982798/376773 -THIS_MAKEFILE_PATH:=$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) -THIS_DIR:=$(shell cd $(dir $(THIS_MAKEFILE_PATH));pwd) -export PATH := $(THIS_DIR)/node_modules/.bin:$(PATH) -SHELL := /bin/bash - -all: lint test - -dist: dist/debug.js dist/test.js - -.INTERMEDIATE: dist/debug.es6.js -dist/debug.es6.js: src/*.js - @mkdir -p dist - browserify --standalone debug . > $@ - -dist/debug.js: dist/debug.es6.js - @mkdir -p dist - babel $< > $@ - -dist/test.js: test.js - @mkdir -p dist - babel $< > $@ - -lint: - xo - -test-node: - istanbul cover node_modules/mocha/bin/_mocha -- test.js - @cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js - -test-browser: dist - karma start --single-run - -test: test-node test-browser - -clean: - rm -rf dist coverage - -.PHONY: all dist clean lint test test-node test-browser diff --git a/package.json b/package.json index cecd5ac5..0c8aa48e 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,19 @@ "Andrew Rhyne " ], "license": "MIT", + "scripts": { + "lint": "xo", + "test": "npm run test:node && npm run test:browser", + "test:node": "istanbul cover _mocha -- test.js", + "posttest:node": "cat ./coverage/lcov.info | coveralls", + "pretest:browser": "npm run build", + "test:browser": "karma start --single-run", + "prebuild:debug": "mkdir -p dist && browserify --standalone debug -o dist/debug.es6.js .", + "build:debug": "babel -o dist/debug.js dist/debug.es6.js > dist/debug.js", + "build:test": "babel -d dist test.js", + "build": "npm run build:debug && npm run build:test", + "clean": "rimraf dist coverage" + }, "dependencies": { "ms": "^2.1.1" }, From 7ef8b417a86941372074f749019b9f439a1f6ef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20B=C3=B8cker-Larsen?= Date: Thu, 4 Oct 2018 09:45:22 +0800 Subject: [PATCH 194/257] feat: Return namespaces string when invoking disable() feat: Add unit tests for disable return value fix: Correct spelling in test case description feat: Test that disable-string works with enable again Closes #523 docs: Add section about disable return value --- README.md | 18 ++++++++++++++++++ src/common.js | 19 +++++++++++++++++++ test.js | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) diff --git a/README.md b/README.md index 0ee7634d..88dae35d 100644 --- a/README.md +++ b/README.md @@ -317,6 +317,24 @@ $ DEBUG=foo node -e 'var dbg = require("debug"); dbg.enable("bar"); console.log( => false ``` +`disable()` + +Will disable all namespaces. The functions returns the namespaces currently +enabled (and skipped). This can be useful if you want to disable debugging +temporarily without knowing what was enabled to begin with. + +For example: + +```js +let debug = require('debug'); +debug.enable('foo:*,-foo:bar'); +let namespaces = debug.disable(); +debug.enable(namespaces); +``` + +Note: There is no guarantee that the string will be identical to the initial +enable string, but semantically they will be identical. + ## Checking whether a debug target is enabled After you've created a debug instance, you can determine whether or not it is diff --git a/src/common.js b/src/common.js index dab9e480..0b6d0b64 100644 --- a/src/common.js +++ b/src/common.js @@ -187,10 +187,16 @@ function setup(env) { /** * Disable debug output. * + * @return {String} namespaces * @api public */ function disable() { + const namespaces = [ + ...createDebug.names.map(toNamespace), + ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace) + ].join(','); createDebug.enable(''); + return namespaces; } /** @@ -223,6 +229,19 @@ function setup(env) { return false; } + /** + * Convert regexp to namespace + * + * @param {RegExp} regxep + * @return {String} namespace + * @api private + */ + function toNamespace(regexp) { + return regexp.toString() + .substring(2, regexp.toString().length - 2) + .replace(/\.\*\?$/, '*'); + } + /** * Coerce `val`. * diff --git a/test.js b/test.js index 675d0825..888f9bd8 100644 --- a/test.js +++ b/test.js @@ -81,4 +81,43 @@ describe('debug', () => { expect(logBar.namespace).to.be.equal('foobar'); }); }); + + describe('rebuild namespaces string (disable)', () => { + it('handle names, skips, and wildcards', () => { + debug.enable('test,abc*,-abc'); + const namespaces = debug.disable(); + expect(namespaces).to.equal('test,abc*,-abc'); + }); + + it('handles empty', () => { + debug.enable(''); + const namespaces = debug.disable(); + expect(namespaces).to.equal(''); + expect(debug.names).to.deep.equal([]); + expect(debug.skips).to.deep.equal([]); + }); + + it('handles all', () => { + debug.enable('*'); + const namespaces = debug.disable(); + expect(namespaces).to.equal('*'); + }); + + it('handles skip all', () => { + debug.enable('-*'); + const namespaces = debug.disable(); + expect(namespaces).to.equal('-*'); + }); + + it('names+skips same with new string', () => { + debug.enable('test,abc*,-abc'); + const oldNames = [...debug.names]; + const oldSkips = [...debug.skips]; + const namespaces = debug.disable(); + expect(namespaces).to.equal('test,abc*,-abc'); + debug.enable(namespaces); + expect(oldNames.map(String)).to.deep.equal(debug.names.map(String)); + expect(oldSkips.map(String)).to.deep.equal(debug.skips.map(String)); + }); + }); }); From e30e8fdbc92c4cf6b3007cd1c3ad2c3cbb82be85 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Mon, 8 Oct 2018 04:09:42 -0600 Subject: [PATCH 195/257] 4.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0c8aa48e..0477a691 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "4.0.1", + "version": "4.1.0", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From 615cbb925f3a57f00d6bfeab881ad47f77a7e4c7 Mon Sep 17 00:00:00 2001 From: ossdev07 Date: Mon, 24 Sep 2018 15:53:42 +0530 Subject: [PATCH 196/257] debug: Replaced phantomJS by chrome Added script in package.json for running Test-suite Signed-off-by: ossdev07 --- karma.conf.js | 8 +++++++- package.json | 7 +++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index e503df20..8a4d88c6 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -47,7 +47,13 @@ module.exports = function (config) { // Start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: ['PhantomJS'], + browsers: ['HeadlessChrome'], + customLaunchers: { + HeadlessChrome: { + base: 'ChromeHeadless', + flags: ['--no-sandbox',], + }, + }, // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits diff --git a/package.json b/package.json index 0477a691..a2dc7f31 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,9 @@ "dependencies": { "ms": "^2.1.1" }, + "scripts": { + "test": "mocha" + }, "devDependencies": { "@babel/cli": "^7.0.0", "@babel/core": "^7.0.0", @@ -48,10 +51,10 @@ "concurrently": "^3.1.0", "coveralls": "^3.0.2", "istanbul": "^0.4.5", - "karma": "^3.0.0", + "karma": "^2.0.0", "karma-chai": "^0.1.0", "karma-mocha": "^1.3.0", - "karma-phantomjs-launcher": "^1.0.2", + "karma-chrome-launcher": "^2.2.0", "mocha": "^5.2.0", "mocha-lcov-reporter": "^1.2.0", "rimraf": "^2.5.4", From 4fe746a44692a9fe55d24a3c0ff5e4f340519d90 Mon Sep 17 00:00:00 2001 From: ossdev07 <39188636+ossdev07@users.noreply.github.com> Date: Mon, 24 Sep 2018 16:15:28 +0530 Subject: [PATCH 197/257] Update karma.conf.js --- karma.conf.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index 8a4d88c6..c8033d79 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -48,12 +48,12 @@ module.exports = function (config) { // Start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher browsers: ['HeadlessChrome'], - customLaunchers: { - HeadlessChrome: { - base: 'ChromeHeadless', - flags: ['--no-sandbox',], - }, - }, + customLaunchers: { + HeadlessChrome: { + base: 'ChromeHeadless', + flags: ['--no-sandbox',], + }, + }, // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits From 61c94841a0cc48f33a8b5ac5f973ee75d74b7996 Mon Sep 17 00:00:00 2001 From: ossdev07 <39188636+ossdev07@users.noreply.github.com> Date: Mon, 24 Sep 2018 16:26:46 +0530 Subject: [PATCH 198/257] Update karma.conf.js --- karma.conf.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index c8033d79..fef8bf4c 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -48,12 +48,12 @@ module.exports = function (config) { // Start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher browsers: ['HeadlessChrome'], - customLaunchers: { - HeadlessChrome: { - base: 'ChromeHeadless', - flags: ['--no-sandbox',], - }, - }, + customLaunchers: { + HeadlessChrome: { + base: 'ChromeHeadless', + flags: ['--no-sandbox' ], + } + }, // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits From 7ea4076fd684df6ace0cb4eba64d17a3b711ba3a Mon Sep 17 00:00:00 2001 From: ossdev07 <39188636+ossdev07@users.noreply.github.com> Date: Mon, 24 Sep 2018 16:31:03 +0530 Subject: [PATCH 199/257] Update karma.conf.js --- karma.conf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/karma.conf.js b/karma.conf.js index fef8bf4c..38f34571 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -51,7 +51,7 @@ module.exports = function (config) { customLaunchers: { HeadlessChrome: { base: 'ChromeHeadless', - flags: ['--no-sandbox' ], + flags: ['--no-sandbox'] } }, From dab648abd54abf3f0cc8862d7ba9628f616cf3fe Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Wed, 10 Oct 2018 01:03:02 -0600 Subject: [PATCH 200/257] remove second (shadow) scripts block --- package.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/package.json b/package.json index a2dc7f31..2e14fcbe 100644 --- a/package.json +++ b/package.json @@ -39,9 +39,6 @@ "dependencies": { "ms": "^2.1.1" }, - "scripts": { - "test": "mocha" - }, "devDependencies": { "@babel/cli": "^7.0.0", "@babel/core": "^7.0.0", From 5fadf4544d32531a91519299f6850620c6a0221e Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Thu, 11 Oct 2018 05:56:04 -0600 Subject: [PATCH 201/257] deprecate CHANGELOG.md --- CHANGELOG.md | 397 +-------------------------------------------------- 1 file changed, 3 insertions(+), 394 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 820d21e3..97162b9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,395 +1,4 @@ +CHANGELOG.md has been deprecated moved to the Github releases pages. It will be removed in the future. -3.1.0 / 2017-09-26 -================== - - * Add `DEBUG_HIDE_DATE` env var (#486) - * Remove ReDoS regexp in %o formatter (#504) - * Remove "component" from package.json - * Remove `component.json` - * Ignore package-lock.json - * Examples: fix colors printout - * Fix: browser detection - * Fix: spelling mistake (#496, @EdwardBetts) - -3.0.1 / 2017-08-24 -================== - - * Fix: Disable colors in Edge and Internet Explorer (#489) - -3.0.0 / 2017-08-08 -================== - - * Breaking: Remove DEBUG_FD (#406) - * Breaking: Use `Date#toISOString()` instead to `Date#toUTCString()` when output is not a TTY (#418) - * Breaking: Make millisecond timer namespace specific and allow 'always enabled' output (#408) - * Addition: document `enabled` flag (#465) - * Addition: add 256 colors mode (#481) - * Addition: `enabled()` updates existing debug instances, add `destroy()` function (#440) - * Update: component: update "ms" to v2.0.0 - * Update: separate the Node and Browser tests in Travis-CI - * Update: refactor Readme, fixed documentation, added "Namespace Colors" section, redid screenshots - * Update: separate Node.js and web browser examples for organization - * Update: update "browserify" to v14.4.0 - * Fix: fix Readme typo (#473) - -2.6.9 / 2017-09-22 -================== - - * remove ReDoS regexp in %o formatter (#504) - -2.6.8 / 2017-05-18 -================== - - * Fix: Check for undefined on browser globals (#462, @marbemac) - -2.6.7 / 2017-05-16 -================== - - * Fix: Update ms to 2.0.0 to fix regular expression denial of service vulnerability (#458, @hubdotcom) - * Fix: Inline extend function in node implementation (#452, @dougwilson) - * Docs: Fix typo (#455, @msasad) - -2.6.5 / 2017-04-27 -================== - - * Fix: null reference check on window.documentElement.style.WebkitAppearance (#447, @thebigredgeek) - * Misc: clean up browser reference checks (#447, @thebigredgeek) - * Misc: add npm-debug.log to .gitignore (@thebigredgeek) - - -2.6.4 / 2017-04-20 -================== - - * Fix: bug that would occur if process.env.DEBUG is a non-string value. (#444, @LucianBuzzo) - * Chore: ignore bower.json in npm installations. (#437, @joaovieira) - * Misc: update "ms" to v0.7.3 (@tootallnate) - -2.6.3 / 2017-03-13 -================== - - * Fix: Electron reference to `process.env.DEBUG` (#431, @paulcbetts) - * Docs: Changelog fix (@thebigredgeek) - -2.6.2 / 2017-03-10 -================== - - * Fix: DEBUG_MAX_ARRAY_LENGTH (#420, @slavaGanzin) - * Docs: Add backers and sponsors from Open Collective (#422, @piamancini) - * Docs: Add Slackin invite badge (@tootallnate) - -2.6.1 / 2017-02-10 -================== - - * Fix: Module's `export default` syntax fix for IE8 `Expected identifier` error - * Fix: Whitelist DEBUG_FD for values 1 and 2 only (#415, @pi0) - * Fix: IE8 "Expected identifier" error (#414, @vgoma) - * Fix: Namespaces would not disable once enabled (#409, @musikov) - -2.6.0 / 2016-12-28 -================== - - * Fix: added better null pointer checks for browser useColors (@thebigredgeek) - * Improvement: removed explicit `window.debug` export (#404, @tootallnate) - * Improvement: deprecated `DEBUG_FD` environment variable (#405, @tootallnate) - -2.5.2 / 2016-12-25 -================== - - * Fix: reference error on window within webworkers (#393, @KlausTrainer) - * Docs: fixed README typo (#391, @lurch) - * Docs: added notice about v3 api discussion (@thebigredgeek) - -2.5.1 / 2016-12-20 -================== - - * Fix: babel-core compatibility - -2.5.0 / 2016-12-20 -================== - - * Fix: wrong reference in bower file (@thebigredgeek) - * Fix: webworker compatibility (@thebigredgeek) - * Fix: output formatting issue (#388, @kribblo) - * Fix: babel-loader compatibility (#383, @escwald) - * Misc: removed built asset from repo and publications (@thebigredgeek) - * Misc: moved source files to /src (#378, @yamikuronue) - * Test: added karma integration and replaced babel with browserify for browser tests (#378, @yamikuronue) - * Test: coveralls integration (#378, @yamikuronue) - * Docs: simplified language in the opening paragraph (#373, @yamikuronue) - -2.4.5 / 2016-12-17 -================== - - * Fix: `navigator` undefined in Rhino (#376, @jochenberger) - * Fix: custom log function (#379, @hsiliev) - * Improvement: bit of cleanup + linting fixes (@thebigredgeek) - * Improvement: rm non-maintainted `dist/` dir (#375, @freewil) - * Docs: simplified language in the opening paragraph. (#373, @yamikuronue) - -2.4.4 / 2016-12-14 -================== - - * Fix: work around debug being loaded in preload scripts for electron (#368, @paulcbetts) - -2.4.3 / 2016-12-14 -================== - - * Fix: navigation.userAgent error for react native (#364, @escwald) - -2.4.2 / 2016-12-14 -================== - - * Fix: browser colors (#367, @tootallnate) - * Misc: travis ci integration (@thebigredgeek) - * Misc: added linting and testing boilerplate with sanity check (@thebigredgeek) - -2.4.1 / 2016-12-13 -================== - - * Fix: typo that broke the package (#356) - -2.4.0 / 2016-12-13 -================== - - * Fix: bower.json references unbuilt src entry point (#342, @justmatt) - * Fix: revert "handle regex special characters" (@tootallnate) - * Feature: configurable util.inspect()`options for NodeJS (#327, @tootallnate) - * Feature: %O`(big O) pretty-prints objects (#322, @tootallnate) - * Improvement: allow colors in workers (#335, @botverse) - * Improvement: use same color for same namespace. (#338, @lchenay) - -2.3.3 / 2016-11-09 -================== - - * Fix: Catch `JSON.stringify()` errors (#195, Jovan Alleyne) - * Fix: Returning `localStorage` saved values (#331, Levi Thomason) - * Improvement: Don't create an empty object when no `process` (Nathan Rajlich) - -2.3.2 / 2016-11-09 -================== - - * Fix: be super-safe in index.js as well (@TooTallNate) - * Fix: should check whether process exists (Tom Newby) - -2.3.1 / 2016-11-09 -================== - - * Fix: Added electron compatibility (#324, @paulcbetts) - * Improvement: Added performance optimizations (@tootallnate) - * Readme: Corrected PowerShell environment variable example (#252, @gimre) - * Misc: Removed yarn lock file from source control (#321, @fengmk2) - -2.3.0 / 2016-11-07 -================== - - * Fix: Consistent placement of ms diff at end of output (#215, @gorangajic) - * Fix: Escaping of regex special characters in namespace strings (#250, @zacronos) - * Fix: Fixed bug causing crash on react-native (#282, @vkarpov15) - * Feature: Enabled ES6+ compatible import via default export (#212 @bucaran) - * Feature: Added %O formatter to reflect Chrome's console.log capability (#279, @oncletom) - * Package: Update "ms" to 0.7.2 (#315, @DevSide) - * Package: removed superfluous version property from bower.json (#207 @kkirsche) - * Readme: fix USE_COLORS to DEBUG_COLORS - * Readme: Doc fixes for format string sugar (#269, @mlucool) - * Readme: Updated docs for DEBUG_FD and DEBUG_COLORS environment variables (#232, @mattlyons0) - * Readme: doc fixes for PowerShell (#271 #243, @exoticknight @unreadable) - * Readme: better docs for browser support (#224, @matthewmueller) - * Tooling: Added yarn integration for development (#317, @thebigredgeek) - * Misc: Renamed History.md to CHANGELOG.md (@thebigredgeek) - * Misc: Added license file (#226 #274, @CantemoInternal @sdaitzman) - * Misc: Updated contributors (@thebigredgeek) - -2.2.0 / 2015-05-09 -================== - - * package: update "ms" to v0.7.1 (#202, @dougwilson) - * README: add logging to file example (#193, @DanielOchoa) - * README: fixed a typo (#191, @amir-s) - * browser: expose `storage` (#190, @stephenmathieson) - * Makefile: add a `distclean` target (#189, @stephenmathieson) - -2.1.3 / 2015-03-13 -================== - - * Updated stdout/stderr example (#186) - * Updated example/stdout.js to match debug current behaviour - * Renamed example/stderr.js to stdout.js - * Update Readme.md (#184) - * replace high intensity foreground color for bold (#182, #183) - -2.1.2 / 2015-03-01 -================== - - * dist: recompile - * update "ms" to v0.7.0 - * package: update "browserify" to v9.0.3 - * component: fix "ms.js" repo location - * changed bower package name - * updated documentation about using debug in a browser - * fix: security error on safari (#167, #168, @yields) - -2.1.1 / 2014-12-29 -================== - - * browser: use `typeof` to check for `console` existence - * browser: check for `console.log` truthiness (fix IE 8/9) - * browser: add support for Chrome apps - * Readme: added Windows usage remarks - * Add `bower.json` to properly support bower install - -2.1.0 / 2014-10-15 -================== - - * node: implement `DEBUG_FD` env variable support - * package: update "browserify" to v6.1.0 - * package: add "license" field to package.json (#135, @panuhorsmalahti) - -2.0.0 / 2014-09-01 -================== - - * package: update "browserify" to v5.11.0 - * node: use stderr rather than stdout for logging (#29, @stephenmathieson) - -1.0.4 / 2014-07-15 -================== - - * dist: recompile - * example: remove `console.info()` log usage - * example: add "Content-Type" UTF-8 header to browser example - * browser: place %c marker after the space character - * browser: reset the "content" color via `color: inherit` - * browser: add colors support for Firefox >= v31 - * debug: prefer an instance `log()` function over the global one (#119) - * Readme: update documentation about styled console logs for FF v31 (#116, @wryk) - -1.0.3 / 2014-07-09 -================== - - * Add support for multiple wildcards in namespaces (#122, @seegno) - * browser: fix lint - -1.0.2 / 2014-06-10 -================== - - * browser: update color palette (#113, @gscottolson) - * common: make console logging function configurable (#108, @timoxley) - * node: fix %o colors on old node <= 0.8.x - * Makefile: find node path using shell/which (#109, @timoxley) - -1.0.1 / 2014-06-06 -================== - - * browser: use `removeItem()` to clear localStorage - * browser, node: don't set DEBUG if namespaces is undefined (#107, @leedm777) - * package: add "contributors" section - * node: fix comment typo - * README: list authors - -1.0.0 / 2014-06-04 -================== - - * make ms diff be global, not be scope - * debug: ignore empty strings in enable() - * node: make DEBUG_COLORS able to disable coloring - * *: export the `colors` array - * npmignore: don't publish the `dist` dir - * Makefile: refactor to use browserify - * package: add "browserify" as a dev dependency - * Readme: add Web Inspector Colors section - * node: reset terminal color for the debug content - * node: map "%o" to `util.inspect()` - * browser: map "%j" to `JSON.stringify()` - * debug: add custom "formatters" - * debug: use "ms" module for humanizing the diff - * Readme: add "bash" syntax highlighting - * browser: add Firebug color support - * browser: add colors for WebKit browsers - * node: apply log to `console` - * rewrite: abstract common logic for Node & browsers - * add .jshintrc file - -0.8.1 / 2014-04-14 -================== - - * package: re-add the "component" section - -0.8.0 / 2014-03-30 -================== - - * add `enable()` method for nodejs. Closes #27 - * change from stderr to stdout - * remove unnecessary index.js file - -0.7.4 / 2013-11-13 -================== - - * remove "browserify" key from package.json (fixes something in browserify) - -0.7.3 / 2013-10-30 -================== - - * fix: catch localStorage security error when cookies are blocked (Chrome) - * add debug(err) support. Closes #46 - * add .browser prop to package.json. Closes #42 - -0.7.2 / 2013-02-06 -================== - - * fix package.json - * fix: Mobile Safari (private mode) is broken with debug - * fix: Use unicode to send escape character to shell instead of octal to work with strict mode javascript - -0.7.1 / 2013-02-05 -================== - - * add repository URL to package.json - * add DEBUG_COLORED to force colored output - * add browserify support - * fix component. Closes #24 - -0.7.0 / 2012-05-04 -================== - - * Added .component to package.json - * Added debug.component.js build - -0.6.0 / 2012-03-16 -================== - - * Added support for "-" prefix in DEBUG [Vinay Pulim] - * Added `.enabled` flag to the node version [TooTallNate] - -0.5.0 / 2012-02-02 -================== - - * Added: humanize diffs. Closes #8 - * Added `debug.disable()` to the CS variant - * Removed padding. Closes #10 - * Fixed: persist client-side variant again. Closes #9 - -0.4.0 / 2012-02-01 -================== - - * Added browser variant support for older browsers [TooTallNate] - * Added `debug.enable('project:*')` to browser variant [TooTallNate] - * Added padding to diff (moved it to the right) - -0.3.0 / 2012-01-26 -================== - - * Added millisecond diff when isatty, otherwise UTC string - -0.2.0 / 2012-01-22 -================== - - * Added wildcard support - -0.1.0 / 2011-12-02 -================== - - * Added: remove colors unless stderr isatty [TooTallNate] - -0.0.1 / 2010-01-03 -================== - - * Initial release +Please see https://github.com/visionmedia/debug/releases for all changelogs and information pertaining +to new releases. From 010fd0d92faeed1bd7e822f3780175e4f57fa2db Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Wed, 19 Dec 2018 01:43:40 +0100 Subject: [PATCH 202/257] remove changelog --- CHANGELOG.md | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 97162b9e..00000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,4 +0,0 @@ -CHANGELOG.md has been deprecated moved to the Github releases pages. It will be removed in the future. - -Please see https://github.com/visionmedia/debug/releases for all changelogs and information pertaining -to new releases. From dfd5ffa8b6cd52056651964360749a1873149eff Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Wed, 19 Dec 2018 01:46:00 +0100 Subject: [PATCH 203/257] remove bower.json (closes #602) --- bower.json | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 bower.json diff --git a/bower.json b/bower.json deleted file mode 100644 index 027804ce..00000000 --- a/bower.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "visionmedia-debug", - "main": "./src/browser.js", - "homepage": "https://github.com/visionmedia/debug", - "authors": [ - "TJ Holowaychuk ", - "Nathan Rajlich (http://n8.io)", - "Andrew Rhyne " - ], - "description": "visionmedia-debug", - "moduleType": [ - "amd", - "es6", - "globals", - "node" - ], - "keywords": [ - "visionmedia", - "debug" - ], - "license": "MIT", - "ignore": [ - "**/.*", - "node_modules", - "bower_components", - "test", - "tests" - ] -} From dc5c34f9d8fc9c08ee5b275b4f0c51b9f984a98f Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Wed, 19 Dec 2018 02:05:38 +0100 Subject: [PATCH 204/257] remove .eslintrc --- .eslintrc | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 .eslintrc diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 146371ed..00000000 --- a/.eslintrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "env": { - "browser": true, - "node": true - }, - "globals": { - "chrome": true - }, - "rules": { - "no-console": 0, - "no-empty": [1, { "allowEmptyCatch": true }] - }, - "extends": "eslint:recommended" -} From fe49015965c0f29f943df20f29445b4310b3ce0a Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Wed, 19 Dec 2018 02:29:30 +0100 Subject: [PATCH 205/257] remove .coveralls.yml --- .coveralls.yml | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .coveralls.yml diff --git a/.coveralls.yml b/.coveralls.yml deleted file mode 100644 index 20a70685..00000000 --- a/.coveralls.yml +++ /dev/null @@ -1 +0,0 @@ -repo_token: SIAeZjKYlHK74rbcFvNHMUzjRiMpflxve From ad551e2b61022107cee85a66819cd4d2b962038a Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Wed, 19 Dec 2018 02:45:52 +0100 Subject: [PATCH 206/257] add Josh Junon to contributors --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 2e14fcbe..3464bd8a 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,8 @@ "author": "TJ Holowaychuk ", "contributors": [ "Nathan Rajlich (http://n8.io)", - "Andrew Rhyne " + "Andrew Rhyne ", + "Josh Junon " ], "license": "MIT", "scripts": { From 0e94034efb1e88b88a06ca3862d8d2cc2f2ed5d0 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Wed, 19 Dec 2018 02:41:45 +0100 Subject: [PATCH 207/257] update development dependencies --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 3464bd8a..9e35a1b2 100644 --- a/package.json +++ b/package.json @@ -44,12 +44,12 @@ "@babel/cli": "^7.0.0", "@babel/core": "^7.0.0", "@babel/preset-env": "^7.0.0", - "browserify": "14.4.0", - "chai": "^3.5.0", - "concurrently": "^3.1.0", + "browserify": "16.2.3", + "chai": "^4.2.0", + "concurrently": "^4.1.0", "coveralls": "^3.0.2", "istanbul": "^0.4.5", - "karma": "^2.0.0", + "karma": "^3.1.4", "karma-chai": "^0.1.0", "karma-mocha": "^1.3.0", "karma-chrome-launcher": "^2.2.0", From 94583b652a58e58102074ce5ab99e17972db1c4f Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Wed, 19 Dec 2018 04:03:39 +0100 Subject: [PATCH 208/257] remove build system (closes #652) --- .babelrc | 13 ------------- .travis.yml | 1 + karma.conf.js | 43 +++++++++++++++++------------------------- package.json | 25 ++++++------------------- test.js | 52 +++++++++++++++++++++------------------------------ 5 files changed, 45 insertions(+), 89 deletions(-) delete mode 100644 .babelrc diff --git a/.babelrc b/.babelrc deleted file mode 100644 index b2799de4..00000000 --- a/.babelrc +++ /dev/null @@ -1,13 +0,0 @@ -{ - "presets": [ - [ - "@babel/preset-env", - { - "targets": { - "chrome": "58", - "ie": "8" - } - } - ] - ] -} diff --git a/.travis.yml b/.travis.yml index 24682db3..c020bf98 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ node_js: - "6" - "8" - "10" + - "11" install: - npm install diff --git a/karma.conf.js b/karma.conf.js index 38f34571..6e835858 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,32 +1,16 @@ -// Karma configuration -// Generated on Fri Dec 16 2016 13:09:51 GMT+0000 (UTC) - module.exports = function (config) { config.set({ - - // Base path that will be used to resolve all patterns (eg. files, exclude) - basePath: '', - // Frameworks to use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter - frameworks: ['mocha', 'chai'], + frameworks: ['browserify', 'mocha'], // List of files / patterns to load in the browser files: [ - 'dist/debug.js', - 'dist/test.js' + 'src/browser.js', + 'src/common.js', + 'test.js' ], - // List of files to exclude - exclude: [ - 'src/node.js' - ], - - // Preprocess matching files before serving them to the browser - // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor - preprocessors: { - }, - // Test results reporter to use // possible values: 'dots', 'progress' // available reporters: https://npmjs.org/browse/keyword/karma-reporter @@ -40,10 +24,7 @@ module.exports = function (config) { // Level of logging // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG - logLevel: config.LOG_INFO, - - // Enable / disable watching file and executing tests whenever any file changes - autoWatch: true, + logLevel: config.LOG_DEBUG, // Start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher @@ -55,12 +36,22 @@ module.exports = function (config) { } }, + preprocessors: { + // *Sigh* what a glob, folks! + '{{!(node_modules),*.js},!(node_modules)/**/*.js}': ['browserify'] + }, + + browserify: { + debug: true, + transform: ['brfs'] + }, + // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits - singleRun: false, + singleRun: true, // Concurrency level // how many browser should be started simultaneous - concurrency: Infinity + concurrency: 1 }); }; diff --git a/package.json b/package.json index 9e35a1b2..c26c4a16 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,6 @@ ], "files": [ "src", - "dist/debug.js", "LICENSE", "README.md" ], @@ -28,37 +27,25 @@ "lint": "xo", "test": "npm run test:node && npm run test:browser", "test:node": "istanbul cover _mocha -- test.js", - "posttest:node": "cat ./coverage/lcov.info | coveralls", - "pretest:browser": "npm run build", "test:browser": "karma start --single-run", - "prebuild:debug": "mkdir -p dist && browserify --standalone debug -o dist/debug.es6.js .", - "build:debug": "babel -o dist/debug.js dist/debug.es6.js > dist/debug.js", - "build:test": "babel -d dist test.js", - "build": "npm run build:debug && npm run build:test", - "clean": "rimraf dist coverage" + "posttest:node": "cat ./coverage/lcov.info | coveralls" }, "dependencies": { "ms": "^2.1.1" }, "devDependencies": { - "@babel/cli": "^7.0.0", - "@babel/core": "^7.0.0", - "@babel/preset-env": "^7.0.0", - "browserify": "16.2.3", - "chai": "^4.2.0", - "concurrently": "^4.1.0", + "brfs": "^2.0.1", + "browserify": "^16.2.3", "coveralls": "^3.0.2", "istanbul": "^0.4.5", "karma": "^3.1.4", - "karma-chai": "^0.1.0", - "karma-mocha": "^1.3.0", + "karma-browserify": "^6.0.0", "karma-chrome-launcher": "^2.2.0", + "karma-mocha": "^1.3.0", "mocha": "^5.2.0", "mocha-lcov-reporter": "^1.2.0", - "rimraf": "^2.5.4", "xo": "^0.23.0" }, "main": "./src/index.js", - "browser": "./src/browser.js", - "unpkg": "./dist/debug.js" + "browser": "./src/browser.js" } diff --git a/test.js b/test.js index 888f9bd8..460f9759 100644 --- a/test.js +++ b/test.js @@ -1,17 +1,7 @@ /* eslint-env mocha */ -'use strict'; -let chai; - -let expect; - -let debug; - -if (typeof module !== 'undefined') { - chai = require('chai'); - expect = chai.expect; - debug = require('./src'); -} +const assert = require('assert'); +const debug = require('./src'); describe('debug', () => { it('passes a basic sanity check', () => { @@ -19,7 +9,7 @@ describe('debug', () => { log.enabled = true; log.log = () => {}; - expect(() => log('hello world')).to.not.throw(); + assert.doesNotThrow(() => log('hello world')); }); it('allows namespaces to be a non-string value', () => { @@ -27,16 +17,16 @@ describe('debug', () => { log.enabled = true; log.log = () => {}; - expect(() => debug.enable(true)).to.not.throw(); + assert.doesNotThrow(() => debug.enable(true)); }); it('honors global debug namespace enable calls', () => { - expect(debug('test:12345').enabled).to.equal(false); - expect(debug('test:67890').enabled).to.equal(false); + assert.deepStrictEqual(debug('test:12345').enabled, false); + assert.deepStrictEqual(debug('test:67890').enabled, false); debug.enable('test:12345'); - expect(debug('test:12345').enabled).to.equal(true); - expect(debug('test:67890').enabled).to.equal(false); + assert.deepStrictEqual(debug('test:12345').enabled, true); + assert.deepStrictEqual(debug('test:67890').enabled, false); }); it('uses custom log function', () => { @@ -50,7 +40,7 @@ describe('debug', () => { log('using custom log function again'); log('%O', 12345); - expect(messages.length).to.equal(3); + assert.deepStrictEqual(messages.length, 3); }); describe('extend namespace', () => { @@ -60,7 +50,7 @@ describe('debug', () => { log.log = () => {}; const logBar = log.extend('bar'); - expect(logBar.namespace).to.be.equal('foo:bar'); + assert.deepStrictEqual(logBar.namespace, 'foo:bar'); }); it('should extend namespace with custom delimiter', () => { @@ -69,7 +59,7 @@ describe('debug', () => { log.log = () => {}; const logBar = log.extend('bar', '--'); - expect(logBar.namespace).to.be.equal('foo--bar'); + assert.deepStrictEqual(logBar.namespace, 'foo--bar'); }); it('should extend namespace with empty delimiter', () => { @@ -78,7 +68,7 @@ describe('debug', () => { log.log = () => {}; const logBar = log.extend('bar', ''); - expect(logBar.namespace).to.be.equal('foobar'); + assert.deepStrictEqual(logBar.namespace, 'foobar'); }); }); @@ -86,27 +76,27 @@ describe('debug', () => { it('handle names, skips, and wildcards', () => { debug.enable('test,abc*,-abc'); const namespaces = debug.disable(); - expect(namespaces).to.equal('test,abc*,-abc'); + assert.deepStrictEqual(namespaces, 'test,abc*,-abc'); }); it('handles empty', () => { debug.enable(''); const namespaces = debug.disable(); - expect(namespaces).to.equal(''); - expect(debug.names).to.deep.equal([]); - expect(debug.skips).to.deep.equal([]); + assert.deepStrictEqual(namespaces, ''); + assert.deepStrictEqual(debug.names, []); + assert.deepStrictEqual(debug.skips, []); }); it('handles all', () => { debug.enable('*'); const namespaces = debug.disable(); - expect(namespaces).to.equal('*'); + assert.deepStrictEqual(namespaces, '*'); }); it('handles skip all', () => { debug.enable('-*'); const namespaces = debug.disable(); - expect(namespaces).to.equal('-*'); + assert.deepStrictEqual(namespaces, '-*'); }); it('names+skips same with new string', () => { @@ -114,10 +104,10 @@ describe('debug', () => { const oldNames = [...debug.names]; const oldSkips = [...debug.skips]; const namespaces = debug.disable(); - expect(namespaces).to.equal('test,abc*,-abc'); + assert.deepStrictEqual(namespaces, 'test,abc*,-abc'); debug.enable(namespaces); - expect(oldNames.map(String)).to.deep.equal(debug.names.map(String)); - expect(oldSkips.map(String)).to.deep.equal(debug.skips.map(String)); + assert.deepStrictEqual(oldNames.map(String), debug.names.map(String)); + assert.deepStrictEqual(oldSkips.map(String), debug.skips.map(String)); }); }); }); From c0127b18a0b7670bf931072a25ddc82e84116659 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Wed, 19 Dec 2018 04:26:28 +0100 Subject: [PATCH 209/257] remove examples folder (closes #650) --- examples/browser/colors.html | 28 ---------------------------- examples/node/app.js | 20 -------------------- examples/node/colors.js | 8 -------- examples/node/stdout.js | 18 ------------------ examples/node/wildcards.js | 10 ---------- examples/node/worker.js | 27 --------------------------- 6 files changed, 111 deletions(-) delete mode 100644 examples/browser/colors.html delete mode 100644 examples/node/app.js delete mode 100644 examples/node/colors.js delete mode 100644 examples/node/stdout.js delete mode 100644 examples/node/wildcards.js delete mode 100644 examples/node/worker.js diff --git a/examples/browser/colors.html b/examples/browser/colors.html deleted file mode 100644 index ce969072..00000000 --- a/examples/browser/colors.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - debug() - - - - - - - Open your - Web Inspector - to see the debug output - - diff --git a/examples/node/app.js b/examples/node/app.js deleted file mode 100644 index 08d3f257..00000000 --- a/examples/node/app.js +++ /dev/null @@ -1,20 +0,0 @@ -const http = require('http'); - -const debug = require('../..')('http'); - -const name = 'My App'; - -// Fake app - -debug('booting %o', name); - -http.createServer((req, res) => { - debug(req.method + ' ' + req.url); - res.end('hello\n'); -}).listen(3000, () => { - debug('listening'); -}); - -// Fake worker of some kind -// eslint-disable-next-line import/no-unassigned-import -require('./worker'); diff --git a/examples/node/colors.js b/examples/node/colors.js deleted file mode 100644 index 9cbfa1f9..00000000 --- a/examples/node/colors.js +++ /dev/null @@ -1,8 +0,0 @@ -const debug = require('../..'); - -debug.enable('*'); - -for (let i = 0; i < debug.colors.length; i++) { - const d = debug('example:' + i); - d('The color is %o', d.color); -} diff --git a/examples/node/stdout.js b/examples/node/stdout.js deleted file mode 100644 index 17558da0..00000000 --- a/examples/node/stdout.js +++ /dev/null @@ -1,18 +0,0 @@ -const debug = require('../..'); - -const error = debug('app:error'); - -// By default stderr is used -error('goes to stderr!'); - -const log = debug('app:log'); -// Set this namespace to log via console.log -log.log = console.log.bind(console); // Don't forget to bind to console! -log('goes to stdout'); -error('still goes to stderr!'); - -// Set all output to go via console.info -// overrides all per-namespace log settings -debug.log = console.info.bind(console); -error('now goes to stdout via console.info'); -log('still goes to stdout, but via console.info now'); diff --git a/examples/node/wildcards.js b/examples/node/wildcards.js deleted file mode 100644 index 2cedc2d8..00000000 --- a/examples/node/wildcards.js +++ /dev/null @@ -1,10 +0,0 @@ - -const debug = { - foo: require('../..')('test:foo'), - bar: require('../..')('test:bar'), - baz: require('../..')('test:baz') -}; - -debug.foo('foo'); -debug.bar('bar'); -debug.baz('baz'); diff --git a/examples/node/worker.js b/examples/node/worker.js deleted file mode 100644 index 6f483a66..00000000 --- a/examples/node/worker.js +++ /dev/null @@ -1,27 +0,0 @@ - -// DEBUG=* node example/worker -// DEBUG=worker:* node example/worker -// DEBUG=worker:a node example/worker -// DEBUG=worker:b node example/worker - -const a = require('../..')('worker:a'); - -const b = require('../..')('worker:b'); - -function work() { - a('doing lots of uninteresting work'); - setTimeout(work, Math.random() * 1000); -} - -work(); - -function workb() { - b('doing some work'); - setTimeout(workb, Math.random() * 2000); -} - -workb(); - -setTimeout(() => { - b(new Error('fail')); -}, 5000); From 5528572f9a96b9202e77e565eb641ba8c74aec40 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Wed, 19 Dec 2018 04:41:05 +0100 Subject: [PATCH 210/257] use console.debug() in browser when available (closes #600) also removes a branch for each logging call, slightly improving performance in the browser. --- src/browser.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/browser.js b/src/browser.js index 5f34c0d0..ac3f7e13 100644 --- a/src/browser.js +++ b/src/browser.js @@ -4,7 +4,6 @@ * This is the web browser implementation of `debug()`. */ -exports.log = log; exports.formatArgs = formatArgs; exports.save = save; exports.load = load; @@ -170,18 +169,14 @@ function formatArgs(args) { } /** - * Invokes `console.log()` when available. - * No-op when `console.log` is not a "function". + * Invokes `console.debug()` when available. + * No-op when `console.debug` is not a "function". + * If `console.debug` is not available, falls back + * to `console.log`. * * @api public */ -function log(...args) { - // This hackery is required for IE8/9, where - // the `console.log` function doesn't have 'apply' - return typeof console === 'object' && - console.log && - console.log(...args); -} +exports.log = console.debug || console.log || (() => {}); /** * Save `namespaces`. From 825d35a2da0a9fa115baffea2f07d22b876332fc Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Wed, 19 Dec 2018 04:56:06 +0100 Subject: [PATCH 211/257] copy custom logger to namespace extension (fixes #646) --- src/common.js | 4 +++- test.js | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/common.js b/src/common.js index 0b6d0b64..2f82b8dc 100644 --- a/src/common.js +++ b/src/common.js @@ -143,7 +143,9 @@ function setup(env) { } function extend(namespace, delimiter) { - return createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace); + const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace); + newDebug.log = this.log; + return newDebug; } /** diff --git a/test.js b/test.js index 460f9759..f61e079b 100644 --- a/test.js +++ b/test.js @@ -70,6 +70,14 @@ describe('debug', () => { const logBar = log.extend('bar', ''); assert.deepStrictEqual(logBar.namespace, 'foobar'); }); + + it('should keep the log function between extensions', () => { + const log = debug('foo'); + log.log = () => {}; + + const logBar = log.extend('bar'); + assert.deepStrictEqual(log.log, logBar.log); + }); }); describe('rebuild namespaces string (disable)', () => { From 982c12c926699221c6769b50a8ead9d50f8807c4 Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Sat, 22 Dec 2018 03:14:57 -0500 Subject: [PATCH 212/257] test: only run coveralls on travis s/posttest:node/coverage Explicitly call coverage only from CI. This will stop the test suite from failing on a system not configured to authenticate with circle-ci --- .travis.yml | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c020bf98..40103cfc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,3 +14,4 @@ install: script: - npm run lint - npm test + - npm run test:coverage diff --git a/package.json b/package.json index c26c4a16..643af019 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "test": "npm run test:node && npm run test:browser", "test:node": "istanbul cover _mocha -- test.js", "test:browser": "karma start --single-run", - "posttest:node": "cat ./coverage/lcov.info | coveralls" + "test:coverage": "cat ./coverage/lcov.info | coveralls" }, "dependencies": { "ms": "^2.1.1" From 976f8d2afc5e2a815225ff6eca2e02f4ef0462ee Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Thu, 10 Jan 2019 16:51:53 +0100 Subject: [PATCH 213/257] add issue and pull request templates --- .github/ISSUE_TEMPLATE.md | 17 +++++++++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..baaeb283 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,17 @@ + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..c43a8c82 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,17 @@ + From 5c7c61dc0df0db4eb5de25707d8cd1b9be1add4f Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Thu, 10 Jan 2019 16:53:31 +0100 Subject: [PATCH 214/257] fix links in issue templates --- .github/ISSUE_TEMPLATE.md | 2 +- .github/PULL_REQUEST_TEMPLATE.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index baaeb283..3c5c9a92 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -12,6 +12,6 @@ target the browsers that make sense for your project. For more information, please see: -https://github.com/visionmedia/debug/pull/672 +https://github.com/sindresorhus/ama/issues/446#issuecomment-281014491 --> diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index c43a8c82..af3da470 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -12,6 +12,6 @@ target the browsers that make sense for your project. For more information, please see: -https://github.com/visionmedia/debug/pull/672 +https://github.com/sindresorhus/ama/issues/446#issuecomment-281014491 --> From 608fca962b34e2bda841db9a4416bab6b4a62803 Mon Sep 17 00:00:00 2001 From: Qix Date: Wed, 13 Nov 2019 11:27:24 +0100 Subject: [PATCH 215/257] Update ISSUE_TEMPLATE.md --- .github/ISSUE_TEMPLATE.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 3c5c9a92..58858535 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -14,4 +14,15 @@ your project. For more information, please see: https://github.com/sindresorhus/ama/issues/446#issuecomment-281014491 +Please keep in mind that `debug` is downloaded, +installed, transpiled and used millions of times +*per day*. If you have an error with `debug`, it's +most likely your own configuration (e.g. with Babel, +Webpack, etc). + +Unless you post ample evidence you have tried +to fix this yourself, it will most likely +be determined that your issue is localized +to your project - not `debug`. + --> From 3f4d7247c0f57085c3d8450593b22ecd7ef73886 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Tue, 7 Jan 2020 20:38:20 -0500 Subject: [PATCH 216/257] Add "engines" to `package.json` (#680) --- package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 643af019..5e9d45e2 100644 --- a/package.json +++ b/package.json @@ -47,5 +47,8 @@ "xo": "^0.23.0" }, "main": "./src/index.js", - "browser": "./src/browser.js" + "browser": "./src/browser.js", + "engines": { + "node": ">=6.0" + } } From 4acdeedd4b532f0b5a86b35019e0bc9f081d04b4 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Sun, 12 Jan 2020 20:29:28 +0100 Subject: [PATCH 217/257] run linter inside of test script --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5e9d45e2..85b6f1d6 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "license": "MIT", "scripts": { "lint": "xo", - "test": "npm run test:node && npm run test:browser", + "test": "npm run test:node && npm run test:browser && npm run lint", "test:node": "istanbul cover _mocha -- test.js", "test:browser": "karma start --single-run", "test:coverage": "cat ./coverage/lcov.info | coveralls" @@ -49,6 +49,6 @@ "main": "./src/index.js", "browser": "./src/browser.js", "engines": { - "node": ">=6.0" + "node": ">=6.0" } } From 0c1d5180ff9559b506c8b431b24842bed0e8a5e2 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Sun, 12 Jan 2020 20:31:27 +0100 Subject: [PATCH 218/257] remove dead code and fix lowercase comment (for linter) --- src/common.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/common.js b/src/common.js index 2f82b8dc..32b4fd62 100644 --- a/src/common.js +++ b/src/common.js @@ -120,10 +120,8 @@ function setup(env) { debug.color = selectColor(namespace); debug.destroy = destroy; debug.extend = extend; - // Debug.formatArgs = formatArgs; - // debug.rawLog = rawLog; - // env-specific initialization logic for debug instances + // Env-specific initialization logic for debug instances if (typeof createDebug.init === 'function') { createDebug.init(debug); } From 6b07f9e50a528b6b47256d876f7e77374c337333 Mon Sep 17 00:00:00 2001 From: Milan Skuhra Date: Sun, 23 Feb 2020 20:07:49 +0100 Subject: [PATCH 219/257] Fixes: Unable to take control over selectColor #747 --- src/common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.js b/src/common.js index 32b4fd62..da7eada6 100644 --- a/src/common.js +++ b/src/common.js @@ -117,7 +117,7 @@ function setup(env) { debug.namespace = namespace; debug.enabled = createDebug.enabled(namespace); debug.useColors = createDebug.useColors(); - debug.color = selectColor(namespace); + debug.color = createDebug.selectColor(namespace); debug.destroy = destroy; debug.extend = extend; From db306db99e7822d355724698990d335927563210 Mon Sep 17 00:00:00 2001 From: Douglas Wilson Date: Fri, 27 Mar 2020 12:28:00 -0400 Subject: [PATCH 220/257] Update and pin ms to 2.1.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 85b6f1d6..b20770f2 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "test:coverage": "cat ./coverage/lcov.info | coveralls" }, "dependencies": { - "ms": "^2.1.1" + "ms": "2.1.2" }, "devDependencies": { "brfs": "^2.0.1", From 09914af00e4c1479db9aa160bc51cb8c7e063ca4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Nison?= Date: Wed, 16 Oct 2019 16:55:00 +0200 Subject: [PATCH 221/257] Marks supports-color as an *optional* peer dependency --- package.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/package.json b/package.json index b20770f2..f9dd28e7 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,11 @@ "mocha-lcov-reporter": "^1.2.0", "xo": "^0.23.0" }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + }, "main": "./src/index.js", "browser": "./src/browser.js", "engines": { From 80ef62a3af4df95250d77d64edfc3d0e1667e7e8 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Tue, 19 May 2020 11:36:58 +0200 Subject: [PATCH 222/257] 4.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f9dd28e7..c270ca0e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "4.1.0", + "version": "4.2.0", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From 22e13fe07e21f32888201aa40833599fd10a4fbb Mon Sep 17 00:00:00 2001 From: "Bruce A. MacNaughton" Date: Mon, 6 Apr 2020 13:37:14 -0700 Subject: [PATCH 223/257] fix quoted percent sign --- src/common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.js b/src/common.js index da7eada6..a7eeb0b1 100644 --- a/src/common.js +++ b/src/common.js @@ -92,7 +92,7 @@ function setup(env) { args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { // If we encounter an escaped % then don't increase the array index if (match === '%%') { - return match; + return '%'; } index++; const formatter = createDebug.formatters[format]; From 27152cad248df54217a14c072e7be1cd16da5f6d Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Sun, 12 Jan 2020 20:10:16 +0100 Subject: [PATCH 224/257] add test for enable/disable of existing instances --- test.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test.js b/test.js index f61e079b..a1d6f633 100644 --- a/test.js +++ b/test.js @@ -117,5 +117,24 @@ describe('debug', () => { assert.deepStrictEqual(oldNames.map(String), debug.names.map(String)); assert.deepStrictEqual(oldSkips.map(String), debug.skips.map(String)); }); + + it('handles re-enabling existing instances', () => { + debug.disable('*'); + const inst = debug('foo'); + const messages = []; + inst.log = msg => messages.push(msg.replace(/^[^@]*@([^@]+)@.*$/, '$1')); + + inst('@test@'); + assert.deepStrictEqual(messages, []); + debug.enable('foo'); + assert.deepStrictEqual(messages, []); + inst('@test2@'); + assert.deepStrictEqual(messages, ['test2']); + inst('@test3@'); + assert.deepStrictEqual(messages, ['test2', 'test3']); + debug.disable('*'); + inst('@test4@'); + assert.deepStrictEqual(messages, ['test2', 'test3']); + }); }); }); From 72e7f864bd75fc8353e4dd450de96d9104ba9f35 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Sun, 12 Jan 2020 20:14:48 +0100 Subject: [PATCH 225/257] fix memory leak within debug instance --- src/common.js | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/src/common.js b/src/common.js index a7eeb0b1..9d7e4dce 100644 --- a/src/common.js +++ b/src/common.js @@ -17,11 +17,6 @@ function setup(env) { createDebug[key] = env[key]; }); - /** - * Active `debug` instances. - */ - createDebug.instances = []; - /** * The currently active debug mode names, and names to skip. */ @@ -63,6 +58,7 @@ function setup(env) { */ function createDebug(namespace) { let prevTime; + let enableOverride = null; function debug(...args) { // Disabled? @@ -115,31 +111,27 @@ function setup(env) { } debug.namespace = namespace; - debug.enabled = createDebug.enabled(namespace); debug.useColors = createDebug.useColors(); debug.color = createDebug.selectColor(namespace); - debug.destroy = destroy; debug.extend = extend; + Object.defineProperty(debug, 'enabled', { + enumerable: true, + configurable: false, + get: () => enableOverride === null ? createDebug.enabled(namespace) : enableOverride, + set: v => { + enableOverride = v; + } + }); + // Env-specific initialization logic for debug instances if (typeof createDebug.init === 'function') { createDebug.init(debug); } - createDebug.instances.push(debug); - return debug; } - function destroy() { - const index = createDebug.instances.indexOf(this); - if (index !== -1) { - createDebug.instances.splice(index, 1); - return true; - } - return false; - } - function extend(namespace, delimiter) { const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace); newDebug.log = this.log; @@ -177,11 +169,6 @@ function setup(env) { createDebug.names.push(new RegExp('^' + namespaces + '$')); } } - - for (i = 0; i < createDebug.instances.length; i++) { - const instance = createDebug.instances[i]; - instance.enabled = createDebug.enabled(instance.namespace); - } } /** From e2d3bc9e428bdd45adb8d6e7f8ab543bee54d9a6 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Sun, 12 Jan 2020 20:25:37 +0100 Subject: [PATCH 226/257] add deprecation notice for debug.destroy() --- src/browser.js | 10 ++++++++++ src/common.js | 10 ++++++++++ src/node.js | 4 ++++ 3 files changed, 24 insertions(+) diff --git a/src/browser.js b/src/browser.js index ac3f7e13..cd0fc35d 100644 --- a/src/browser.js +++ b/src/browser.js @@ -9,6 +9,16 @@ exports.save = save; exports.load = load; exports.useColors = useColors; exports.storage = localstorage(); +exports.destroy = (() => { + let warned = false; + + return () => { + if (!warned) { + warned = true; + console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); + } + }; +})(); /** * Colors. diff --git a/src/common.js b/src/common.js index 9d7e4dce..392a8e00 100644 --- a/src/common.js +++ b/src/common.js @@ -12,6 +12,7 @@ function setup(env) { createDebug.enable = enable; createDebug.enabled = enabled; createDebug.humanize = require('ms'); + createDebug.destroy = destroy; Object.keys(env).forEach(key => { createDebug[key] = env[key]; @@ -114,6 +115,7 @@ function setup(env) { debug.useColors = createDebug.useColors(); debug.color = createDebug.selectColor(namespace); debug.extend = extend; + debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release. Object.defineProperty(debug, 'enabled', { enumerable: true, @@ -243,6 +245,14 @@ function setup(env) { return val; } + /** + * XXX DO NOT USE. This is a temporary stub function. + * XXX It WILL be removed in the next major release. + */ + function destroy() { + console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); + } + createDebug.enable(createDebug.load()); return createDebug; diff --git a/src/node.js b/src/node.js index 5e1f1541..12a11f40 100644 --- a/src/node.js +++ b/src/node.js @@ -15,6 +15,10 @@ exports.formatArgs = formatArgs; exports.save = save; exports.load = load; exports.useColors = useColors; +exports.destroy = util.deprecate( + () => {}, + 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.' +); /** * Colors. From 3f56313c1e4a0d59c1054fb9b10026b6903bfba7 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Sat, 19 Sep 2020 10:35:28 +0200 Subject: [PATCH 227/257] 4.3.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c270ca0e..c4e19aa1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "4.2.0", + "version": "4.3.0", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From b6d12fdbc63b483e5c969da33ea6adc09946b5ac Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Thu, 19 Nov 2020 12:31:16 +0100 Subject: [PATCH 228/257] fix regression --- src/node.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/node.js b/src/node.js index 12a11f40..79bc085c 100644 --- a/src/node.js +++ b/src/node.js @@ -248,7 +248,9 @@ const {formatters} = module.exports; formatters.o = function (v) { this.inspectOpts.colors = this.useColors; return util.inspect(v, this.inspectOpts) - .replace(/\s*\n\s*/g, ' '); + .split('\n') + .map(str => str.trim()) + .join(' '); }; /** From 0d3d66b0eb47c5d34e1a940e8a204446fdd832cd Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Thu, 19 Nov 2020 13:15:13 +0100 Subject: [PATCH 229/257] 4.3.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c4e19aa1..da809d2b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "4.3.0", + "version": "4.3.1", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From 1e9d38c2e6e170abde6cfeaf7b2024d8b456f906 Mon Sep 17 00:00:00 2001 From: omg Date: Wed, 9 Dec 2020 17:34:56 +0200 Subject: [PATCH 230/257] cache enabled status per-logger (#799) Co-authored-by: Qix --- src/common.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/common.js b/src/common.js index 392a8e00..50ce2925 100644 --- a/src/common.js +++ b/src/common.js @@ -60,6 +60,8 @@ function setup(env) { function createDebug(namespace) { let prevTime; let enableOverride = null; + let namespacesCache; + let enabledCache; function debug(...args) { // Disabled? @@ -120,7 +122,17 @@ function setup(env) { Object.defineProperty(debug, 'enabled', { enumerable: true, configurable: false, - get: () => enableOverride === null ? createDebug.enabled(namespace) : enableOverride, + get: () => { + if (enableOverride !== null) { + return enableOverride; + } + if (namespacesCache !== createDebug.namespaces) { + namespacesCache = createDebug.namespaces; + enabledCache = createDebug.enabled(namespace); + } + + return enabledCache; + }, set: v => { enableOverride = v; } @@ -149,6 +161,7 @@ function setup(env) { */ function enable(namespaces) { createDebug.save(namespaces); + createDebug.namespaces = namespaces; createDebug.names = []; createDebug.skips = []; From e47f96de3de5921584364b4ac91e2769d22a3b1f Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Wed, 9 Dec 2020 16:35:38 +0100 Subject: [PATCH 231/257] 4.3.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index da809d2b..b7d70acb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "4.3.1", + "version": "4.3.2", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" From d177f2bc36d3b8b8e9b1b006727ef5e04f98eac7 Mon Sep 17 00:00:00 2001 From: Taylor Everding Date: Fri, 21 May 2021 13:51:30 -0600 Subject: [PATCH 232/257] Remove accidental epizeuxis --- src/common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.js b/src/common.js index 50ce2925..6d571d28 100644 --- a/src/common.js +++ b/src/common.js @@ -34,7 +34,7 @@ function setup(env) { /** * Selects a color for a debug namespace - * @param {String} namespace The namespace string for the for the debug instance to be colored + * @param {String} namespace The namespace string for the debug instance to be colored * @return {Number|String} An ANSI color code for the given namespace * @api private */ From f851b00eb006d400e757dca33568773910365519 Mon Sep 17 00:00:00 2001 From: Kristof Kalocsai Date: Wed, 13 Oct 2021 21:14:14 +0200 Subject: [PATCH 233/257] adds README section regarding usage in child procs (#850) * adds README section regarding usage in child procs code example and original request copied from @aaarichter should close #811 * Update README.md Co-authored-by: Qix Co-authored-by: Qix --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index 88dae35d..3b168838 100644 --- a/README.md +++ b/README.md @@ -351,6 +351,27 @@ if (debug.enabled) { You can also manually toggle this property to force the debug instance to be enabled or disabled. +## Usage in child processes + +Due to the way `debug` detects if the output is a TTY or not, colors are not shown in child processes when `stderr` is piped. A solution is to pass the `DEBUG_COLORS=1` environment variable to the child process. +For example: + +```javascript +worker = fork(WORKER_WRAP_PATH, [workerPath], { + stdio: [ + /* stdin: */ 0, + /* stdout: */ 'pipe', + /* stderr: */ 'pipe', + 'ipc', + ], + env: Object.assign({}, process.env, { + DEBUG_COLORS: 1 // without this settings, colors won't be shown + }), +}); + +worker.stderr.pipe(process.stderr, { end: false }); +``` + ## Authors From 19b36c052ab0084f8b1c86d34d3e82190680246a Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Sat, 27 Nov 2021 14:00:16 +0100 Subject: [PATCH 234/257] update repository location + maintainership information --- README.md | 2 +- package.json | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3b168838..3457f655 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # debug -[![Build Status](https://travis-ci.org/visionmedia/debug.svg?branch=master)](https://travis-ci.org/visionmedia/debug) [![Coverage Status](https://coveralls.io/repos/github/visionmedia/debug/badge.svg?branch=master)](https://coveralls.io/github/visionmedia/debug?branch=master) [![Slack](https://visionmedia-community-slackin.now.sh/badge.svg)](https://visionmedia-community-slackin.now.sh/) [![OpenCollective](https://opencollective.com/debug/backers/badge.svg)](#backers) +[![Build Status](https://travis-ci.org/debug-js/debug.svg?branch=master)](https://travis-ci.org/debug-js/debug) [![Coverage Status](https://coveralls.io/repos/github/debug-js/debug/badge.svg?branch=master)](https://coveralls.io/github/debug-js/debug?branch=master) [![Slack](https://visionmedia-community-slackin.now.sh/badge.svg)](https://visionmedia-community-slackin.now.sh/) [![OpenCollective](https://opencollective.com/debug/backers/badge.svg)](#backers) [![OpenCollective](https://opencollective.com/debug/sponsors/badge.svg)](#sponsors) diff --git a/package.json b/package.json index b7d70acb..9cd2a2d7 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,9 @@ "version": "4.3.2", "repository": { "type": "git", - "url": "git://github.com/visionmedia/debug.git" + "url": "git://github.com/debug-js/debug.git" }, - "description": "small debugging utility", + "description": "Lightweight debugging utility for Node.js and the browser", "keywords": [ "debug", "log", @@ -16,11 +16,11 @@ "LICENSE", "README.md" ], - "author": "TJ Holowaychuk ", + "author": "Josh Junon ", "contributors": [ + "TJ Holowaychuk ", "Nathan Rajlich (http://n8.io)", - "Andrew Rhyne ", - "Josh Junon " + "Andrew Rhyne " ], "license": "MIT", "scripts": { From 4079aae5b5bf1198ecd2e1032609dfd46bec843f Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Sat, 27 Nov 2021 14:01:16 +0100 Subject: [PATCH 235/257] update license and more maintainership information --- LICENSE | 19 ++++++++++--------- README.md | 2 ++ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/LICENSE b/LICENSE index 658c933d..1a9820e2 100644 --- a/LICENSE +++ b/LICENSE @@ -1,19 +1,20 @@ (The MIT License) -Copyright (c) 2014 TJ Holowaychuk +Copyright (c) 2014-2017 TJ Holowaychuk +Copyright (c) 2018-2021 Josh Junon -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the 'Software'), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the 'Software'), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all copies or substantial +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT -LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT +LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index 3457f655..5ea4cd27 100644 --- a/README.md +++ b/README.md @@ -378,6 +378,7 @@ worker.stderr.pipe(process.stderr, { end: false }); - TJ Holowaychuk - Nathan Rajlich - Andrew Rhyne + - Josh Junon ## Backers @@ -455,6 +456,7 @@ Become a sponsor and get your logo on our README on Github with a link to your s (The MIT License) Copyright (c) 2014-2017 TJ Holowaychuk <tj@vision-media.ca> +Copyright (c) 2018-2021 Josh Junon Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the From 043d3cd17d30af45f71d2beab4ec7abfc9936e9e Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Sat, 27 Nov 2021 14:01:35 +0100 Subject: [PATCH 236/257] 4.3.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9cd2a2d7..cb7efa8e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "4.3.2", + "version": "4.3.3", "repository": { "type": "git", "url": "git://github.com/debug-js/debug.git" From c0805cc4d3b2c7c987567e99ecaec78840516d7b Mon Sep 17 00:00:00 2001 From: gitname Date: Wed, 2 Feb 2022 16:34:39 -0800 Subject: [PATCH 237/257] add section about configuring JS console to show debug messages (#866) * Add section about configuring JS console to show debug messages * Rewrite log level section to be more concise --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 5ea4cd27..e9c3e047 100644 --- a/README.md +++ b/README.md @@ -241,6 +241,9 @@ setInterval(function(){ }, 1200); ``` +In Chromium-based web browsers (e.g. Brave, Chrome, and Electron), the JavaScript console will—by default—only show messages logged by `debug` if the "Verbose" log level is _enabled_. + + ## Output streams From 9b334123f1331a252bc27c99c33b5c4f199d200f Mon Sep 17 00:00:00 2001 From: CommanderRoot Date: Thu, 17 Mar 2022 14:36:24 +0100 Subject: [PATCH 238/257] replace deprecated String.prototype.substr() (#876) String.prototype.substr() is deprecated (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr) so we replace it with slice() which works similarily but isn't deprecated. Signed-off-by: Tobias Speicher --- src/common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.js b/src/common.js index 6d571d28..e3291b20 100644 --- a/src/common.js +++ b/src/common.js @@ -179,7 +179,7 @@ function setup(env) { namespaces = split[i].replace(/\*/g, '.*?'); if (namespaces[0] === '-') { - createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); + createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$')); } else { createDebug.names.push(new RegExp('^' + namespaces + '$')); } From da66c86c5fd71ef570f36b5b1edfa4472149f1bc Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Thu, 17 Mar 2022 14:38:08 +0100 Subject: [PATCH 239/257] 4.3.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cb7efa8e..3bcdc242 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "4.3.3", + "version": "4.3.4", "repository": { "type": "git", "url": "git://github.com/debug-js/debug.git" From 12c1ad04db972bbb40d49c952f8f8da6871c7216 Mon Sep 17 00:00:00 2001 From: Qix Date: Thu, 31 Mar 2022 17:24:37 +0200 Subject: [PATCH 240/257] Update ISSUE_TEMPLATE.md --- .github/ISSUE_TEMPLATE.md | 58 +++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 58858535..f674f400 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,28 +1,38 @@ From d1616622e4d404863c5a98443f755b4006e971dc Mon Sep 17 00:00:00 2001 From: Qix Date: Thu, 31 Mar 2022 17:43:51 +0200 Subject: [PATCH 241/257] Update ISSUE_TEMPLATE.md --- .github/ISSUE_TEMPLATE.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index f674f400..62c47e32 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,11 +1,12 @@ diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index af3da470..00000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,17 +0,0 @@ - From cac39b1c5b018b0fe93a53a05f084eee543d17f5 Mon Sep 17 00:00:00 2001 From: calvintwr Date: Fri, 31 May 2024 19:34:49 +0800 Subject: [PATCH 243/257] Fix/debug depth (#926) * fix debug format options ignored * moved sinon to devDependencies --- package.json | 3 ++- src/node.js | 4 ++-- test.node.js | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 test.node.js diff --git a/package.json b/package.json index 3bcdc242..5da3cfeb 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "scripts": { "lint": "xo", "test": "npm run test:node && npm run test:browser && npm run lint", - "test:node": "istanbul cover _mocha -- test.js", + "test:node": "istanbul cover _mocha -- test.js test.node.js", "test:browser": "karma start --single-run", "test:coverage": "cat ./coverage/lcov.info | coveralls" }, @@ -44,6 +44,7 @@ "karma-mocha": "^1.3.0", "mocha": "^5.2.0", "mocha-lcov-reporter": "^1.2.0", + "sinon": "^14.0.0", "xo": "^0.23.0" }, "peerDependenciesMeta": { diff --git a/src/node.js b/src/node.js index 79bc085c..715560a4 100644 --- a/src/node.js +++ b/src/node.js @@ -187,11 +187,11 @@ function getDate() { } /** - * Invokes `util.format()` with the specified arguments and writes to stderr. + * Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr. */ function log(...args) { - return process.stderr.write(util.format(...args) + '\n'); + return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n'); } /** diff --git a/test.node.js b/test.node.js new file mode 100644 index 00000000..4cc3c051 --- /dev/null +++ b/test.node.js @@ -0,0 +1,40 @@ +/* eslint-env mocha */ + +const assert = require('assert'); +const util = require('util'); +const sinon = require('sinon'); +const debug = require('./src/node'); + +const formatWithOptionsSpy = sinon.spy(util, 'formatWithOptions'); +beforeEach(() => { + formatWithOptionsSpy.resetHistory(); +}); + +describe('debug node', () => { + describe('formatting options', () => { + it('calls util.formatWithOptions', () => { + debug.enable('*'); + const stdErrWriteStub = sinon.stub(process.stderr, 'write'); + const log = debug('formatting options'); + log('hello world'); + assert(util.formatWithOptions.callCount === 1); + stdErrWriteStub.restore(); + }); + + it('calls util.formatWithOptions with inspectOpts', () => { + debug.enable('*'); + const options = { + hideDate: true, + colors: true, + depth: 10, + showHidden: true + }; + Object.assign(debug.inspectOpts, options); + const stdErrWriteStub = sinon.stub(process.stderr, 'write'); + const log = debug('format with inspectOpts'); + log('hello world2'); + assert.deepStrictEqual(util.formatWithOptions.getCall(0).args[0], options); + stdErrWriteStub.restore(); + }); + }); +}); From f244ada2e98b30a09b42e6f85e8d4ac3f038d2d6 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Fri, 31 May 2024 13:37:01 +0200 Subject: [PATCH 244/257] update authorship contact info --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5da3cfeb..f498861c 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "LICENSE", "README.md" ], - "author": "Josh Junon ", + "author": "Josh Junon (https://github.com/qix-)", "contributors": [ "TJ Holowaychuk ", "Nathan Rajlich (http://n8.io)", From 5464bdddbc6f91b2aef2ad20650d3a6cfd9fcc3a Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Fri, 31 May 2024 13:37:42 +0200 Subject: [PATCH 245/257] 4.3.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f498861c..cb671038 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "4.3.4", + "version": "4.3.5", "repository": { "type": "git", "url": "git://github.com/debug-js/debug.git" From 7956a45f683924a1fce672dcfb15a1fb8a762c60 Mon Sep 17 00:00:00 2001 From: bluwy Date: Fri, 26 Jul 2024 18:21:29 +0800 Subject: [PATCH 246/257] Avoid using deprecated RegExp.$1 --- src/browser.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/browser.js b/src/browser.js index cd0fc35d..8d808e58 100644 --- a/src/browser.js +++ b/src/browser.js @@ -125,6 +125,8 @@ function useColors() { return false; } + let m; + // Is webkit? http://stackoverflow.com/a/16459606/376773 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || @@ -132,7 +134,7 @@ function useColors() { (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || // Is firefox >= v31? // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || + (typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) || // Double check webkit in userAgent just in case we are in a worker (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); } From c33b464a797d6cf8c72b8d84d87e02b2822494c9 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Sat, 27 Jul 2024 11:19:57 +0200 Subject: [PATCH 247/257] 4.3.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cb671038..8eea0552 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "4.3.5", + "version": "4.3.6", "repository": { "type": "git", "url": "git://github.com/debug-js/debug.git" From 382864a45a782a84b29e457211c27704df77a75f Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Wed, 7 Aug 2024 18:49:53 +0200 Subject: [PATCH 248/257] remove archaic badges from readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e9c3e047..9ebdfbf1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # debug -[![Build Status](https://travis-ci.org/debug-js/debug.svg?branch=master)](https://travis-ci.org/debug-js/debug) [![Coverage Status](https://coveralls.io/repos/github/debug-js/debug/badge.svg?branch=master)](https://coveralls.io/github/debug-js/debug?branch=master) [![Slack](https://visionmedia-community-slackin.now.sh/badge.svg)](https://visionmedia-community-slackin.now.sh/) [![OpenCollective](https://opencollective.com/debug/backers/badge.svg)](#backers) +[![OpenCollective](https://opencollective.com/debug/backers/badge.svg)](#backers) [![OpenCollective](https://opencollective.com/debug/sponsors/badge.svg)](#sponsors) From c63e96e6495cdb8e15d2affa8dad105c48a21c92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rouven=20We=C3=9Fling?= Date: Fri, 6 Sep 2024 02:48:50 +0200 Subject: [PATCH 249/257] Upgrade ms to version 2.1.3 (#819) * Upgrade ms to version 2.1.3 * Update package.json Co-authored-by: Superchupu <53496941+SuperchupuDev@users.noreply.github.com> --------- Co-authored-by: Josh Junon Co-authored-by: Superchupu <53496941+SuperchupuDev@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8eea0552..26146ca5 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "test:coverage": "cat ./coverage/lcov.info | coveralls" }, "dependencies": { - "ms": "2.1.2" + "ms": "^2.1.3" }, "devDependencies": { "brfs": "^2.0.1", From bc60914816e5e45a5fff1cd638410438fc317521 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Fri, 6 Sep 2024 02:50:18 +0200 Subject: [PATCH 250/257] 4.3.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 26146ca5..2f782eb9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "4.3.6", + "version": "4.3.7", "repository": { "type": "git", "url": "git://github.com/debug-js/debug.git" From d2d6bf0bab3a0eeeb3a9ce7113cb0a31d8da678f Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Fri, 6 Dec 2024 13:27:40 +0100 Subject: [PATCH 251/257] fix inefficient .enable() regex and .enabled() test --- package.json | 5 +++ src/browser.js | 1 + src/common.js | 96 ++++++++++++++++++++++++++++++-------------------- 3 files changed, 63 insertions(+), 39 deletions(-) diff --git a/package.json b/package.json index 2f782eb9..f2050bc1 100644 --- a/package.json +++ b/package.json @@ -56,5 +56,10 @@ "browser": "./src/browser.js", "engines": { "node": ">=6.0" + }, + "xo": { + "rules": { + "import/extensions": "off" + } } } diff --git a/src/browser.js b/src/browser.js index 8d808e58..df8e179e 100644 --- a/src/browser.js +++ b/src/browser.js @@ -129,6 +129,7 @@ function useColors() { // Is webkit? http://stackoverflow.com/a/16459606/376773 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 + // eslint-disable-next-line no-return-assign return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || // Is firebug? http://stackoverflow.com/a/398120/376773 (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || diff --git a/src/common.js b/src/common.js index e3291b20..528c7ecf 100644 --- a/src/common.js +++ b/src/common.js @@ -166,24 +166,62 @@ function setup(env) { createDebug.names = []; createDebug.skips = []; - let i; - const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); - const len = split.length; - - for (i = 0; i < len; i++) { - if (!split[i]) { - // ignore empty strings - continue; + const split = (typeof namespaces === 'string' ? namespaces : '') + .trim() + .replace(' ', ',') + .split(',') + .filter(Boolean); + + for (const ns of split) { + if (ns[0] === '-') { + createDebug.skips.push(ns.slice(1)); + } else { + createDebug.names.push(ns); } + } + } - namespaces = split[i].replace(/\*/g, '.*?'); - - if (namespaces[0] === '-') { - createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$')); + /** + * Checks if the given string matches a namespace template, honoring + * asterisks as wildcards. + * + * @param {String} search + * @param {String} template + * @return {Boolean} + */ + function matchesTemplate(search, template) { + let searchIndex = 0; + let templateIndex = 0; + let starIndex = -1; + let matchIndex = 0; + + while (searchIndex < search.length) { + if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) { + // Match character or proceed with wildcard + if (template[templateIndex] === '*') { + starIndex = templateIndex; + matchIndex = searchIndex; + templateIndex++; // Skip the '*' + } else { + searchIndex++; + templateIndex++; + } + } else if (starIndex !== -1) { // eslint-disable-line no-negated-condition + // Backtrack to the last '*' and try to match more characters + templateIndex = starIndex + 1; + matchIndex++; + searchIndex = matchIndex; } else { - createDebug.names.push(new RegExp('^' + namespaces + '$')); + return false; // No match } } + + // Handle trailing '*' in template + while (templateIndex < template.length && template[templateIndex] === '*') { + templateIndex++; + } + + return templateIndex === template.length; } /** @@ -194,8 +232,8 @@ function setup(env) { */ function disable() { const namespaces = [ - ...createDebug.names.map(toNamespace), - ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace) + ...createDebug.names, + ...createDebug.skips.map(namespace => '-' + namespace) ].join(','); createDebug.enable(''); return namespaces; @@ -209,21 +247,14 @@ function setup(env) { * @api public */ function enabled(name) { - if (name[name.length - 1] === '*') { - return true; - } - - let i; - let len; - - for (i = 0, len = createDebug.skips.length; i < len; i++) { - if (createDebug.skips[i].test(name)) { + for (const skip of createDebug.skips) { + if (matchesTemplate(name, skip)) { return false; } } - for (i = 0, len = createDebug.names.length; i < len; i++) { - if (createDebug.names[i].test(name)) { + for (const ns of createDebug.names) { + if (matchesTemplate(name, ns)) { return true; } } @@ -231,19 +262,6 @@ function setup(env) { return false; } - /** - * Convert regexp to namespace - * - * @param {RegExp} regxep - * @return {String} namespace - * @api private - */ - function toNamespace(regexp) { - return regexp.toString() - .substring(2, regexp.toString().length - 2) - .replace(/\.\*\?$/, '*'); - } - /** * Coerce `val`. * From 7e3814cc603bf64fdd69e714e0cf5611ec31f43b Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Fri, 6 Dec 2024 13:30:15 +0100 Subject: [PATCH 252/257] 4.4.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f2050bc1..60dfcf57 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "4.3.7", + "version": "4.4.0", "repository": { "type": "git", "url": "git://github.com/debug-js/debug.git" From a0497bd46dacb701437f62cfc065dc72bf0952c7 Mon Sep 17 00:00:00 2001 From: Prabhat Dahal Date: Fri, 21 Mar 2025 10:44:33 -0500 Subject: [PATCH 253/257] Replace whitespaces in namespaces string with commas globally instead of just the first space occurrence. (#997) Co-authored-by: Prabhat Dahal --- src/common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.js b/src/common.js index 528c7ecf..141cb578 100644 --- a/src/common.js +++ b/src/common.js @@ -168,7 +168,7 @@ function setup(env) { const split = (typeof namespaces === 'string' ? namespaces : '') .trim() - .replace(' ', ',') + .replace(/\s+/g, ',') .split(',') .filter(Boolean); From bf2f574c3e588ce4b660bf4e392e7a5e788640c0 Mon Sep 17 00:00:00 2001 From: Luke Zilioli Date: Sun, 23 Mar 2025 18:28:01 -0400 Subject: [PATCH 254/257] fixes #987 fallback to localStorage.DEBUG if debug is not defined (#988) --- src/browser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/browser.js b/src/browser.js index df8e179e..5993451b 100644 --- a/src/browser.js +++ b/src/browser.js @@ -219,7 +219,7 @@ function save(namespaces) { function load() { let r; try { - r = exports.storage.getItem('debug'); + r = exports.storage.getItem('debug') || exports.storage.getItem('DEBUG') ; } catch (error) { // Swallow // XXX (@Qix-) should we be logging these? From 98df33ed9d5215c1d801b74e6ab00969759a6839 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Tue, 13 May 2025 22:53:29 +0200 Subject: [PATCH 255/257] remove istanbul --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 60dfcf57..20d2b670 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "scripts": { "lint": "xo", "test": "npm run test:node && npm run test:browser && npm run lint", - "test:node": "istanbul cover _mocha -- test.js test.node.js", + "test:node": "mocha test.js test.node.js", "test:browser": "karma start --single-run", "test:coverage": "cat ./coverage/lcov.info | coveralls" }, @@ -37,7 +37,6 @@ "brfs": "^2.0.1", "browserify": "^16.2.3", "coveralls": "^3.0.2", - "istanbul": "^0.4.5", "karma": "^3.1.4", "karma-browserify": "^6.0.0", "karma-chrome-launcher": "^2.2.0", From 33330fa8616b9b33f29f7674747be77266878ba6 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Tue, 13 May 2025 22:55:39 +0200 Subject: [PATCH 256/257] 4.4.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 20d2b670..afc2f8b6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "4.4.0", + "version": "4.4.1", "repository": { "type": "git", "url": "git://github.com/debug-js/debug.git" From 6b2c5fbdb7d414483d9e306ef234acb4cd7ea67c Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Sat, 13 Sep 2025 19:24:41 +0200 Subject: [PATCH 257/257] 4.4.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index afc2f8b6..ee8abb52 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "4.4.1", + "version": "4.4.3", "repository": { "type": "git", "url": "git://github.com/debug-js/debug.git"