Skip to content

Commit e355b1a

Browse files
authored
Replace get-func-name with Function.prototype.name (#24)
1 parent 6ff6a00 commit e355b1a

File tree

3 files changed

+1620
-1821
lines changed

3 files changed

+1620
-1821
lines changed

index.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import getFunctionName from 'get-func-name';
2-
31
/**
42
* ### .compatibleInstance(thrown, errorLike)
53
*
@@ -85,14 +83,14 @@ function compatibleMessage(thrown, errMatcher) {
8583
function getConstructorName(errorLike) {
8684
let constructorName = errorLike;
8785
if (errorLike instanceof Error) {
88-
constructorName = getFunctionName(errorLike.constructor);
86+
constructorName = errorLike.constructor.name;
8987
} else if (typeof errorLike === 'function') {
9088
// If `err` is not an instance of Error it is an error constructor itself or another function.
9189
// If we've got a common function we get its name, otherwise we may need to create a new instance
9290
// of the error just in case it's a poorly-constructed error. Please see chaijs/chai/issues/45 to know more.
93-
constructorName = getFunctionName(errorLike);
91+
constructorName = errorLike.name;
9492
if (constructorName === '') {
95-
const newConstructorName = getFunctionName(new errorLike()); // eslint-disable-line new-cap
93+
const newConstructorName = (new errorLike().name); // eslint-disable-line new-cap
9694
constructorName = newConstructorName || constructorName;
9795
}
9896
}

0 commit comments

Comments
 (0)