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.

index.js 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  7. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  8. function _extendableBuiltin(cls) {
  9. function ExtendableBuiltin() {
  10. cls.apply(this, arguments);
  11. }
  12. ExtendableBuiltin.prototype = Object.create(cls.prototype, {
  13. constructor: {
  14. value: cls,
  15. enumerable: false,
  16. writable: true,
  17. configurable: true
  18. }
  19. });
  20. if (Object.setPrototypeOf) {
  21. Object.setPrototypeOf(ExtendableBuiltin, cls);
  22. } else {
  23. ExtendableBuiltin.__proto__ = cls;
  24. }
  25. return ExtendableBuiltin;
  26. }
  27. var ExtendableError = function (_extendableBuiltin2) {
  28. _inherits(ExtendableError, _extendableBuiltin2);
  29. function ExtendableError() {
  30. var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  31. _classCallCheck(this, ExtendableError);
  32. // extending Error is weird and does not propagate `message`
  33. var _this = _possibleConstructorReturn(this, (ExtendableError.__proto__ || Object.getPrototypeOf(ExtendableError)).call(this, message));
  34. Object.defineProperty(_this, 'message', {
  35. configurable: true,
  36. enumerable: false,
  37. value: message,
  38. writable: true
  39. });
  40. Object.defineProperty(_this, 'name', {
  41. configurable: true,
  42. enumerable: false,
  43. value: _this.constructor.name,
  44. writable: true
  45. });
  46. if (Error.hasOwnProperty('captureStackTrace')) {
  47. Error.captureStackTrace(_this, _this.constructor);
  48. return _possibleConstructorReturn(_this);
  49. }
  50. Object.defineProperty(_this, 'stack', {
  51. configurable: true,
  52. enumerable: false,
  53. value: new Error(message).stack,
  54. writable: true
  55. });
  56. return _this;
  57. }
  58. return ExtendableError;
  59. }(_extendableBuiltin(Error));
  60. exports.default = ExtendableError;
  61. module.exports = exports['default'];