mirror of
https://github.com/Wessel/wumpfetch.git
synced 2026-07-24 09:07:11 +02:00
v0.3.0 - Profiles (Check the description for changes)
A lot has been renovated and some small things has been added to v0.3.0: * Added profiles (`getProfile`, `setProfile`, `setDefaults`) * Renamed `Collection` to `MemoryCollection` * Made `wumpfetch.userAgent` read-only * Renamed `__test__` to `tests` * Removed the `dist` folder * Changed the tab size from `4` to `2` in the declarations file and wumpfetch TS test file * Added JSdoc to `WumpRequest` and `WumpResponse` * Fixed up some of the weird spacing in `WumpRequest` and `WumpResponse` * Cleaned up all test files
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
module.exports = class WumpResponse {
|
||||
constructor (res) {
|
||||
this.body = Buffer.alloc(0);
|
||||
this.coreRes = res;
|
||||
this.headers = res.headers;
|
||||
this.statusCode = res.statusCode;
|
||||
}
|
||||
|
||||
_addChunk (chunk) {
|
||||
this.body = Buffer.concat([ this.body, chunk ]);
|
||||
}
|
||||
|
||||
parse () {
|
||||
if (this.headers['content-type'].includes('application/json')) return JSON.parse(this.body);
|
||||
else return this.body.toString();
|
||||
}
|
||||
|
||||
text () { return this.body.toString(); }
|
||||
json () { return JSON.parse(this.body); }
|
||||
buffer () { return this.body; }
|
||||
};
|
||||
module.exports = class WumpResponse {
|
||||
constructor (res) {
|
||||
this.body = Buffer.alloc(0);
|
||||
this.coreRes = res;
|
||||
this.headers = res.headers;
|
||||
this.statusCode = res.statusCode;
|
||||
}
|
||||
|
||||
_addChunk (chunk) {
|
||||
this.body = Buffer.concat([ this.body, chunk ]);
|
||||
}
|
||||
|
||||
parse () {
|
||||
if (this.headers['content-type'].includes('application/json')) return this.json();
|
||||
else return this.text();
|
||||
}
|
||||
|
||||
text() { return this.body.toString(); }
|
||||
json() { return JSON.parse(this.body); }
|
||||
buffer() { return this.body; }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user