Skip to content

Commit

Permalink
add deprecation notice for debug.destroy()
Browse files Browse the repository at this point in the history
  • Loading branch information
Qix- committed Sep 19, 2020
1 parent 72e7f86 commit e2d3bc9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 10 additions & 0 deletions src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit e2d3bc9

Please sign in to comment.