Files
wumpfetch/lib/index.js
2019-04-05 17:15:24 +02:00

20 lines
656 B
JavaScript

const common = [ 'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'TRACE', 'PATCH' ];
const request = require('./model/WumpRequest');
const { version } = require('../package.json');
module.exports = (url, method) => {
return new request(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);
}
}
});
module.exports.version = version;
module.exports.userAgent = `wumpfetch/${version} (https://github.com/PassTheWessel/wumpfetch)`;