classUtils.js 438 B

1234567891011121314151617181920
  1. function isSubclassOf(Constructor, SuperConstructor) {
  2. if (typeof SuperConstructor !== 'function') {
  3. return false;
  4. }
  5. while (typeof Constructor === 'function') {
  6. if (Constructor === SuperConstructor) {
  7. return true;
  8. }
  9. const proto = Constructor.prototype && Object.getPrototypeOf(Constructor.prototype);
  10. Constructor = proto && proto.constructor;
  11. }
  12. return false;
  13. }
  14. module.exports = {
  15. isSubclassOf
  16. };