inherits.js 550 B

123456789101112131415
  1. export default (function (subClass, superClass) {
  2. if (typeof superClass !== "function" && superClass !== null) {
  3. throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
  4. }
  5. subClass.prototype = Object.create(superClass && superClass.prototype, {
  6. constructor: {
  7. value: subClass,
  8. enumerable: false,
  9. writable: true,
  10. configurable: true
  11. }
  12. });
  13. if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
  14. });