@whatwg-node/node-fetch 0.0.5 → 0.0.6-alpha-20230207082303-4613c8e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +9 -19
- package/index.mjs +9 -19
- package/package.json +1 -1
package/index.js
CHANGED
@@ -713,37 +713,27 @@ function processBodyInit(bodyInit) {
|
|
713
713
|
throw new Error('Unknown body type');
|
714
714
|
}
|
715
715
|
|
716
|
+
function isHeadersLike(headers) {
|
717
|
+
return headers && typeof headers.get === 'function';
|
718
|
+
}
|
716
719
|
class PonyfillHeaders {
|
717
720
|
constructor(headersInit) {
|
718
721
|
this.map = new Map();
|
719
722
|
if (headersInit != null) {
|
720
723
|
if (Array.isArray(headersInit)) {
|
721
|
-
|
722
|
-
if (Array.isArray(value)) {
|
723
|
-
for (const v of value) {
|
724
|
-
this.append(key, v);
|
725
|
-
}
|
726
|
-
}
|
727
|
-
else {
|
728
|
-
this.map.set(key, value);
|
729
|
-
}
|
730
|
-
}
|
724
|
+
this.map = new Map(headersInit);
|
731
725
|
}
|
732
|
-
else if (
|
726
|
+
else if (isHeadersLike(headersInit)) {
|
733
727
|
headersInit.forEach((value, key) => {
|
734
|
-
this.
|
728
|
+
this.map.set(key, value);
|
735
729
|
});
|
736
730
|
}
|
737
731
|
else {
|
738
732
|
for (const key in headersInit) {
|
739
733
|
const value = headersInit[key];
|
740
|
-
if (
|
741
|
-
|
742
|
-
|
743
|
-
}
|
744
|
-
}
|
745
|
-
else if (value != null) {
|
746
|
-
this.set(key, value);
|
734
|
+
if (value != null) {
|
735
|
+
const normalizedValue = Array.isArray(value) ? value.join(', ') : value;
|
736
|
+
this.map.set(key, normalizedValue);
|
747
737
|
}
|
748
738
|
}
|
749
739
|
}
|
package/index.mjs
CHANGED
@@ -707,37 +707,27 @@ function processBodyInit(bodyInit) {
|
|
707
707
|
throw new Error('Unknown body type');
|
708
708
|
}
|
709
709
|
|
710
|
+
function isHeadersLike(headers) {
|
711
|
+
return headers && typeof headers.get === 'function';
|
712
|
+
}
|
710
713
|
class PonyfillHeaders {
|
711
714
|
constructor(headersInit) {
|
712
715
|
this.map = new Map();
|
713
716
|
if (headersInit != null) {
|
714
717
|
if (Array.isArray(headersInit)) {
|
715
|
-
|
716
|
-
if (Array.isArray(value)) {
|
717
|
-
for (const v of value) {
|
718
|
-
this.append(key, v);
|
719
|
-
}
|
720
|
-
}
|
721
|
-
else {
|
722
|
-
this.map.set(key, value);
|
723
|
-
}
|
724
|
-
}
|
718
|
+
this.map = new Map(headersInit);
|
725
719
|
}
|
726
|
-
else if (
|
720
|
+
else if (isHeadersLike(headersInit)) {
|
727
721
|
headersInit.forEach((value, key) => {
|
728
|
-
this.
|
722
|
+
this.map.set(key, value);
|
729
723
|
});
|
730
724
|
}
|
731
725
|
else {
|
732
726
|
for (const key in headersInit) {
|
733
727
|
const value = headersInit[key];
|
734
|
-
if (
|
735
|
-
|
736
|
-
|
737
|
-
}
|
738
|
-
}
|
739
|
-
else if (value != null) {
|
740
|
-
this.set(key, value);
|
728
|
+
if (value != null) {
|
729
|
+
const normalizedValue = Array.isArray(value) ? value.join(', ') : value;
|
730
|
+
this.map.set(key, normalizedValue);
|
741
731
|
}
|
742
732
|
}
|
743
733
|
}
|