mirror of
https://github.com/Wessel/wumpfetch.git
synced 2026-07-21 23:57:11 +02:00
Some code base improvements
This commit is contained in:
23
lib/index.js
23
lib/index.js
@@ -1,18 +1,15 @@
|
||||
const req = require('./model/WumpRequest');
|
||||
const pkg = require('../package.json');
|
||||
|
||||
const common = [ 'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'TRACE', 'PATCH' ];
|
||||
const metaData = require('../package.json');
|
||||
|
||||
module.exports = (url, method) => {
|
||||
return new req(url, method);
|
||||
};
|
||||
module.exports = (url, method) => { return new req(url, method); };
|
||||
|
||||
common.forEach((v) => {
|
||||
module.exports[v.toLowerCase()] = (url, method) => {
|
||||
if (typeof url === 'string') return new req(url, { method: v, ...method });
|
||||
else return new req({ method: v, ...url }, method);
|
||||
}
|
||||
});
|
||||
for (const method of common) {
|
||||
module.exports[method.toLowerCase()] = (url, method) => {
|
||||
if (typeof url === 'string') return new req(url, { method: method, ...method });
|
||||
else return new req({ method: method, ...url }, method);
|
||||
};
|
||||
}
|
||||
|
||||
module.exports.version = pkg.version;
|
||||
module.exports.userAgent = `${pkg.name}/${pkg.version} (${pkg.repository.url})`;
|
||||
module.exports.version = metaData.version;
|
||||
module.exports.userAgent = `${metaData.name}/${metaData.version} (${metaData.repository.url})`;
|
||||
Reference in New Issue
Block a user