Socket
Socket
Sign inDemoInstall

node-parse-api

Package Overview
Dependencies
0
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.1 to 0.3.2

45

lib/Parse.js
var qs = require('querystring');
qs.escape = function(q){ return q; };

@@ -231,2 +230,33 @@ module.exports = Parse;

function reformatDatesToParse(object){
if(typeof object !== 'object') return object;
for( var key in object){
if(object[key] instanceof Date){
object[key] = {
"__type": "Date",
"iso": object[key].toISOString()
}
}else if(typeof object[key] === 'object'){
object[key] = reformatDatesToParse(object[key]);
}
}
return object;
}
function reformatDatesFromParse(object){
if(typeof object !== 'object') return object;
for( var key in object){
if(typeof object[key]==='object'){
if(object[key]["__type"] && object[key]["__type"]==="Date"){
object[key] = new Date(object[key]["iso"]);
}else{
object[key] = reformatDatesFromParse(object[key]);
}
}
}
return object;
}
// Parse.com https api request

@@ -242,6 +272,17 @@ function parseRequest(method, path, data, callback, contentType) {

//convert javascript date objects to parse format
if(typeof data === 'object'){
data = reformatDatesToParse(data);
}
switch (method) {
case 'GET':
if (data) {
// Avoid globally overriding `querystring.escape`:
// http://nodejs.org/api/querystring.html#querystring_querystring_escape
var originalEscape = qs.escape;
qs.escape = function(q){ return q; };
path += (path.indexOf("?") == -1 ? '?' : '&') + qs.stringify(data);
qs.escape = originalEscape;
}

@@ -301,3 +342,3 @@ break;

try {
var data = JSON.parse(json);
var data = reformatDatesFromParse(JSON.parse(json));
} catch (err) {

@@ -304,0 +345,0 @@ }

2

package.json
{
"name": "node-parse-api",
"description": "A Parse.com REST API client for Node.js",
"version": "0.3.1",
"version": "0.3.2",
"author": "Chris Johnson <tenorviol@yahoo.com>, Michael Leveton <mleveton@prepcloud.com>, Seth Gholson",

@@ -6,0 +6,0 @@ "repository": "git://github.com/leveton/node-parse-api",

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc