@whatwg-node/fetch 0.2.3 → 0.2.6
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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const handleFileRequest = require("./handle-file-request");
|
|
2
2
|
|
|
3
3
|
module.exports = function createNodePonyfill(opts = {}) {
|
|
4
|
+
|
|
4
5
|
const ponyfills = {};
|
|
5
6
|
|
|
6
7
|
if (!opts.useNodeFetch) {
|
|
@@ -65,10 +66,14 @@ module.exports = function createNodePonyfill(opts = {}) {
|
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
ponyfills.TextDecoder = function TextDecoder() {
|
|
69
|
+
ponyfills.TextDecoder = function TextDecoder(label, opts) {
|
|
70
|
+
let encoding = 'utf-8'
|
|
71
|
+
if (opts && opts.encoding) {
|
|
72
|
+
encoding = opts.encoding
|
|
73
|
+
}
|
|
69
74
|
return {
|
|
70
75
|
decode(buf) {
|
|
71
|
-
return buf.toString(
|
|
76
|
+
return Buffer.from(buf).toString(encoding);
|
|
72
77
|
}
|
|
73
78
|
}
|
|
74
79
|
}
|
|
@@ -223,7 +228,7 @@ module.exports = function createNodePonyfill(opts = {}) {
|
|
|
223
228
|
if (globalThis.Headers) {
|
|
224
229
|
Object.defineProperty(globalThis.Headers, Symbol.hasInstance, {
|
|
225
230
|
value(obj) {
|
|
226
|
-
return obj.get && obj.set && obj.delete && obj.has && obj.append;
|
|
231
|
+
return obj && obj.get && obj.set && obj.delete && obj.has && obj.append;
|
|
227
232
|
},
|
|
228
233
|
configurable: true,
|
|
229
234
|
})
|