You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
733 B
29 lines
733 B
1 month ago
|
(function(root) {
|
||
|
var toString = Function.prototype.toString;
|
||
|
|
||
|
function fnBody(fn) {
|
||
|
return toString.call(fn).replace(/^[^{]*{\s*/,'').replace(/\s*}[^}]*$/,'');
|
||
|
}
|
||
|
|
||
|
function isClass(fn) {
|
||
|
return (typeof fn === 'function' &&
|
||
|
(/^class(?:\s|{)/.test(toString.call(fn)) ||
|
||
|
(/^.*classCallCheck\(/.test(fnBody(fn)))) // babel.js
|
||
|
);
|
||
|
}
|
||
|
|
||
|
if (typeof exports !== 'undefined') {
|
||
|
if (typeof module !== 'undefined' && module.exports) {
|
||
|
exports = module.exports = isClass;
|
||
|
}
|
||
|
exports.isClass = isClass;
|
||
|
} else if (typeof define === 'function' && define.amd) {
|
||
|
define([], function() {
|
||
|
return isClass;
|
||
|
});
|
||
|
} else {
|
||
|
root.isClass = isClass;
|
||
|
}
|
||
|
|
||
|
})(this);
|