You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

fetch-mock

Package Overview
Dependencies
Maintainers
3
Versions
218
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.5.1 to 7.6.0

39

es5/lib/set-up-and-tear-down.js

@@ -12,21 +12,30 @@ 'use strict';

FetchMock.mock = function (matcher, response) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
FetchMock.mock = function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var route = void 0;
if (args.length) {
var matcher = args[0],
response = args[1],
_args$ = args[2],
options = _args$ === undefined ? {} : _args$;
// Handle the variety of parameters accepted by mock (see README)
if (matcher && response) {
route = (0, _assign2.default)({
matcher: matcher,
response: response
}, options);
} else if (matcher && matcher.matcher) {
route = matcher;
} else {
throw new Error('fetch-mock: Invalid parameters passed to fetch-mock');
var route = void 0;
// Handle the variety of parameters accepted by mock (see README)
if (matcher && response) {
route = (0, _assign2.default)({
matcher: matcher,
response: response
}, options);
} else if (matcher && matcher.matcher) {
route = matcher;
} else {
throw new Error('fetch-mock: Invalid parameters passed to fetch-mock');
}
this.addRoute(route);
}
this.addRoute(route);
return this._mock();

@@ -33,0 +42,0 @@ };

{
"name": "fetch-mock",
"version": "7.5.1",
"version": "7.6.0",
"description": "Mock http requests made using fetch (or isomorphic-fetch)",

@@ -5,0 +5,0 @@ "main": "src/server.js",

const compileRoute = require('./compile-route');
const FetchMock = {};
FetchMock.mock = function(matcher, response, options = {}) {
let route;
FetchMock.mock = function(...args) {
if (args.length) {
const [matcher, response, options = {}] = args;
let route;
// Handle the variety of parameters accepted by mock (see README)
if (matcher && response) {
route = Object.assign(
{
matcher,
response
},
options
);
} else if (matcher && matcher.matcher) {
route = matcher;
} else {
throw new Error('fetch-mock: Invalid parameters passed to fetch-mock');
// Handle the variety of parameters accepted by mock (see README)
if (matcher && response) {
route = Object.assign(
{
matcher,
response
},
options
);
} else if (matcher && matcher.matcher) {
route = matcher;
} else {
throw new Error('fetch-mock: Invalid parameters passed to fetch-mock');
}
this.addRoute(route);
}
this.addRoute(route);
return this._mock();

@@ -25,0 +28,0 @@ };

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc