superagent-cache
Advanced tools
Comparing version 3.1.0 to 3.1.1
{ | ||
"name": "superagent-cache", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "Superagent with flexible built-in caching.", | ||
@@ -5,0 +5,0 @@ "main": "superagentCache.js", |
31
utils.js
@@ -65,2 +65,21 @@ module.exports = { | ||
/** | ||
* Add an array of key-value pairs to an object (mutation by reference) | ||
* @param {object} obj | ||
* @param {array} arr | ||
*/ | ||
addKvArrayToObj: function(obj, arr){ | ||
for(var i = 0; i < arr.length; i++){ | ||
var kvString = arr[i].split(`=`); | ||
if (Array.isArray(obj[kvString[0]])) { | ||
obj[kvString[0]].push(kvString[1]) | ||
} else if (obj[kvString[0]]) { | ||
obj[kvString[0]] = [obj[kvString[0]], kvString[1]]; | ||
} else { | ||
obj[kvString[0]] = kvString[1]; | ||
} | ||
} | ||
return obj; | ||
}, | ||
/** | ||
* Convert an array to an object | ||
@@ -75,6 +94,3 @@ * @param {array} arr | ||
var kvArray = str.split('&'); | ||
for(var j = 0; j < kvArray.length; j++){ | ||
var kvString = kvArray[j].split('='); | ||
obj[kvString[0]] = kvString[1]; | ||
} | ||
obj = this.addKvArrayToObj(obj, kvArray); | ||
} | ||
@@ -92,3 +108,2 @@ return obj; | ||
if(str){ | ||
var obj = {}; | ||
if(~str.indexOf('?')){ | ||
@@ -99,7 +114,3 @@ var strs = str.split('?'); | ||
var kvArray = str.split('&'); | ||
for(var i = 0; i < kvArray.length; i++){ | ||
var kvString = kvArray[i].split('='); | ||
obj[kvString[0]] = kvString[1]; | ||
} | ||
return obj; | ||
return this.addKvArrayToObj({}, kvArray); | ||
} | ||
@@ -106,0 +117,0 @@ return null; |
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
78549
13
1598