New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vi-fetch

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vi-fetch - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

global.d.ts

48

dist/api.js

@@ -1,37 +0,3 @@

var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __reExport = (target, module2, copyDefault, desc) => {
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
for (let key of __getOwnPropNames(module2))
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
}
return target;
};
var __toCommonJS = /* @__PURE__ */ ((cache) => {
return (module2, temp) => {
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
};
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
var api_exports = {};
__export(api_exports, {
Mocks: () => Mocks,
createMockApi: () => createMockApi,
mockApi: () => mockApi,
mockDelete: () => mockDelete,
mockGet: () => mockGet,
mockPatch: () => mockPatch,
mockPost: () => mockPost,
mockPut: () => mockPut,
prepareFetch: () => prepareFetch
});
var import_tinyspy = require("tinyspy");
var import_response = require("./response");
import { spyOn } from "tinyspy";
import { ResponseMock } from "./response";
const methods = ["GET", "POST", "PATCH", "PUT", "DELETE"];

@@ -108,3 +74,3 @@ class MockStorage {

} = typeof result.value === "function" ? await result.value(urlObj, urlOrRequest, optionsOrNothing) : result.value;
return new import_response.ResponseMock(url, body, {
return new ResponseMock(url, body, {
status: statusCode,

@@ -117,3 +83,3 @@ statusText,

function spyOnFetch(fetchMethod, fetchPath, includeQuery = true) {
const spyFetch = (0, import_tinyspy.spyOn)(settings.global, settings.fetchKey);
const spyFetch = spyOn(settings.global, settings.fetchKey);
fetchPath = this.options.baseUrl + fetchPath;

@@ -266,5 +232,3 @@ function isRoute([input, options]) {

}
module.exports = __toCommonJS(api_exports);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
export {
Mocks,

@@ -279,2 +243,2 @@ createMockApi,

prepareFetch
});
};

@@ -1,42 +0,23 @@

var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __reExport = (target, module2, copyDefault, desc) => {
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
for (let key of __getOwnPropNames(module2))
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
}
return target;
};
var __toCommonJS = /* @__PURE__ */ ((cache) => {
return (module2, temp) => {
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
};
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
var extend_exports = {};
__export(extend_exports, {
declareFetchAssertions: () => declareFetchAssertions
});
var import_matchers = require("./matchers");
import {
toFetch,
toFetchTimes,
toFetchWithBody,
toFetchWithQuery,
toFetchNthTimeWithBody,
toFetchNthTimeWithQuery
} from "./matchers";
function declareFetchAssertions(expect2) {
expect2.extend({
toHaveFetched: import_matchers.toFetch,
toFetch: import_matchers.toFetch,
toHaveFetchedTimes: import_matchers.toFetchTimes,
toFetchTimes: import_matchers.toFetchTimes,
toHaveFetchedWithBody: import_matchers.toFetchWithBody,
toFetchWithBody: import_matchers.toFetchWithBody,
toHaveFetchedNthTimeWithBody: import_matchers.toFetchNthTimeWithBody,
toFetchNthTimeWithBody: import_matchers.toFetchNthTimeWithBody,
toHaveFetchedWithQuery: import_matchers.toFetchWithQuery,
toFetchWithQuery: import_matchers.toFetchWithQuery,
toHaveFetchedNthTimeWithQuery: import_matchers.toFetchNthTimeWithQuery,
toFetchNthTimeWithQuery: import_matchers.toFetchNthTimeWithQuery
toHaveFetched: toFetch,
toFetch,
toHaveFetchedTimes: toFetchTimes,
toFetchTimes,
toHaveFetchedWithBody: toFetchWithBody,
toFetchWithBody,
toHaveFetchedNthTimeWithBody: toFetchNthTimeWithBody,
toFetchNthTimeWithBody,
toHaveFetchedWithQuery: toFetchWithQuery,
toFetchWithQuery,
toHaveFetchedNthTimeWithQuery: toFetchNthTimeWithQuery,
toFetchNthTimeWithQuery
});

@@ -47,6 +28,4 @@ }

}
module.exports = __toCommonJS(extend_exports);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
export {
declareFetchAssertions
});
};

@@ -1,39 +0,12 @@

var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __reExport = (target, module2, copyDefault, desc) => {
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
for (let key of __getOwnPropNames(module2))
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
}
return target;
};
var __toCommonJS = /* @__PURE__ */ ((cache) => {
return (module2, temp) => {
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
};
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
var src_exports = {};
__export(src_exports, {
declareFetchAssertions: () => import_extend.declareFetchAssertions,
mockApi: () => import_api.mockApi,
mockDelete: () => import_api.mockDelete,
mockGet: () => import_api.mockGet,
mockPatch: () => import_api.mockPatch,
mockPost: () => import_api.mockPost,
mockPut: () => import_api.mockPut,
prepareFetch: () => import_api.prepareFetch
});
var import_extend = require("./extend");
var import_api = require("./api");
module.exports = __toCommonJS(src_exports);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
import { declareFetchAssertions } from "./extend";
import {
prepareFetch,
mockApi,
mockDelete,
mockGet,
mockPatch,
mockPost,
mockPut
} from "./api";
export {
declareFetchAssertions,

@@ -47,2 +20,2 @@ mockApi,

prepareFetch
});
};

@@ -1,33 +0,2 @@

var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __reExport = (target, module2, copyDefault, desc) => {
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
for (let key of __getOwnPropNames(module2))
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
}
return target;
};
var __toCommonJS = /* @__PURE__ */ ((cache) => {
return (module2, temp) => {
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
};
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
var matchers_exports = {};
__export(matchers_exports, {
toFetch: () => toFetch,
toFetchNthTimeWithBody: () => toFetchNthTimeWithBody,
toFetchNthTimeWithQuery: () => toFetchNthTimeWithQuery,
toFetchTimes: () => toFetchTimes,
toFetchWithBody: () => toFetchWithBody,
toFetchWithQuery: () => toFetchWithQuery
});
var import_query_string = require("query-string");
import { parse as parseQuery } from "query-string";
const arrayBufferEquality = (a, b) => {

@@ -179,3 +148,3 @@ if (!(a instanceof ArrayBuffer) || !(b instanceof ArrayBuffer))

function createQueryComparison(expectedQuery, equals) {
const expectedQueryObj = typeof expectedQuery === "string" ? (0, import_query_string.parse)(expectedQuery) : expectedQuery;
const expectedQueryObj = typeof expectedQuery === "string" ? parseQuery(expectedQuery) : expectedQuery;
return ([input]) => {

@@ -187,3 +156,3 @@ const url = typeof input === "string" ? input : input.url;

}
return equals(expectedQueryObj, (0, import_query_string.parse)(uri.search));
return equals(expectedQueryObj, parseQuery(uri.search));
};

@@ -235,5 +204,3 @@ }

}
module.exports = __toCommonJS(matchers_exports);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
export {
toFetch,

@@ -245,2 +212,2 @@ toFetchNthTimeWithBody,

toFetchWithQuery
});
};

@@ -1,27 +0,1 @@

var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __reExport = (target, module2, copyDefault, desc) => {
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
for (let key of __getOwnPropNames(module2))
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
}
return target;
};
var __toCommonJS = /* @__PURE__ */ ((cache) => {
return (module2, temp) => {
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
};
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
var response_exports = {};
__export(response_exports, {
ResponseMock: () => ResponseMock
});
class ResponseMock {

@@ -101,6 +75,4 @@ constructor(path, value, init) {

}
module.exports = __toCommonJS(response_exports);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
export {
ResponseMock
});
};

@@ -1,7 +0,7 @@

var import_extend = require("./extend");
var import_api = require("./api");
import "./extend";
import { prepareFetch } from "./api";
if (globalThis && globalThis.window && "fetch" in globalThis.window && globalThis.window.fetch) {
(0, import_api.prepareFetch)(globalThis.window);
prepareFetch(globalThis.window);
} else {
(0, import_api.prepareFetch)();
prepareFetch();
}
{
"name": "vi-fetch",
"version": "0.2.0",
"version": "0.2.1",
"description": "Easiest way to mock fetch",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"type": "module",
"files": [
"dist/**"
"dist/**",
"global.d.ts"
],
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.js",
"import": "./dist/index.js",
"types": "./dist/index.d.ts"

@@ -22,4 +23,3 @@ },

"./setup": {
"import": "./dist/setup.mjs",
"require": "./dist/setup.js",
"import": "./dist/setup.js",
"types": "./dist/global.d.ts"

@@ -26,0 +26,0 @@ }

@@ -5,3 +5,3 @@ # vi-fetch

Compatible with [Jest](https://github.com/facebook/jest) and [Vitest](https://github.com/vitest-dev/vitest).
Compatible with [Jest](https://github.com/facebook/jest) when using ESM flag and [Vitest](https://github.com/vitest-dev/vitest).

@@ -8,0 +8,0 @@ ## Installing

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc