mirror of
https://github.com/actions/labeler.git
synced 2025-12-17 07:32:20 +00:00
build
This commit is contained in:
47
node_modules/is-callable/index.js
generated
vendored
47
node_modules/is-callable/index.js
generated
vendored
@@ -1,6 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
var fnToStr = Function.prototype.toString;
|
||||
var reflectApply = typeof Reflect === 'object' && Reflect !== null && Reflect.apply;
|
||||
var badArrayLike;
|
||||
var isCallableMarker;
|
||||
if (typeof reflectApply === 'function' && typeof Object.defineProperty === 'function') {
|
||||
try {
|
||||
badArrayLike = Object.defineProperty({}, 'length', {
|
||||
get: function () {
|
||||
throw isCallableMarker;
|
||||
}
|
||||
});
|
||||
isCallableMarker = {};
|
||||
} catch (_) {
|
||||
reflectApply = null;
|
||||
}
|
||||
} else {
|
||||
reflectApply = null;
|
||||
}
|
||||
|
||||
var constructorRegex = /^\s*class\b/;
|
||||
var isES6ClassFn = function isES6ClassFunction(value) {
|
||||
@@ -26,12 +43,24 @@ var fnClass = '[object Function]';
|
||||
var genClass = '[object GeneratorFunction]';
|
||||
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
|
||||
|
||||
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);
|
||||
return strClass === fnClass || strClass === genClass;
|
||||
};
|
||||
module.exports = reflectApply
|
||||
? function isCallable(value) {
|
||||
if (!value) { return false; }
|
||||
if (typeof value !== 'function' && typeof value !== 'object') { return false; }
|
||||
if (typeof value === 'function' && !value.prototype) { return true; }
|
||||
try {
|
||||
reflectApply(value, null, badArrayLike);
|
||||
} catch (e) {
|
||||
if (e !== isCallableMarker) { return false; }
|
||||
}
|
||||
return !isES6ClassFn(value);
|
||||
}
|
||||
: 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);
|
||||
return strClass === fnClass || strClass === genClass;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user