summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/node_modules/is-callable/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/node_modules/eslint/node_modules/is-callable/index.js')
-rw-r--r--tools/node_modules/eslint/node_modules/is-callable/index.js12
1 files changed, 5 insertions, 7 deletions
diff --git a/tools/node_modules/eslint/node_modules/is-callable/index.js b/tools/node_modules/eslint/node_modules/is-callable/index.js
index 9e70b7978a..d9820b51fd 100644
--- a/tools/node_modules/eslint/node_modules/is-callable/index.js
+++ b/tools/node_modules/eslint/node_modules/is-callable/index.js
@@ -2,20 +2,17 @@
var fnToStr = Function.prototype.toString;
-var constructorRegex = /^\s*class /;
-var isES6ClassFn = function isES6ClassFn(value) {
+var constructorRegex = /^\s*class\b/;
+var isES6ClassFn = function isES6ClassFunction(value) {
try {
var fnStr = fnToStr.call(value);
- var singleStripped = fnStr.replace(/\/\/.*\n/g, '');
- var multiStripped = singleStripped.replace(/\/\*[.\s\S]*\*\//g, '');
- var spaceStripped = multiStripped.replace(/\n/mg, ' ').replace(/ {2}/g, ' ');
- return constructorRegex.test(spaceStripped);
+ return constructorRegex.test(fnStr);
} catch (e) {
return false; // not a function
}
};
-var tryFunctionObject = function tryFunctionObject(value) {
+var tryFunctionObject = function tryFunctionToStr(value) {
try {
if (isES6ClassFn(value)) { return false; }
fnToStr.call(value);
@@ -32,6 +29,7 @@ var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag =
module.exports = function isCallable(value) {
if (!value) { return false; }
if (typeof value !== 'function' && typeof value !== 'object') { return false; }
+ if (typeof value === 'function' && !value.prototype) { return true; }
if (hasToStringTag) { return tryFunctionObject(value); }
if (isES6ClassFn(value)) { return false; }
var strClass = toStr.call(value);