Browse Source

Add all helper functions in the same loop (#336)

err
Luke Childs 8 years ago
committed by Sindre Sorhus
parent
commit
ee405f4843
  1. 15
      index.js

15
index.js

@ -388,7 +388,9 @@ function got(url, opts) {
}
}
const helpers = [
got.stream = (url, opts) => asStream(normalizeArguments(url, opts));
const methods = [
'get',
'post',
'put',
@ -397,14 +399,9 @@ const helpers = [
'delete'
];
helpers.forEach(el => {
got[el] = (url, opts) => got(url, Object.assign({}, opts, {method: el}));
});
got.stream = (url, opts) => asStream(normalizeArguments(url, opts));
for (const el of helpers) {
got.stream[el] = (url, opts) => got.stream(url, Object.assign({}, opts, {method: el}));
for (const method of methods) {
got[method] = (url, opts) => got(url, Object.assign({}, opts, {method}));
got.stream[method] = (url, opts) => got.stream(url, Object.assign({}, opts, {method}));
}
class StdError extends Error {

Loading…
Cancel
Save