Comparing version 0.0.3 to 0.0.4
32
cot.js
@@ -85,13 +85,11 @@ /* | ||
if (response.headers['content-type'] === 'application/json') { | ||
trycatch(function (_) { return JSON.parse(response.body); }, onParsed); | ||
try { | ||
response.json = JSON.parse(response.body); | ||
} | ||
catch (err) { | ||
next(err); | ||
return; | ||
} | ||
} | ||
else { | ||
next(null, response); | ||
} | ||
} | ||
function onParsed(err, json) { | ||
if (err) { next(err); return; } | ||
response.json = json; | ||
next(null, response); | ||
@@ -286,3 +284,8 @@ } | ||
if (typeof query[key] !== 'undefined') { | ||
q[key] = JSON.stringify(query[key]); | ||
if (key === 'startkey_docid' || key === 'endkey_docid') { | ||
q[key] = query[key]; | ||
} | ||
else { | ||
q[key] = JSON.stringify(query[key]); | ||
} | ||
} | ||
@@ -413,11 +416,2 @@ }); | ||
function trycatch(fn, next) { | ||
try { | ||
next(null, fn()); | ||
} | ||
catch (err) { | ||
next(err); | ||
} | ||
} | ||
function once(f) { | ||
@@ -424,0 +418,0 @@ var called = false; |
@@ -5,3 +5,3 @@ { | ||
"keywords": ["couch", "couchdb"], | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"main": "cot", | ||
@@ -8,0 +8,0 @@ "dependencies": {}, |
20217
6
529