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

got-fetch

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

got-fetch - npm Package Compare versions

Comparing version 4.0.3 to 5.0.0-next.1

jest.config.cjs

12

CHANGELOG.md

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

# [5.0.0-next.1](https://github.com/alexghr/got-fetch/compare/v4.0.3...v5.0.0-next.1) (2021-12-18)
### Features
* support got@12 ([#61](https://github.com/alexghr/got-fetch/issues/61)) ([83257f1](https://github.com/alexghr/got-fetch/commit/83257f1ae463f369d49e41b8a6c8ffac6928f2d5))
### BREAKING CHANGES
* no longer supports got@11
## [4.0.3](https://github.com/alexghr/got-fetch/compare/v4.0.2...v4.0.3) (2021-12-14)

@@ -2,0 +14,0 @@

46

out/lib/fetch.js

@@ -1,26 +0,31 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createFetch = void 0;
const tslib_1 = require("tslib");
const stream_1 = require("stream");
const url_1 = require("url");
const util_1 = require("util");
const response_1 = require("./response");
function createFetch(got) {
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import { Readable } from 'stream';
import { URL, URLSearchParams } from 'url';
import { format } from 'util';
import { GotFetchResponse } from './response.js';
export function createFetch(got) {
const globalCache = new Map();
return (input, opts) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
const url = new url_1.URL(typeof input === 'string' ? input : input.url);
return (input, opts) => __awaiter(this, void 0, void 0, function* () {
const url = new URL(typeof input === 'string' ? input : input.url);
const request = typeof input === 'object' ? input : opts || {};
if (request.mode === 'no-cors' || request.mode === 'same-origin' || request.mode === 'navigate') {
throw new TypeError((0, util_1.format)('request.mode not supported: %s', request.mode));
throw new TypeError(format('request.mode not supported: %s', request.mode));
}
if (request.cache === 'only-if-cached') {
throw new TypeError((0, util_1.format)('request.cache not supported: %s', request.cache));
throw new TypeError(format('request.cache not supported: %s', request.cache));
}
if (request.redirect === 'error' || request.redirect === 'manual') {
throw new TypeError((0, util_1.format)('request.redirect not supported: %s', request.redirect));
throw new TypeError(format('request.redirect not supported: %s', request.redirect));
}
// naive check to make sure headers are a plain object
if (request.headers && typeof request.headers !== 'object') {
throw new TypeError((0, util_1.format)('request.headers must be plain object: %j', request.headers));
throw new TypeError(format('request.headers must be plain object: %j', request.headers));
}

@@ -32,3 +37,3 @@ // got does not merge base searchParams with the url's searchParams

// https://github.com/sindresorhus/got/issues/1188
const searchParams = new url_1.URLSearchParams(url.searchParams);
const searchParams = new URLSearchParams(url.searchParams);
url.search = '';

@@ -69,3 +74,3 @@ const gotOpts = {

return response.then(r => {
return new response_1.GotFetchResponse(r.body, {
return new GotFetchResponse(r.body, {
headers: r.headers,

@@ -80,3 +85,3 @@ redirected: r.redirectUrls && r.redirectUrls.length > 0,

// supported by anything below Node 16.8
? r.redirectUrls[r.redirectUrls.length - 1]
? r.redirectUrls[r.redirectUrls.length - 1].href
: url.href,

@@ -87,3 +92,2 @@ });

}
exports.createFetch = createFetch;
function serializeBody(body) {

@@ -93,3 +97,3 @@ if (!body) {

}
else if (body instanceof url_1.URLSearchParams) {
else if (body instanceof URLSearchParams) {
const serialized = body.toString();

@@ -113,3 +117,3 @@ return {

}
else if (Buffer.isBuffer(body) || (body instanceof stream_1.Readable)) {
else if (Buffer.isBuffer(body) || (body instanceof Readable)) {
return {

@@ -116,0 +120,0 @@ body,

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const got_1 = (0, tslib_1.__importDefault)(require("got"));
const fetch_1 = require("./fetch");
exports.default = (0, fetch_1.createFetch)(got_1.default);
import got from 'got';
import { createFetch } from './fetch.js';
export default createFetch(got);
//# sourceMappingURL=global-fetch.js.map

@@ -1,5 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GotHeaders = void 0;
class GotHeaders {
export class GotHeaders {
constructor(headers, guard = 'none') {

@@ -67,3 +64,2 @@ const init = headers ? Object.entries(headers).map(([name, values]) => {

}
exports.GotHeaders = GotHeaders;
//# sourceMappingURL=headers.js.map

@@ -1,5 +0,5 @@

import { createFetch } from './fetch';
import fetch from './global-fetch';
import { createFetch } from './fetch.js';
import fetch from './global-fetch.js';
export { createFetch, fetch };
export default fetch;
//# sourceMappingURL=index.d.ts.map

@@ -1,10 +0,5 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.fetch = exports.createFetch = void 0;
const tslib_1 = require("tslib");
const fetch_1 = require("./fetch");
Object.defineProperty(exports, "createFetch", { enumerable: true, get: function () { return fetch_1.createFetch; } });
const global_fetch_1 = (0, tslib_1.__importDefault)(require("./global-fetch"));
exports.fetch = global_fetch_1.default;
exports.default = global_fetch_1.default;
import { createFetch } from './fetch.js';
import fetch from './global-fetch.js';
export { createFetch, fetch };
export default fetch;
//# sourceMappingURL=index.js.map

@@ -7,3 +7,3 @@ /**

import { IncomingHttpHeaders } from 'http2';
import { GotHeaders } from './headers';
import { GotHeaders } from './headers.js';
declare type ResponseInit = {

@@ -10,0 +10,0 @@ status?: number;

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

"use strict";
/**

@@ -6,14 +5,12 @@ * Spec:

*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.GotFetchResponse = void 0;
const util_1 = require("util");
const headers_1 = require("./headers");
class GotFetchResponse {
import { format } from 'util';
import { GotHeaders } from './headers.js';
export class GotFetchResponse {
constructor(body, init) {
if (init && typeof init.status === 'number' && (init.status < 200 || init.status > 599)) {
throw new RangeError((0, util_1.format)('init.status is out of range: %s', init.status));
throw new RangeError(format('init.status is out of range: %s', init.status));
}
this.body = body;
this.type = init && init.type || 'basic';
this.headers = new headers_1.GotHeaders(init ? init.headers : undefined, 'immutable');
this.headers = new GotHeaders(init ? init.headers : undefined, 'immutable');
this.status = init && init.status || 0;

@@ -69,3 +66,2 @@ this.statusText = String(init && init.statusText || '');

}
exports.GotFetchResponse = GotFetchResponse;
//# sourceMappingURL=response.js.map
{
"name": "got-fetch",
"version": "4.0.3",
"version": "5.0.0-next.1",
"type": "module",
"license": "MIT",

@@ -17,2 +18,5 @@ "description": "A fetch-compatible interface to the got HTTP client",

"types": "./out/lib",
"exports": {
".": "./out/lib/index.js"
},
"scripts": {

@@ -28,3 +32,3 @@ "build": "$npm_execpath run build:lib",

"pretest": "$npm_execpath run build:test",
"test": "jest",
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
"pretest:watch": "$npm_execpath run build:test",

@@ -35,5 +39,3 @@ "test:watch": "concurrently '$npm_execpath run build:test:watch' 'jest --watchAll'",

},
"dependencies": {
"tslib": "^2.3.1"
},
"dependencies": {},
"devDependencies": {

@@ -47,3 +49,3 @@ "@semantic-release/changelog": "^6.0.1",

"@types/nock": "^11.1.0",
"@types/node": "^16.11.12",
"@types/node": "^17.0.0",
"@typescript-eslint/eslint-plugin": "^5.7.0",

@@ -54,4 +56,4 @@ "@typescript-eslint/parser": "^5.7.0",

"eslint": "^8.4.1",
"got": "^11.0.2",
"jest": "^27.4.3",
"got": "^12.0.0",
"jest": "^27.4.5",
"nock": "^13.2.1",

@@ -62,3 +64,3 @@ "semantic-release": "^18.0.0",

"peerDependencies": {
"got": "^11.0.0"
"got": "^12.0.0"
},

@@ -65,0 +67,0 @@ "engines": {

Sorry, the diff of this file is not supported yet

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