Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

myfetchapi

Package Overview
Dependencies
Maintainers
0
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

myfetchapi - npm Package Compare versions

Comparing version 1.6.0 to 1.7.0

dist/nodeFetch.d.ts

10

dist/index.d.ts

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

import type * as nodefetch from "node-fetch";
/**
* set maximum number of concurrent requests (requests made at thesame time)
* @param max @default 500
*/
export declare const SET_MAX_CONCURRENT_REQUESTS: (max: number) => void;
export type myFetchOptions = {
useNodeFetch?: boolean;
maxRetry?: number | null;
retryCb?: (err: any, count: number, max: number) => any;
retryCondition?: (res: Response) => boolean | Promise<boolean>;
retryCondition?: (res: Response | nodefetch.Response) => boolean | Promise<boolean>;
};
export declare function myFetch(input: RequestInfo, init?: RequestInit, options?: myFetchOptions): Promise<Response>;
export declare function myFetch(input: RequestInfo | nodefetch.RequestInfo, init?: RequestInit | nodefetch.RequestInit, options?: myFetchOptions): Promise<Response>;

9

dist/index.js

@@ -20,3 +20,3 @@ "use strict";

// src/index.ts
// index.ts
var src_exports = {};

@@ -36,3 +36,4 @@ __export(src_exports, {

try {
const res = await fetch(input, init);
const httpFunc = options?.useNodeFetch ? (await require("./nodeFetch.js")).fetch : fetch;
const res = await httpFunc(input, init);
const isOkay = options?.retryCondition ? await options.retryCondition(res) : res.ok;

@@ -53,3 +54,3 @@ if (isOkay)

try {
return (await res.text()).substring(0, 250);
return await res.text();
} catch (_) {

@@ -59,3 +60,3 @@ return "";

}
async function myFetch(input, init = {}, options) {
async function myFetch(input, init, options) {
const maxRetry = options?.maxRetry === void 0 ? 3 : options.maxRetry === null ? 0 : options.maxRetry < 0 ? 0 : options.maxRetry;

@@ -62,0 +63,0 @@ return new Promise((resolve, reject) => {

{
"name": "myfetchapi",
"version": "1.6.0",
"version": "1.7.0",
"description": "mFetch is a JavaScript library that provides a utility function for making HTTP requests with queuing and retry functionality.",

@@ -20,4 +20,6 @@ "type": "commonjs",

"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "tsc && esbuild src/index.ts --format=cjs --bundle --outfile=dist/index.js && esbuild src/index.ts --format=esm --bundle --outfile=dist/index.mjs"
"test": "cd test && npm run dev",
"build": "tsc && cd src && npm run cjs && npm run esm",
"cjs": "esbuild nodeFetch.ts --format=cjs --bundle --platform=node --outfile=../dist/nodeFetch.js && esbuild index.ts --format=cjs --bundle --external:./nodeFetch.js --outfile=../dist/index.js",
"esm": "esbuild nodeFetch.ts --format=esm --bundle --platform=node --outfile=../dist/nodeFetch.mjs && esbuild index.ts --format=esm --bundle --external:./nodeFetch.js --outfile=../dist/index.mjs"
},

@@ -43,3 +45,9 @@ "repository": {

},
"homepage": "https://github.com/ugo-studio/myfetch#readme"
"homepage": "https://github.com/ugo-studio/myfetch#readme",
"dependencies": {
"node-fetch": "^3.3.2"
},
"devDependencies": {
"@types/node": "^20.14.9"
}
}

@@ -12,3 +12,3 @@ {

/* Language and Environment */
"target": "ES2020", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"target": "ES2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */

@@ -26,5 +26,5 @@ // "jsx": "preserve", /* Specify what JSX code is generated. */

/* Modules */
"module": "ES2020", /* Specify what module code is generated. */
"module": "ES2022", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
"moduleResolution": "Bundler", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */

@@ -31,0 +31,0 @@ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */

Sorry, the diff of this file is not supported yet

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