Sha256: 19a53be538eedd97b8b720b3ef5d48eb0c0e0742907e90fc2b69a925f6e5062f

Contents?: true

Size: 1.15 KB

Versions: 24

Compression:

Stored size: 1.15 KB

Contents

var extend = require('util')._extend

function constructObject(initialObject) {
  initialObject = initialObject || {}

  return {
    extend: function (object) {
      return constructObject(extend(initialObject, object))
    },
    done: function () {
      return initialObject
    }
  }
}

function constructOptionsFrom(uri, options) {
  var params = constructObject()
  if (typeof uri === 'object') params.extend(uri)
  if (typeof uri === 'string') params.extend({uri: uri})
  params.extend(options)
  return params.done()
}

function filterForCallback(values) {
  var callbacks = values.filter(isFunction)
  return callbacks[0]
}

function isFunction(value) {
  return typeof value === 'function'
}

function paramsHaveRequestBody(params) {
  return (
    params.options.body ||
    params.options.requestBodyStream ||
    (params.options.json && typeof params.options.json !== 'boolean') ||
    params.options.multipart
  )
}

exports.isFunction            = isFunction
exports.constructObject       = constructObject
exports.constructOptionsFrom  = constructOptionsFrom
exports.filterForCallback     = filterForCallback
exports.paramsHaveRequestBody = paramsHaveRequestBody

Version data entries

24 entries across 17 versions & 2 rubygems

Version Path
entangled-0.0.11 spec/dummy/public/node_modules/phantomjs/node_modules/request/lib/helpers.js
entangled-0.0.11 spec/dummy/public/node_modules/bower/node_modules/request/lib/helpers.js
entangled-0.0.10 spec/dummy/public/node_modules/bower/node_modules/request/lib/helpers.js
entangled-0.0.10 spec/dummy/public/node_modules/phantomjs/node_modules/request/lib/helpers.js