diff --git a/README.md b/README.md
index 1b64ef4..e46cf52 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# Wumpfetch
> A lightweight and fast Node.js HTTP client which can be used in various ways
-> [Typings](https://www.github.com/PassTheWessel/wumpfetch-typings) [GitHub](https://www.github.com/PassTheWessel/wumpfetch) **|** [NPM](https://www.npmjs.com/package/wumpfetch)
+> [Typings](https://github.com/PassTheWessel/wumpfetch-typings) **|** [GitHub](https://github.com/PassTheWessel/wumpfetch) **|** [NPM](https://npmjs.com/package/wumpfetch)
## Installing
```sh
@@ -66,10 +66,10 @@ const w = require('wumpfetch');
;(async() => {
const r = await w('https://my-site.com/postboi', { method: 'GET' });
console.log(r.json());
-})();
+})();z
```
-### Why should i use wumpfetch?
-Wumpfetch is a lightweight and fast request library comparing to other packages such as request and node-fetch which are both around 1.5-4mb in size
-
+### Why use Wumpfetch?
+Wumpfetch is a lightweight and fast request library comparing to other packages such as request which is 4.46mb!
+
[](https://packagephobia.now.sh/result?p=wumpfetch) (6.2kb concatenated and 4.4kb minified, both in **/dest**)
\ No newline at end of file
diff --git a/__test__/main.js b/__test__/main.js
index 98683c7..f558180 100644
--- a/__test__/main.js
+++ b/__test__/main.js
@@ -3,7 +3,6 @@ const wump = require('../lib');
console.log(`Using wumpfetch v${wump.version} [${wump.userAgent}]\n\n`);
-
;(async() => {
const requests = [
await wump({ url: 'https://jsonplaceholder.typicode.com/todos/1', parse: 'json' }).send(),
diff --git a/examples/thronebutt-icons.js b/examples/thronebutt-icons.js
index 6a2c3b0..e4e077c 100644
--- a/examples/thronebutt-icons.js
+++ b/examples/thronebutt-icons.js
@@ -35,9 +35,8 @@ const settings = {
// Fetch `url` and save it to `dump/.`
const get = async(url, index) => {
const req = await wump(url).send();
- if (req.statusCode !== 200) {
- return console.log(`[${process.name}] Failed on "${url}": ${req.statusCode}`)
- } else {
+ if (req.statusCode !== 200) return console.log(`[${process.name}] Failed on "${url}": ${req.statusCode}`)
+ else {
fs.writeFileSync(`dump/${index}.${settings.fileType}`, req.body);
console.log(`[${process.name}] Successfully copied "${url}" to "dump/${index}.${settings.fileType}" in ${Date.now() - start}ms from queue`);
}
diff --git a/gulpfile.js b/gulpfile.js
index ebd8b02..3fdc3e7 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -11,7 +11,7 @@ gulp.task('build:node', () => {
gulp.task('concat', () => {
return gulp
- .src('lib/**/*.js')
- .pipe(concat('wumpfetch.concat.js'))
- .pipe(gulp.dest('dist'));
+ .src('lib/**/*.js')
+ .pipe(concat('wumpfetch.concat.js'))
+ .pipe(gulp.dest('dist'));
});
\ No newline at end of file
diff --git a/lib/index.js b/lib/index.js
index 286db1c..07519ee 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -8,11 +8,8 @@ module.exports = (url, method) => {
common.forEach((v) => {
module.exports[v.toLowerCase()] = (url, method) => {
- if (typeof url === 'string') {
- return new request(url, { method: v, ...method });
- } else {
- return new request({ method: v, ...url }, method);
- }
+ if (typeof url === 'string') return new request(url, { method: v, ...method });
+ else return new request({ method: v, ...url }, method);
}
});
diff --git a/lib/model/WumpRequest.js b/lib/model/WumpRequest.js
index fdd8f61..ce77f72 100644
--- a/lib/model/WumpRequest.js
+++ b/lib/model/WumpRequest.js
@@ -15,9 +15,7 @@ module.exports = class WumpRequest {
const o = (typeof url === 'string' ? method : url);
const obj = (typeof o === 'object');
- if (typeof url !== 'string' && !o.hasOwnProperty('url')) {
- throw new Error('Missing url parameter');
- }
+ if (typeof url !== 'string' && !o.hasOwnProperty('url')) throw new Error('Missing URL parameter');
this.o = {
'm': typeof o === 'string' ? o : obj && o.method ? o.method : 'GET',
@@ -33,9 +31,7 @@ module.exports = class WumpRequest {
'coreOptions': obj && typeof o.coreOptions === 'object' ? o.coreOptions : {}
};
- if (typeof o.core === 'object') {
- Object.keys(o.core).forEach((v) => this.option(v, o.core[v]));
- }
+ if (typeof o.core === 'object') Object.keys(o.core).forEach((v) => this.option(v, o.core[v]));
return this;
}
@@ -94,9 +90,7 @@ module.exports = class WumpRequest {
send () {
return new Promise((resolve, reject) => {
if (this.o.data) {
- if (!this.o.rHeaders.hasOwnProperty('user-agent')) {
- this.o.rHeaders['User-Agent'] = w.userAgent || 'Wumpfetch/2.0.1 (https://github.com/PassTheWessel/wumpfetch)';
- }
+ if (!this.o.rHeaders.hasOwnProperty('user-agent')) this.o.rHeaders['User-Agent'] = w.userAgent || 'Wumpfetch/2.0.1 (https://github.com/PassTheWessel/wumpfetch)';
if (this.o.SDA === 'json' && !this.o.rHeaders.hasOwnProperty('content-type')) this.o.rHeaders['Content-Type'] = 'application/json';
if (this.o.SDA === 'form') {
@@ -153,7 +147,6 @@ module.exports = class WumpRequest {
else if (this.o.url.protocol === 'https:') req = https.request(options, handler);
else throw new Error(`Bad URL protocol: ${this.o.url.protocol}`);
-
if (this.o.timeoutTime) {
req.setTimeout(this.o.timeoutTime, () => {
req.abort();
@@ -164,14 +157,10 @@ module.exports = class WumpRequest {
req.on('error', (e) => reject(e));
if (this.o.data) {
- if (this.o.SDA === 'json') {
- req.write(JSON.stringify(this.o.data));
- } else {
- if (typeof this.o.data === 'object') {
- req.write(JSON.stringify(this.o.data));
- } else {
- req.write(this.o.data);
- }
+ if (this.o.SDA === 'json') req.write(JSON.stringify(this.o.data));
+ else {
+ if (typeof this.o.data === 'object') req.write(JSON.stringify(this.o.data));
+ else req.write(this.o.data);
}
}
diff --git a/package.json b/package.json
index 8828846..35d83a4 100644
--- a/package.json
+++ b/package.json
@@ -10,12 +10,12 @@
"lib/"
],
"bugs": {
- "url": "https://www.github.com/PassTheWessel/wumpfetch/issues"
+ "url": "https://github.com/PassTheWessel/wumpfetch/issues"
},
- "homepage": "https://www.github.com/PassTheWessel/wumpfetch#readme",
+ "homepage": "https://github.com/PassTheWessel/wumpfetch#readme",
"repository": {
"type": "git",
- "url": "https://www.github.com/PassTheWessel/wumpfetch"
+ "url": "https://github.com/PassTheWessel/wumpfetch"
},
"keywords": [
"http",
@@ -32,8 +32,5 @@
"gulp": "^4.0.0",
"gulp-concat": "^2.6.1",
"gulp-minify": "^3.1.0"
- },
- "dependencies": {
- "wumpfetch": "^0.2.0"
}
}