inherits.js 663 B

12345678910111213141516171819202122232425
  1. var inherits;
  2. if (typeof Object.create === 'function'){
  3. inherits = function inherits(ctor, superCtor) {
  4. // implementation from standard node.js 'util' module
  5. ctor.super_ = superCtor
  6. ctor.prototype = Object.create(superCtor.prototype, {
  7. constructor: {
  8. value: ctor,
  9. enumerable: false,
  10. writable: true,
  11. configurable: true
  12. }
  13. });
  14. };
  15. } else {
  16. inherits = function inherits(ctor, superCtor) {
  17. ctor.super_ = superCtor
  18. var TempCtor = function () {}
  19. TempCtor.prototype = superCtor.prototype
  20. ctor.prototype = new TempCtor()
  21. ctor.prototype.constructor = ctor
  22. }
  23. }
  24. export default inherits;