File tree Expand file tree Collapse file tree 3 files changed +20
-16
lines changed
node_modules/minipass-fetch Expand file tree Collapse file tree 3 files changed +20
-16
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,9 @@ const FetchError = require('./fetch-error.js')
10
10
let convert
11
11
try {
12
12
convert = require ( 'encoding' ) . convert
13
- } catch ( e ) { }
13
+ } catch ( e ) {
14
+ // defer error until textConverted is called
15
+ }
14
16
15
17
const INTERNALS = Symbol ( 'Body internals' )
16
18
const CONSUME_BODY = Symbol ( 'consumeBody' )
@@ -69,16 +71,16 @@ class Body {
69
71
) )
70
72
}
71
73
72
- json ( ) {
73
- return this [ CONSUME_BODY ] ( ) . then ( buf => {
74
- try {
75
- return JSON . parse ( buf . toString ( ) )
76
- } catch ( er ) {
77
- return Promise . reject ( new FetchError (
78
- `invalid json response body at ${
79
- this . url } reason: ${ er . message } ` , 'invalid-json' ) )
80
- }
81
- } )
74
+ async json ( ) {
75
+ try {
76
+ const buf = await this [ CONSUME_BODY ] ( )
77
+ return JSON . parse ( buf . toString ( ) )
78
+ } catch ( er ) {
79
+ throw new FetchError (
80
+ `invalid json response body at ${ this . url } reason: ${ er . message } ` ,
81
+ 'invalid-json'
82
+ )
83
+ }
82
84
}
83
85
84
86
text ( ) {
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " minipass-fetch" ,
3
- "version" : " 2.1.0 " ,
3
+ "version" : " 2.1.1 " ,
4
4
"description" : " An implementation of window.fetch in Node.js using Minipass streams" ,
5
5
"license" : " MIT" ,
6
6
"main" : " lib/index.js" ,
23
23
},
24
24
"devDependencies" : {
25
25
"@npmcli/eslint-config" : " ^3.0.1" ,
26
- "@npmcli/template-oss" : " 3.1.2 " ,
26
+ "@npmcli/template-oss" : " 3.5.0 " ,
27
27
"@ungap/url-search-params" : " ^0.2.2" ,
28
28
"abort-controller" : " ^3.0.0" ,
29
29
"abortcontroller-polyfill" : " ~1.7.3" ,
30
+ "encoding" : " ^0.1.13" ,
30
31
"form-data" : " ^4.0.0" ,
31
32
"nock" : " ^13.2.4" ,
32
33
"parted" : " ^0.1.1" ,
61
62
"author" : " GitHub Inc." ,
62
63
"templateOSS" : {
63
64
"//@npmcli/template-oss" : " This file is partially managed by @npmcli/template-oss. Edits may be overwritten." ,
64
- "version" : " 3.1.2 "
65
+ "version" : " 3.5.0 "
65
66
}
66
67
}
Original file line number Diff line number Diff line change 4819
4819
}
4820
4820
},
4821
4821
"node_modules/minipass-fetch" : {
4822
- "version" : " 2.1.0" ,
4822
+ "version" : " 2.1.1" ,
4823
+ "resolved" : " https://registry.npmjs.org/minipass-fetch/-/minipass-fetch-2.1.1.tgz" ,
4824
+ "integrity" : " sha512-/kgtXVGS10PTFET6dAbOBWQtgH+iDiI4NhRqAftojRlsOJhk0y45sVVxqCaRQC+AMFH7JkHiWpuKJKQ+mojKiA==" ,
4823
4825
"inBundle" : true ,
4824
- "license" : " MIT" ,
4825
4826
"dependencies" : {
4826
4827
"minipass" : " ^3.1.6" ,
4827
4828
"minipass-sized" : " ^1.0.3" ,
You can’t perform that action at this time.
0 commit comments