Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bluereq

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bluereq - npm Package Compare versions

Comparing version 2.1.10 to 2.1.11

8

lib/arg_parser.js

@@ -1,2 +0,2 @@

const getOpts = require('./get_options')
const getOptions = require('./get_options')
const haveData = [ 'POST', 'PUT', 'MATCH' ]

@@ -7,5 +7,5 @@

const hasData = haveData.includes(method)
const opts = getOpts(args, hasData)
opts.config.method = method
return opts
const options = getOptions(args, hasData)
options.method = method
return options
}

@@ -5,4 +5,4 @@ const request = require('./promisified_request')

const customRequest = function (method, ...args) {
const opts = parseArgs(method, args)
return request(opts.config, opts.callback)
const options = parseArgs(method, args)
return request(options)
}

@@ -9,0 +9,0 @@

const signature = require('./signature_checker')
module.exports = function (args, hasData = false) {
let opts = {}
let options
// get(url) or delete(url) or post(url) or put(url) or head(url)
if (signature.matches(args, 'string')) {
opts.config = { url: args[0] }
opts.config.json = hasData ? {} : true
options = { url: args[0] }
options.json = hasData ? {} : true
// get(config) or delete(config) or post(config) or put(config) or head(config)
// get(options) or delete(options) or post(options) or put(options) or head(options)
} else if (signature.matches(args, 'object')) {
opts.config = args[0]
if (opts.config.json == null) opts.config.json = true
options = args[0]
if (options.json == null) options.json = true
// post(url, json) or put(url, json)
} else if (signature.matches(args, 'string', 'object') && hasData) {
opts.config = { url: args[0], json: args[1] }
options = { url: args[0], json: args[1] }
// post(url, text) or put(url, text)
} else if (signature.matches(args, 'string', 'string') && hasData) {
opts.config = { url: args[0], body: args[1] }
options = { url: args[0], body: args[1] }
} else {

@@ -28,5 +28,5 @@ throw new Error(`Invalid params: ${args.join(', ')}`)

// Default to gzip on
opts.config.gzip = opts.config.gzip !== false
options.gzip = options.gzip !== false
return opts
return options
}

@@ -13,5 +13,5 @@ const request = require('request')

module.exports = function (config) {
module.exports = function (options) {
return new BluePromise(function (resolve, reject) {
request(config, function (err, res) {
request(options, function (err, res) {
if (err != null) {

@@ -18,0 +18,0 @@ reject(err)

{
"name": "bluereq",
"version": "2.1.10",
"version": "2.1.11",
"description": "A bluebird promise wrapper for HTTP requests",

@@ -5,0 +5,0 @@ "main": "lib/bluereq.js",

const should = require('should')
const getOpts = require('../../lib/get_options')
const getOptions = require('../../lib/get_options')
describe('argParser', () => {
describe('getOpts', () => {
describe('getOptions', () => {
describe('[url]', () => {
it('should return a valid options object', () => {
const args = ['http://example.dev']
should(getOpts(args).config).deepEqual({ url: 'http://example.dev', json: true, gzip: true })
should(getOpts(args).callback).not.be.ok()
should(getOptions(args)).deepEqual({ url: 'http://example.dev', json: true, gzip: true })
})

@@ -17,5 +16,4 @@ })

const args = [{ url: 'http://example.dev' }]
const opts = getOpts(args)
should(opts.config).deepEqual(args[0])
should(opts.callback).not.be.ok()
const options = getOptions(args)
should(options).deepEqual(args[0])
})

@@ -27,5 +25,4 @@ })

it('should return a valid options object', () => {
const opts = getOpts(args, true)
should(opts.config).deepEqual({ url: args[0], json: args[1], gzip: true })
should(opts.callback).not.be.ok()
const options = getOptions(args, true)
should(options).deepEqual({ url: args[0], json: args[1], gzip: true })
})

@@ -37,4 +34,4 @@ })

it('should return without json option', () => {
const opts = getOpts(args, true)
should(opts.config).deepEqual({ url: args[0], body: args[1], gzip: true })
const options = getOptions(args, true)
should(options).deepEqual({ url: args[0], body: args[1], gzip: true })
})

@@ -41,0 +38,0 @@ })

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc