aboutsummaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/is-callable/index.js
diff options
context:
space:
mode:
authorisaacs <nope@not.real>2019-07-03 10:23:19 -0700
committerRich Trott <rtrott@gmail.com>2019-07-18 15:12:49 -0700
commit1721034a40c5e7a0a334701dc36153adee3f27e5 (patch)
tree7b2ce5a0c5d67d2e1d817fc548571250e8c1a305 /deps/npm/node_modules/is-callable/index.js
parent6df7b6a4f9cb64d298e7fd0691c4d09679872922 (diff)
downloadandroid-node-v8-1721034a40c5e7a0a334701dc36153adee3f27e5.tar.gz
android-node-v8-1721034a40c5e7a0a334701dc36153adee3f27e5.tar.bz2
android-node-v8-1721034a40c5e7a0a334701dc36153adee3f27e5.zip
deps: upgrade npm to 6.10.0
PR-URL: https://github.com/nodejs/node/pull/28525 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Diffstat (limited to 'deps/npm/node_modules/is-callable/index.js')
-rw-r--r--deps/npm/node_modules/is-callable/index.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/deps/npm/node_modules/is-callable/index.js b/deps/npm/node_modules/is-callable/index.js
new file mode 100644
index 0000000000..d9820b51fd
--- /dev/null
+++ b/deps/npm/node_modules/is-callable/index.js
@@ -0,0 +1,37 @@
+'use strict';
+
+var fnToStr = Function.prototype.toString;
+
+var constructorRegex = /^\s*class\b/;
+var isES6ClassFn = function isES6ClassFunction(value) {
+ try {
+ var fnStr = fnToStr.call(value);
+ return constructorRegex.test(fnStr);
+ } catch (e) {
+ return false; // not a function
+ }
+};
+
+var tryFunctionObject = function tryFunctionToStr(value) {
+ try {
+ if (isES6ClassFn(value)) { return false; }
+ fnToStr.call(value);
+ return true;
+ } catch (e) {
+ return false;
+ }
+};
+var toStr = Object.prototype.toString;
+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;
+};