All files / src/utils isClass.js

58.33% Statements 7/12
46.15% Branches 6/13
50% Functions 2/4
58.33% Lines 7/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33  5x 5x                   1x             5x 5x 5x   5x                  
//https://github.com/miguelmota/is-class
(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
    );
  }
 
  Eif (typeof exports !== "undefined") {
    Eif (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);