Skip to content

Commit

Permalink
don't call splice() when indexOf() returns -1
Browse files Browse the repository at this point in the history
  • Loading branch information
TooTallNate committed Aug 8, 2017
1 parent 02eb3c6 commit 25e07c7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/debug.js
Expand Up @@ -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;
}
}

/**
Expand Down

0 comments on commit 25e07c7

Please sign in to comment.