Comparing version 0.0.7 to 0.0.8
@@ -9,3 +9,3 @@ 'use strict'; | ||
var verbose = opts.verbose; | ||
var namespace = 'get-it'; | ||
var namespace = opts.namespace || 'get-it'; | ||
var defaultLogger = debugIt(namespace); | ||
@@ -12,0 +12,0 @@ var log = opts.log || defaultLogger; |
@@ -21,3 +21,3 @@ 'use strict'; | ||
if (options.query) { | ||
url.query = objectAssign({}, url.query, options.query); | ||
url.query = objectAssign({}, url.query, removeUndefined(options.query)); | ||
} | ||
@@ -35,3 +35,3 @@ | ||
function normalizeTimeout(time) { | ||
if (time === false) { | ||
if (time === false || time === 0) { | ||
return false; | ||
@@ -51,2 +51,12 @@ } | ||
} | ||
function removeUndefined(obj) { | ||
var target = {}; | ||
for (var key in obj) { | ||
if (obj[key] !== undefined) { | ||
target[key] = obj[key]; | ||
} | ||
} | ||
return target; | ||
} | ||
//# sourceMappingURL=defaultOptionsProcessor.js.map |
'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var objectAssign = require('object-assign'); | ||
var isPlainObject = require('is-plain-object'); | ||
var serializeTypes = ['boolean', 'string', 'number']; | ||
module.exports = function () { | ||
return { | ||
processOptions: function processOptions(options) { | ||
if (typeof options.body === 'undefined') { | ||
var body = options.body; | ||
var shouldSerialize = serializeTypes.indexOf(typeof body === 'undefined' ? 'undefined' : _typeof(body)) !== -1 || Array.isArray(body) || isPlainObject(body) || body && typeof body.toJSON === 'function'; | ||
if (!shouldSerialize) { | ||
return options; | ||
@@ -10,0 +18,0 @@ } |
{ | ||
"name": "get-it", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "Generic HTTP request library for node and browsers", | ||
@@ -48,2 +48,3 @@ "main": "lib/index.js", | ||
"into-stream": "^3.1.0", | ||
"is-plain-object": "^2.0.1", | ||
"is-retry-allowed": "^1.1.0", | ||
@@ -50,0 +51,0 @@ "is-stream": "^1.1.0", |
@@ -5,3 +5,3 @@ const debugIt = require('debug') | ||
const verbose = opts.verbose | ||
const namespace = 'get-it' | ||
const namespace = opts.namespace || 'get-it' | ||
const defaultLogger = debugIt(namespace) | ||
@@ -8,0 +8,0 @@ const log = opts.log || defaultLogger |
@@ -23,3 +23,3 @@ const objectAssign = require('object-assign') | ||
if (options.query) { | ||
url.query = objectAssign({}, url.query, options.query) | ||
url.query = objectAssign({}, url.query, removeUndefined(options.query)) | ||
} | ||
@@ -39,3 +39,3 @@ | ||
function normalizeTimeout(time) { | ||
if (time === false) { | ||
if (time === false || time === 0) { | ||
return false | ||
@@ -55,1 +55,11 @@ } | ||
} | ||
function removeUndefined(obj) { | ||
const target = {} | ||
for (const key in obj) { | ||
if (obj[key] !== undefined) { | ||
target[key] = obj[key] | ||
} | ||
} | ||
return target | ||
} |
const objectAssign = require('object-assign') | ||
const isPlainObject = require('is-plain-object') | ||
const serializeTypes = ['boolean', 'string', 'number'] | ||
module.exports = () => ({ | ||
processOptions: options => { | ||
if (typeof options.body === 'undefined') { | ||
const body = options.body | ||
const shouldSerialize = ( | ||
serializeTypes.indexOf(typeof body) !== -1 | ||
|| Array.isArray(body) | ||
|| isPlainObject(body) | ||
|| (body && typeof body.toJSON === 'function') | ||
) | ||
if (!shouldSerialize) { | ||
return options | ||
@@ -7,0 +18,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
384035
2113
17
+ Addedis-plain-object@^2.0.1
+ Addedis-plain-object@2.0.4(transitive)
+ Addedisobject@3.0.1(transitive)