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

Loading…
Cancel
Save