Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
fritzy committed Aug 17, 2022
1 parent 1f6daf5 commit 409468f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
24 changes: 13 additions & 11 deletions node_modules/minipass-fetch/lib/body.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ const FetchError = require('./fetch-error.js')
let convert
try {
convert = require('encoding').convert
} catch (e) {}
} catch (e) {
// defer error until textConverted is called
}

const INTERNALS = Symbol('Body internals')
const CONSUME_BODY = Symbol('consumeBody')
Expand Down Expand Up @@ -69,16 +71,16 @@ class Body {
))
}

json () {
return this[CONSUME_BODY]().then(buf => {
try {
return JSON.parse(buf.toString())
} catch (er) {
return Promise.reject(new FetchError(
`invalid json response body at ${
this.url} reason: ${er.message}`, 'invalid-json'))
}
})
async json () {
try {
const buf = await this[CONSUME_BODY]()
return JSON.parse(buf.toString())
} catch (er) {
throw new FetchError(
`invalid json response body at ${this.url} reason: ${er.message}`,
'invalid-json'
)
}
}

text () {
Expand Down
7 changes: 4 additions & 3 deletions node_modules/minipass-fetch/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "minipass-fetch",
"version": "2.1.0",
"version": "2.1.1",
"description": "An implementation of window.fetch in Node.js using Minipass streams",
"license": "MIT",
"main": "lib/index.js",
Expand All @@ -23,10 +23,11 @@
},
"devDependencies": {
"@npmcli/eslint-config": "^3.0.1",
"@npmcli/template-oss": "3.1.2",
"@npmcli/template-oss": "3.5.0",
"@ungap/url-search-params": "^0.2.2",
"abort-controller": "^3.0.0",
"abortcontroller-polyfill": "~1.7.3",
"encoding": "^0.1.13",
"form-data": "^4.0.0",
"nock": "^13.2.4",
"parted": "^0.1.1",
Expand Down Expand Up @@ -61,6 +62,6 @@
"author": "GitHub Inc.",
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "3.1.2"
"version": "3.5.0"
}
}
5 changes: 3 additions & 2 deletions package-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -4819,9 +4819,10 @@
}
},
"node_modules/minipass-fetch": {
"version": "2.1.0",
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/minipass-fetch/-/minipass-fetch-2.1.1.tgz",
"integrity": "sha512-/kgtXVGS10PTFET6dAbOBWQtgH+iDiI4NhRqAftojRlsOJhk0y45sVVxqCaRQC+AMFH7JkHiWpuKJKQ+mojKiA==",
"inBundle": true,
"license": "MIT",
"dependencies": {
"minipass": "^3.1.6",
"minipass-sized": "^1.0.3",
Expand Down

0 comments on commit 409468f

Please sign in to comment.