bare-fetch
Advanced tools
Comparing version 1.3.1 to 1.4.0
@@ -28,2 +28,8 @@ const { Readable } = require('bare-stream') | ||
// https://fetch.spec.whatwg.org/#dom-body-bytes | ||
async bytes () { | ||
return this.buffer() | ||
} | ||
// https://fetch.spec.whatwg.org/#dom-body-arraybuffer | ||
async arrayBuffer () { | ||
@@ -33,2 +39,3 @@ return (await this.buffer()).buffer | ||
// https://fetch.spec.whatwg.org/#dom-body-text | ||
async text () { | ||
@@ -38,2 +45,3 @@ return (await this.buffer()).toString('utf8') | ||
// https://fetch.spec.whatwg.org/#dom-body-json | ||
async json () { | ||
@@ -40,0 +48,0 @@ return JSON.parse(await this.text()) |
{ | ||
"name": "bare-fetch", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"description": "Minimal WHATWG Fetch implementation for Bare", | ||
@@ -8,2 +8,3 @@ "exports": { | ||
"./package": "./package.json", | ||
"./global": "./global.js", | ||
"./errors": "./lib/errors.js", | ||
@@ -10,0 +11,0 @@ "./response": "./lib/response.js", |
@@ -27,31 +27,44 @@ # bare-fetch | ||
#### `response.buffer()` | ||
Consumes the stream and returns a buffer. | ||
#### `response.headers` | ||
#### `response.arrayBuffer()` | ||
Consumes the stream and returns an array buffer. | ||
The response headers. | ||
#### `response.text()` | ||
Consumes the stream, parses it as utf8 and returns a string. | ||
#### `response.body` | ||
#### `response.json() ` | ||
Consumes the stream, parses it as json and returns a js object. | ||
The `Readable` body stream. | ||
#### `response.headers` | ||
The headers on the response. | ||
#### `response.bodyUsed` | ||
#### `response.body` | ||
The `Readable` stream wrapped by the response. | ||
Whether or not the stream has already been consumed. | ||
#### `response.bodyUsed` | ||
A boolean property that tracks whether the stream has already been consumed. | ||
#### `response.status` | ||
The http status code of the response. | ||
The HTTP status code of the response. | ||
#### `response.redirected` | ||
A boolean property that tracks whether the request has been redirected to a different URL. | ||
Whether or not the request has been redirected to a different URL. | ||
#### `response.buffer()` | ||
Consumes the stream and returns a `Buffer`. | ||
#### `response.bytes()` | ||
Consumes the stream and returns a `Uint8Array`. | ||
#### `response.arrayBuffer()` | ||
Consumes the stream and returns an `ArrayBuffer`. | ||
#### `response.text()` | ||
Consumes the stream and returns a UTF-8 string. | ||
#### `response.json() ` | ||
Consumes the stream and returns a JSON value. | ||
## License | ||
Apache-2.0 |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
17563
126
70
2