Comparing version 0.5.8 to 0.5.9
{ | ||
"name": "popsicle", | ||
"version": "0.5.8", | ||
"version": "0.5.9", | ||
"description": "Simple HTTP requests for node and the browser", | ||
@@ -5,0 +5,0 @@ "main": "popsicle.js", |
@@ -58,2 +58,23 @@ /* global define */ | ||
/** | ||
* Grab properties from an object to create a new object. | ||
* | ||
* @param {Object} obj | ||
* @param {Array} props | ||
* @return {Object} | ||
*/ | ||
function pluck (obj, props) { | ||
var dest = {} | ||
for (var i = 0; i < props.length; i++) { | ||
var prop = props[i] | ||
if (obj[prop] != null) { | ||
dest[prop] = obj[prop] | ||
} | ||
} | ||
return dest | ||
} | ||
/** | ||
* Create a function to set progress properties on a request instance. | ||
@@ -917,2 +938,16 @@ * | ||
/** | ||
* Return a JSON stringify-able object. | ||
* | ||
* @return {Object} | ||
*/ | ||
Response.prototype.toJSON = function () { | ||
return pluck(this, [ | ||
'headers', | ||
'headerNames', | ||
'status', | ||
'body' | ||
]) | ||
} | ||
/** | ||
* Initialise a request instance. | ||
@@ -1017,2 +1052,34 @@ * | ||
/** | ||
* Return a JSON stringify-able object. | ||
* | ||
* @return {Object} | ||
*/ | ||
Request.prototype.toJSON = function () { | ||
return pluck(this, [ | ||
'url', | ||
'method', | ||
'query', | ||
'timeout', | ||
'maxRedirects', | ||
'rejectUnauthorized', | ||
'stream', | ||
'raw', | ||
'encoding', | ||
'parse', | ||
'withCredentials', | ||
'uploaded', | ||
'downloaded', | ||
'completed', | ||
'uploadSize', | ||
'uploadTotal', | ||
'downloadSize', | ||
'downloadTotal', | ||
'headers', | ||
'headerNames', | ||
'opened', | ||
'aborted' | ||
]) | ||
} | ||
/** | ||
* Retrieve the current request URL. | ||
@@ -1019,0 +1086,0 @@ * |
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
54439
1408