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

superagent-cache

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

superagent-cache - npm Package Compare versions

Comparing version 3.1.0 to 3.1.1

test/server/utils.js

2

package.json
{
"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",

@@ -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;

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