@adobe/fetch
Advanced tools
Comparing version 3.2.0 to 3.2.1
{ | ||
"name": "@adobe/fetch", | ||
"version": "3.2.0", | ||
"version": "3.2.1", | ||
"description": "Light-weight Fetch implementation transparently supporting both HTTP/1(.1) and HTTP/2", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -69,3 +69,3 @@ <div align="center"> | ||
`@adobe/fetch` also supports the following extensions: | ||
`@adobe/fetch` also supports the following non-spec extensions: | ||
@@ -80,2 +80,3 @@ * `Response.buffer()` returns a Node.js `Buffer`. | ||
* `Response.headers.plain()` returns the headers as a plain object. | ||
* `Response.headers.raw()` returns the internal/raw representation of the headers where e.g. the `Set-Cokkie` header is represented with an array of strings value. | ||
* The Fetch option `follow` allows to limit the number of redirects to follow (default: `20`). | ||
@@ -118,3 +119,3 @@ * The Fetch option `compress` enables transparent gzip/deflate/br content encoding (default: `true`). | ||
`@adobe/fetch` exposes the following extensions: | ||
`@adobe/fetch` exposes the following non-spec extensions: | ||
@@ -274,3 +275,3 @@ * `context()` - creates a new customized API context | ||
Using `timeoutSignal(ms)` extension: | ||
Using `timeoutSignal(ms)` non-spec extension: | ||
@@ -465,3 +466,3 @@ ```javascript | ||
Unlike browsers, you can access raw `Set-Cookie` headers manually using `Headers.plain()`. This is an `@adobe/fetch` only API. | ||
Unlike browsers, you can access raw `Set-Cookie` headers manually using `Headers.raw()`. This is an `@adobe/fetch` only API. | ||
@@ -473,3 +474,3 @@ ```javascript | ||
// returns an array of values, instead of a string of comma-separated values | ||
console.log(resp.headers.plain()['set-cookie']); | ||
console.log(resp.headers.raw()['set-cookie']); | ||
``` | ||
@@ -476,0 +477,0 @@ |
@@ -147,3 +147,3 @@ /* | ||
// extensions | ||
// non-spec extensions | ||
/** | ||
@@ -266,3 +266,3 @@ * A boolean specifying whether the response was retrieved from the cache. | ||
// extensions | ||
// non-spec extensions | ||
/** | ||
@@ -269,0 +269,0 @@ * A boolean specifying support of gzip/deflate/brotli content encoding. |
@@ -126,3 +126,3 @@ /* | ||
* Consume the body and return a promise that will resolve to a Node.js Buffer. | ||
* (extension) | ||
* (non-spec extension) | ||
* | ||
@@ -129,0 +129,0 @@ * @return {Promise<Buffer>} |
@@ -77,4 +77,4 @@ /* | ||
if (init instanceof Headers) { | ||
init.forEach((value, name) => { | ||
this.append(name, value); | ||
init[INTERNALS].map.forEach((value, name) => { | ||
this[INTERNALS].map.set(name, Array.isArray(value) ? [...value] : value); | ||
}); | ||
@@ -181,7 +181,23 @@ } else if (Array.isArray(init)) { | ||
* Returns the headers as a plain object. | ||
* (extension) | ||
* (non-spec extension) | ||
* | ||
* @return {object} | ||
* @returns {Record<string, string>} | ||
*/ | ||
plain() { | ||
return [...this.keys()].reduce((result, key) => { | ||
// eslint-disable-next-line no-param-reassign | ||
result[key] = this.get(key); | ||
return result; | ||
}, {}); | ||
} | ||
/** | ||
* Returns the internal/raw representation of the | ||
* headers, i.e. the value of an multi-valued header | ||
* (added with <code>append()</code>) is an array of strings. | ||
* (non-spec extension) | ||
* | ||
* @returns {Record<string, string|string[]>} | ||
*/ | ||
raw() { | ||
return Object.fromEntries(this[INTERNALS].map); | ||
@@ -188,0 +204,0 @@ } |
@@ -407,3 +407,3 @@ /* | ||
// extensions | ||
// non-spec extensions | ||
@@ -410,0 +410,0 @@ FetchBaseError, |
@@ -74,3 +74,3 @@ /* | ||
if (isPlainObject(body)) { | ||
// extension: support plain js object body (JSON serialization) | ||
// non-spec extension: support plain js object body (JSON serialization) | ||
body = JSON.stringify(body); | ||
@@ -118,3 +118,3 @@ headers.set('content-type', 'application/json'); | ||
// extension options | ||
// non-spec extension options | ||
if (init.follow === undefined) { | ||
@@ -121,0 +121,0 @@ if (!req || req.follow === undefined) { |
@@ -58,3 +58,3 @@ /* | ||
if (isPlainObject(respBody)) { | ||
// extension: support plain js object body (JSON serialization) | ||
// non-spec extension: support plain js object body (JSON serialization) | ||
respBody = JSON.stringify(respBody); | ||
@@ -108,3 +108,3 @@ headers.set('content-type', 'application/json'); | ||
// extension | ||
// non-spec extension | ||
get httpVersion() { | ||
@@ -114,3 +114,3 @@ return this[INTERNALS].httpVersion; | ||
// extension | ||
// non-spec extension | ||
get decoded() { | ||
@@ -117,0 +117,0 @@ return this[INTERNALS].decoded; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
143671
3320
582