@whatwg-node/fetch 0.2.2 → 0.2.5

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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @whatwg-node/fetch
2
2
 
3
- ## 0.2.2
3
+ ## 0.2.3
4
4
 
5
5
  ### Minor Changes
6
6
 
@@ -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) {
@@ -19,7 +20,10 @@ module.exports = function createNodePonyfill(opts = {}) {
19
20
  ponyfills.Blob = globalThis.Blob;
20
21
  ponyfills.crypto = globalThis.crypto;
21
22
 
22
- require('event-target-polyfill');
23
+ if (!globalThis.Event || !globalThis.EventTarget) {
24
+ require('event-target-polyfill');
25
+ }
26
+
23
27
  ponyfills.Event = globalThis.Event;
24
28
  ponyfills.EventTarget = globalThis.EventTarget;
25
29
 
@@ -62,10 +66,14 @@ module.exports = function createNodePonyfill(opts = {}) {
62
66
  }
63
67
  }
64
68
 
65
- 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
+ }
66
74
  return {
67
75
  decode(buf) {
68
- return buf.toString("utf8");
76
+ return Buffer.from(buf).toString(encoding);
69
77
  }
70
78
  }
71
79
  }
@@ -220,7 +228,7 @@ module.exports = function createNodePonyfill(opts = {}) {
220
228
  if (globalThis.Headers) {
221
229
  Object.defineProperty(globalThis.Headers, Symbol.hasInstance, {
222
230
  value(obj) {
223
- return obj.get && obj.set && obj.delete && obj.has && obj.append;
231
+ return obj && obj.get && obj.set && obj.delete && obj.has && obj.append;
224
232
  },
225
233
  configurable: true,
226
234
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whatwg-node/fetch",
3
- "version": "0.2.2",
3
+ "version": "0.2.5",
4
4
  "description": "Cross Platform Smart Fetch Ponyfill",
5
5
  "author": "Arda TANRIKULU <ardatanrikulu@gmail.com>",
6
6
  "repository": {
@@ -25,7 +25,6 @@
25
25
  "form-data-encoder": "^1.7.1",
26
26
  "formdata-node": "^4.3.1",
27
27
  "node-fetch": "^2.6.7",
28
- "undici": "^5.8.0",
29
28
  "web-streams-polyfill": "^3.2.0"
30
29
  },
31
30
  "publishConfig": {