fetch-mock
Advanced tools
Comparing version 7.3.8 to 7.3.9
@@ -11,2 +11,18 @@ 'use strict'; | ||
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of'); | ||
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf); | ||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); | ||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | ||
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn'); | ||
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2); | ||
var _inherits2 = require('babel-runtime/helpers/inherits'); | ||
var _inherits3 = _interopRequireDefault(_inherits2); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -18,2 +34,24 @@ | ||
// see https://heycam.github.io/webidl/#aborterror for the standardised interface | ||
// Note that this differs slightly from node-fetch | ||
var AbortError = function (_Error) { | ||
(0, _inherits3.default)(AbortError, _Error); | ||
function AbortError() { | ||
(0, _classCallCheck3.default)(this, AbortError); | ||
var _this = (0, _possibleConstructorReturn3.default)(this, (AbortError.__proto__ || (0, _getPrototypeOf2.default)(AbortError)).apply(this, arguments)); | ||
_this.name = 'AbortError'; | ||
_this.message = 'The operation was aborted.'; | ||
// Do not include this class in the stacktrace | ||
Error.captureStackTrace(_this, _this.constructor); | ||
return _this; | ||
} | ||
return AbortError; | ||
}(Error); | ||
var resolve = function () { | ||
@@ -79,3 +117,3 @@ var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(_ref, url, options, request) { | ||
FetchMock.fetchHandler = function (url, options, request) { | ||
var _this = this; | ||
var _this2 = this; | ||
@@ -102,3 +140,3 @@ var _requestUtils$normali = requestUtils.normalizeRequest(url, options, this.config.Request); | ||
var abort = function abort() { | ||
rej(new Error('URL \'' + url + '\' aborted.')); | ||
rej(new AbortError()); | ||
done(); | ||
@@ -112,3 +150,3 @@ }; | ||
_this.generateResponse(route, url, options, request).then(res, rej).then(done, done); | ||
_this2.generateResponse(route, url, options, request).then(res, rej).then(done, done); | ||
}); | ||
@@ -115,0 +153,0 @@ }; |
{ | ||
"name": "fetch-mock", | ||
"version": "7.3.8", | ||
"version": "7.3.9", | ||
"description": "Mock http requests made using fetch (or isomorphic-fetch)", | ||
@@ -60,2 +60,3 @@ "main": "src/server.js", | ||
"devDependencies": { | ||
"abort-controller": "^3.0.0", | ||
"babel-cli": "^6.1.2", | ||
@@ -62,0 +63,0 @@ "babel-loader": "^7.1.2", |
@@ -5,2 +5,15 @@ const responseBuilder = require('./response-builder'); | ||
// see https://heycam.github.io/webidl/#aborterror for the standardised interface | ||
// Note that this differs slightly from node-fetch | ||
class AbortError extends Error { | ||
constructor() { | ||
super(...arguments); | ||
this.name = 'AbortError'; | ||
this.message = 'The operation was aborted.'; | ||
// Do not include this class in the stacktrace | ||
Error.captureStackTrace(this, this.constructor); | ||
} | ||
} | ||
const resolve = async ( | ||
@@ -53,3 +66,3 @@ { response, responseIsFetch = false }, | ||
const abort = () => { | ||
rej(new Error(`URL '${url}' aborted.`)); | ||
rej(new AbortError()); | ||
done(); | ||
@@ -56,0 +69,0 @@ }; |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1392287
9272
26