@whatwg-node/node-fetch 0.4.3 → 0.4.4-alpha-20230609080853-e545b54
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/cjs/Body.js +9 -1
- package/esm/Body.js +9 -1
- package/package.json +2 -1
package/cjs/Body.js
CHANGED
@@ -4,6 +4,7 @@ exports.PonyfillBody = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
5
5
|
const stream_1 = require("stream");
|
6
6
|
const busboy_1 = tslib_1.__importDefault(require("busboy"));
|
7
|
+
const simdjson_1 = tslib_1.__importDefault(require("simdjson"));
|
7
8
|
const Blob_js_1 = require("./Blob.js");
|
8
9
|
const File_js_1 = require("./File.js");
|
9
10
|
const FormData_js_1 = require("./FormData.js");
|
@@ -212,7 +213,14 @@ class PonyfillBody {
|
|
212
213
|
}
|
213
214
|
async json() {
|
214
215
|
const text = await this.text();
|
215
|
-
|
216
|
+
const fakeObj = new Proxy(simdjson_1.default.lazyParse(text), {
|
217
|
+
get(tape, prop) {
|
218
|
+
if (prop !== 'then') {
|
219
|
+
return tape.valueForKeyPath(prop);
|
220
|
+
}
|
221
|
+
},
|
222
|
+
});
|
223
|
+
return fakeObj;
|
216
224
|
}
|
217
225
|
async text() {
|
218
226
|
if (this.bodyType === BodyInitType.String) {
|
package/esm/Body.js
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import { Readable } from 'stream';
|
2
2
|
import busboy from 'busboy';
|
3
|
+
import simdjson from 'simdjson';
|
3
4
|
import { PonyfillBlob } from './Blob.js';
|
4
5
|
import { PonyfillFile } from './File.js';
|
5
6
|
import { getStreamFromFormData, PonyfillFormData } from './FormData.js';
|
@@ -208,7 +209,14 @@ export class PonyfillBody {
|
|
208
209
|
}
|
209
210
|
async json() {
|
210
211
|
const text = await this.text();
|
211
|
-
|
212
|
+
const fakeObj = new Proxy(simdjson.lazyParse(text), {
|
213
|
+
get(tape, prop) {
|
214
|
+
if (prop !== 'then') {
|
215
|
+
return tape.valueForKeyPath(prop);
|
216
|
+
}
|
217
|
+
},
|
218
|
+
});
|
219
|
+
return fakeObj;
|
212
220
|
}
|
213
221
|
async text() {
|
214
222
|
if (this.bodyType === BodyInitType.String) {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@whatwg-node/node-fetch",
|
3
|
-
"version": "0.4.
|
3
|
+
"version": "0.4.4-alpha-20230609080853-e545b54",
|
4
4
|
"description": "Fetch API implementation for Node",
|
5
5
|
"sideEffects": false,
|
6
6
|
"dependencies": {
|
@@ -8,6 +8,7 @@
|
|
8
8
|
"busboy": "^1.6.0",
|
9
9
|
"fast-querystring": "^1.1.1",
|
10
10
|
"fast-url-parser": "^1.1.3",
|
11
|
+
"simdjson": "^0.9.2",
|
11
12
|
"tslib": "^2.3.1"
|
12
13
|
},
|
13
14
|
"repository": {
|