Skip to content

Commit

Permalink
[Refactor] use is-regex instead of instanceof RegExp
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jul 29, 2019
1 parent 24487cb commit 8150c3b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/test.js
Expand Up @@ -4,6 +4,7 @@ var path = require('path');
var inherits = require('inherits');
var EventEmitter = require('events').EventEmitter;
var has = require('has');
var isRegExp = require('is-regex');
var trim = require('string.prototype.trim');
var bind = require('function-bind');
var forEach = require('for-each');
Expand Down Expand Up @@ -502,7 +503,7 @@ Test.prototype['throws'] = function (fn, expected, msg, extra) {

var passed = caught;

if (expected instanceof RegExp) {
if (isRegExp(expected)) {
passed = expected.test(caught && caught.error);
expected = String(expected);
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -16,6 +16,7 @@
"glob": "~7.1.4",
"has": "~1.0.3",
"inherits": "~2.0.4",
"is-regex": "~1.0.4",
"minimist": "~1.2.0",
"object-inspect": "~1.6.0",
"resolve": "~1.11.1",
Expand Down

0 comments on commit 8150c3b

Please sign in to comment.