Skip to content

Commit

Permalink
Merge pull request #1598 from flannelJesus:fix-verbs
Browse files Browse the repository at this point in the history
Fix the way http verbs are defined in order to please intellisense IDEs
  • Loading branch information
simov committed May 25, 2015
2 parents f2451bf + 20e9b57 commit ee6ff62
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions index.js
Expand Up @@ -56,16 +56,22 @@ function request (uri, options, callback) {
return new request.Request(params)
}

var verbs = ['get', 'head', 'post', 'put', 'patch', 'del']

verbs.forEach(function(verb) {
function verbFunc (verb) {
var method = verb === 'del' ? 'DELETE' : verb.toUpperCase()
request[verb] = function (uri, options, callback) {
return function (uri, options, callback) {
var params = initParams(uri, options, callback)
params.method = method
return request(params, params.callback)
}
})
}

// define like this to please codeintel/intellisense IDEs
request.get = verbFunc('get')
request.head = verbFunc('head')
request.post = verbFunc('post')
request.put = verbFunc('put')
request.patch = verbFunc('patch')
request.del = verbFunc('del')

request.jar = function (store) {
return cookies.jar(store)
Expand Down

0 comments on commit ee6ff62

Please sign in to comment.