@whatwg-node/node-fetch
Advanced tools
Comparing version 0.0.1-alpha-20230109165738-8edf269 to 0.0.1-alpha-20230117081522-969e299
@@ -19,3 +19,3 @@ /// <reference types="node" /> | ||
} | ||
export declare class PonyfillBody implements Body { | ||
export declare class PonyfillBody<TJSON = any> implements Body { | ||
private bodyInit; | ||
@@ -35,4 +35,4 @@ private options; | ||
}): Promise<PonyfillFormData>; | ||
json(): Promise<any>; | ||
json(): Promise<TJSON>; | ||
text(): Promise<string>; | ||
} |
import { PonyfillRequest, RequestPonyfillInit } from './Request'; | ||
import { PonyfillResponse } from './Response'; | ||
export declare const fetchPonyfill: (info: string | PonyfillRequest | URL, init?: RequestPonyfillInit) => Promise<PonyfillResponse>; | ||
export declare function fetchPonyfill<TResponseJSON = any, TRequestJSON = any>(info: string | PonyfillRequest<TRequestJSON> | URL, init?: RequestPonyfillInit): Promise<PonyfillResponse<TResponseJSON>>; |
19
index.js
@@ -13,2 +13,3 @@ 'use strict'; | ||
const busboy = _interopDefault(require('busboy')); | ||
const headerCase = require('header-case'); | ||
const url = require('url'); | ||
@@ -584,3 +585,3 @@ const fs = require('fs'); | ||
append(name, value) { | ||
const key = name.toLowerCase(); | ||
const key = headerCase.headerCase(name); | ||
if (this.map.has(key)) { | ||
@@ -592,15 +593,15 @@ value = this.map.get(key) + ', ' + value; | ||
get(name) { | ||
const key = name.toLowerCase(); | ||
const key = headerCase.headerCase(name); | ||
return this.map.get(key) || null; | ||
} | ||
has(name) { | ||
const key = name.toLowerCase(); | ||
const key = headerCase.headerCase(name); | ||
return this.map.has(key); | ||
} | ||
set(name, value) { | ||
const key = name.toLowerCase(); | ||
const key = headerCase.headerCase(name); | ||
this.map.set(key, value); | ||
} | ||
delete(name) { | ||
const key = name.toLowerCase(); | ||
const key = headerCase.headerCase(name); | ||
this.map.delete(key); | ||
@@ -703,2 +704,3 @@ } | ||
this.redirected = init.redirected || false; | ||
this.type = init.type || 'default'; | ||
} | ||
@@ -713,7 +715,6 @@ } | ||
static error() { | ||
const response = new PonyfillResponse(null, { | ||
return new PonyfillResponse(null, { | ||
status: 500, | ||
statusText: 'Internal Server Error', | ||
}); | ||
return response; | ||
} | ||
@@ -767,3 +768,3 @@ static redirect(url, status = 301) { | ||
} | ||
const fetchPonyfill = (info, init) => { | ||
function fetchPonyfill(info, init) { | ||
if (typeof info === 'string' || info instanceof URL) { | ||
@@ -839,3 +840,3 @@ const ponyfillRequest = new PonyfillRequest(info, init); | ||
}); | ||
}; | ||
} | ||
@@ -842,0 +843,0 @@ class PonyfillTextEncoder { |
{ | ||
"name": "@whatwg-node/node-fetch", | ||
"version": "0.0.1-alpha-20230109165738-8edf269", | ||
"version": "0.0.1-alpha-20230117081522-969e299", | ||
"description": "Fetch API implementation for Node", | ||
@@ -12,2 +12,3 @@ "sideEffects": false, | ||
"busboy": "1.6.0", | ||
"header-case": "^2.0.4", | ||
"tslib": "^2.3.1" | ||
@@ -14,0 +15,0 @@ }, |
@@ -7,3 +7,3 @@ import { PonyfillBody, BodyPonyfillInit, PonyfillBodyOptions } from './Body'; | ||
}; | ||
export declare class PonyfillRequest extends PonyfillBody implements Request { | ||
export declare class PonyfillRequest<TJSON = any> extends PonyfillBody<TJSON> implements Request { | ||
constructor(input: RequestInfo | URL, options?: RequestPonyfillInit); | ||
@@ -10,0 +10,0 @@ cache: RequestCache; |
@@ -7,4 +7,5 @@ import { PonyfillBody, BodyPonyfillInit, PonyfillBodyOptions } from './Body'; | ||
headers?: PonyfillHeadersInit; | ||
type?: ResponseType; | ||
}; | ||
export declare class PonyfillResponse extends PonyfillBody implements Response { | ||
export declare class PonyfillResponse<TJSON = any> extends PonyfillBody<TJSON> implements Response { | ||
constructor(body?: BodyPonyfillInit | null, init?: ResponsePonyfilInit); | ||
@@ -18,6 +19,6 @@ headers: Headers; | ||
type: ResponseType; | ||
clone(): PonyfillResponse; | ||
static error(): PonyfillResponse; | ||
static redirect(url: string, status?: number): PonyfillResponse; | ||
static json(data: any, init?: RequestInit): PonyfillResponse; | ||
clone(): PonyfillResponse<any>; | ||
static error(): PonyfillResponse<any>; | ||
static redirect(url: string, status?: number): PonyfillResponse<any>; | ||
static json<T = any>(data: T, init?: RequestInit): PonyfillResponse<T>; | ||
} |
Sorry, the diff of this file is not supported yet
71188
1912
5
+ Addedheader-case@^2.0.4
+ Addedcapital-case@1.0.4(transitive)
+ Addedheader-case@2.0.4(transitive)
+ Addedlower-case@2.0.2(transitive)
+ Addedno-case@3.0.4(transitive)
+ Addedupper-case-first@2.0.2(transitive)