Comparing version 0.8.0 to 0.8.1
10
clerk.js
@@ -122,3 +122,3 @@ "use strict"; | ||
clerk.version = "0.8.0"; | ||
clerk.version = "0.8.1"; | ||
@@ -338,2 +338,3 @@ /** | ||
var key, value; | ||
var fn = options.fn; | ||
@@ -368,5 +369,3 @@ // create request | ||
// send request | ||
var fn = options.fn; | ||
req.end(function (res) { | ||
var err = res.error; | ||
req.end(function (err, res) { | ||
var data; | ||
@@ -380,4 +379,5 @@ | ||
if (err) return fn && fn(err); | ||
res.data = data; | ||
fn && fn(err || null, data, res.status, res.header, res); | ||
@@ -384,0 +384,0 @@ }); |
@@ -19,3 +19,3 @@ this.clerk=function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return t[n].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";function n(t){return n.make(t)}function o(){}function i(t,e){this.uri=t,this._db={},this.auth=e}function s(t,e,r){this.client=t,this.name=e,this.uri=t.uri+"/"+encodeURIComponent(e),this.auth=r}/*! | ||
*/ | ||
var a=r(1),u=function(t){for(var e,r,n=1;e=arguments[n++];)for(r in e)t[r]=e[r];return t},p=function(t){return Object.prototype.toString.call(t)},h=function(t){return"[object String]"==p(t)},c=function(t){return"[object Array]"==p(t)},l=function(t){return"[object Function]"==p(t)};n.version="0.8.0",n.defaultHost="http://127.0.0.1:5984",n.make=function(t){if(!t)return new i(this.defaultHost);t=n._parseURI(t);var e=/\/*([^\/]+)\/*$/.exec(t.path);e&&(t.path=t.path.substr(0,e.index),e=e[1]&&decodeURIComponent(e[1])),t.auth&&(t.auth="Basic "+n.btoa(t.auth));var r=new n.Client(t.base+t.path,t.auth);return e?r.db(e):r},n.btoa="undefined"!=typeof Buffer?function(t){return new Buffer(t).toString("base64")}:function(t){return btoa(t)},n._parseURI=function(t){var e;return t&&(e=/^(https?:\/\/)(?:([^\/@]+)@)?([^\/]+)(.*)\/*$/.exec(t))?{base:e[1]+e[3].replace(/\/+/g,"/"),path:e[4],auth:e[2]&&decodeURIComponent(e[2])}:{base:t||"",path:""}},o.prototype.request=function(){var t=[].slice.call(arguments),e=l(t[t.length-1])&&t.pop();return this._request({method:t[0],path:t[1],query:t[2],data:t[3],headers:t[4],fn:e})},o.prototype._request=function(t){function e(){var e=t._,n=t.fn;return n&&(t.fn=e?function(){n.apply(r,e.apply(r,arguments)||arguments)}:n),r._do(t)}var r=this;null==t.method&&(t.method="GET"),null==t.headers&&(t.headers={}),null==t.auth&&(t.auth=this.auth),t.path=t.path?"/"+t.path:"",null==t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/json"),null==t.headers.Accept&&(t.headers.Accept="application/json"),this.auth&&null==t.headers.Authorization&&(t.headers.Authorization=this.auth),t.uri=this.uri+t.path,t.body=t.data&&JSON.stringify(t.data,/^\/_design/.test(t.path)&&this._replacer)||"";var n,o;return t.fn||"undefined"==typeof Promise?void e():(n=new Promise(function(e,r){t.fn=function(t,n,o,i,s){t?(t.body=n,t.status=o,t.headers=i,t.res=s,r(t)):(Object.defineProperties&&Object.defineProperties(n,{_status:{value:o},_headers:{value:i},_response:{value:s}}),e(n))}}),o=e(),n.request=o,n.abort=function(){return o.abort(),t.fn(new Error("abort")),n},n)},o.prototype._do=function(t){var e,r,n=this,o=a(t.method,t.uri);if(t.query){for(e in t.query)"object"==typeof(r=t.query[e])&&(t.query[e]=JSON.stringify(r));o.query(t.query)}t.headers&&(o.set(t.headers),o.withCredentials&&null!=t.headers.Authorization&&o.withCredentials()),t.body&&o.send(t.body);var i=t.fn;return o.end(function(t){var e,r=t.error;r||((e=t.body)?e.error?r=n._error(e):e=n._response(e):e=t.text),t.data=e,i&&i(r||null,e,t.status,t.header,t)}),o},o.prototype._response=function(t){var e,r,n=t.rows||t.results||t.uuids||c(t)&&t,o=this._meta,i=0;if(n)for(u(n,t).json=t,e=n.length;e>i;i++)r=n[i]=o(n[i]),r.doc&&(r.doc=o(r.doc));else n=o(t);return n},o.prototype._error=function(t){var e=new Error(t.reason);return e.code=t.error,u(e,t)},o.prototype._replacer=function(t,e){return l(e)?e.toString():e},o.prototype._meta=function(t){var e,r=!t._id&&t.id,n=!t._rev&&t.rev;return(r||n)&&(e=function(){},t=u(new e,t),e=e.prototype,r&&(e._id=t.id),n&&(e._rev=t.rev)),t},o.prototype._=function(t,e,r){function n(t,e,r){return r||(r={}),a._request({method:t,path:e||n.p,query:r.q||n.q,data:r.b||n.b,headers:r.h||n.h,fn:r.f||n.f,_:r._||n._})}var o,i,s,a=this;return t=[].slice.call(t,e||0),n.f=l(t[t.length-1])&&t.pop(),n.p=h(t[0])&&encodeURI(t.shift()),n.q=t[r?1:0]||{},n.h=t[r?2:1]||{},r&&(o=n.b=t[0])&&((i=n.p||o._id||o.id)&&(n.p=i),(s=n.q.rev||o._rev||o.rev)&&(n.q.rev=s)),n},i.prototype=new o,i.prototype.db=function(t){var e=this._db;return e[t]||(e[t]=new s(this,t,this.auth))},i.prototype.dbs=function(){return this._(arguments)("GET","_all_dbs")},i.prototype.uuids=function(t){var e=this._(arguments,+t==t?1:0);return t>1&&(e.q.count=t),e("GET","_uuids")},i.prototype.info=function(){return this._(arguments)("GET")},i.prototype.stats=function(){return this._(arguments)("GET","_stats")},i.prototype.log=function(){return this._(arguments)("GET","_log")},i.prototype.tasks=function(){return this._(arguments)("GET","_active_tasks")},i.prototype.config=function(){var t=[].slice.call(arguments),e=h(t[0])&&t.shift()||"",r=h(t[0])&&t.shift(),n=h(r)?"PUT":"GET";return this._(t)(n,"_config/"+e,{b:r})},i.prototype.replicate=function(t){return this._(arguments,1)("POST","_replicate",{b:t})},s.prototype=new o,s.prototype.create=function(){return this._(arguments)("PUT")},s.prototype.destroy=function(){return this._(arguments)("DELETE")},s.prototype.info=function(){return this._(arguments)("GET")},s.prototype.exists=function(){var t=this._(arguments);return t._=function(t,e,r,n,o){return[t,200===r,r,n,o]},t("HEAD")},s.prototype.get=function(){return this._(arguments)("GET")},s.prototype.head=function(){var t=this,e=t._(arguments);return e._=function(t,r,n,o,i){return[t,t?null:{_id:e.p,_rev:o.etag&&JSON.parse(o.etag),contentType:o["content-type"],contentLength:o["content-length"]},n,o,i]},e("HEAD")},s.prototype.post=function(t){var e=this._(arguments,1);return c(t)?(e.p="_bulk_docs",e.b=u({docs:t},e.q),e.q=null):e.b=t,e("POST")},s.prototype.put=function(){var t=this._(arguments,0,1);if(t.p||(t.p=t.b._id||t.b.id),!t.p)throw new Error("missing id");return t("PUT")},s.prototype.del=function(t){if(c(t)){for(var e,r=0,n=t.length;n>r;r++)e=t[r],t[r]={_id:e._id||e.id,_rev:e._rev||e.rev,_deleted:!0};return this.post.apply(this,arguments)}var o=this._(arguments,0,1);if(!o.p)throw new Error("missing id");return o("DELETE")},s.prototype.copy=function(t,e){var r=this._(arguments,2),n=encodeURIComponent(t.id||t._id||t),o=encodeURIComponent(e.id||e._id||e),i=t.rev||t._rev,s=e.rev||e._rev;return i&&(r.q.rev=i),s&&(o+="?rev="+encodeURIComponent(s)),r.h.Destination=o,r("COPY",n)},s.prototype.all=function(){var t=this._(arguments),e=this._viewOptions(t.q);return t(e?"POST":"GET","_all_docs",{b:e})},s.prototype.find=function(t){var e,r,n=this._(arguments,1);return h(t)?(e=t.split("/",2),e="_design/"+encodeURIComponent(e[0])+"/_view/"+encodeURIComponent(e[1])):(e="_temp_view",r=t),r=this._viewOptions(n.q,r),n(r?"POST":"GET",e,{b:r})},s.prototype.changes=function(){var t=this._(arguments);return"longpoll"!=t.q.feed&&delete t.q.feed,this._changes(t)},s.prototype.follow=function(){var t=this,e=this._(arguments),r=e.f;return r?(e.q.feed="longpoll",e.f=function(n,o){var i,s,a=[].slice.call(arguments);for(s=0;s<o.length&&(a[1]=o[s],!(i=r.apply(t,a)===!1||n));s++);i||t._changes(e)},this._changes(e)):this},s.prototype._changes=function(t){return t("GET","_changes")},s.prototype.update=function(t){var e=this._(arguments,1,1),r=t.split("/",2);return r="_design/"+encodeURIComponent(r[0])+"/_update/"+encodeURIComponent(r[1]),e.p&&(r+="/"+e.p),e("POST",r)},s.prototype.attachment=function(t,e){var r=this._(arguments,2),n=encodeURIComponent(t._id||t.id||t)+"/"+encodeURIComponent(e);return r("GET",n,options)},s.prototype.attach=function(t,e,r){var n=this._(arguments,3);return n.p=encodeURIComponent(t._id||t.id)+"/"+encodeURIComponent(e),n.q.rev||(n.q.rev=t._rev||t.rev),n.q.body=r,n("PUT",path)},s.prototype.replicate=function(t){return t.source||(t.source=this.name),t.target||(t.target=this.name),this.client.replicate.apply(this.client,arguments)},s.prototype.commit=function(){return this._(arguments)("POST","_ensure_full_commit")},s.prototype.purge=function(t){return this._(arguments,1)("POST","_purge",{b:t})},s.prototype.compact=function(){var t=this._(arguments);return t("POST","_compact/"+(t.p||""))},s.prototype.vacuum=function(){return this._(arguments)("POST","_view_cleanup")},s.prototype._viewOptions=function(t,e){return t&&(t.key&&(t.key=JSON.stringify(t.key)),t.startkey&&(t.startkey=JSON.stringify(t.startkey)),t.endkey&&(t.endkey=JSON.stringify(t.endkey)),t.stale&&"update_after"!=t.stale&&(t.stale="ok"),t.keys&&(e||(e={}),e.keys=t.keys,delete t.keys)),e},n.Base=o,n.Client=i,n.DB=s,t.exports=n},function(t,e,r){function n(){}function o(t){var e={}.toString.call(t);switch(e){case"[object File]":case"[object Blob]":case"[object FormData]":return!0;default:return!1}}function i(){if(m.XMLHttpRequest&&("file:"!=m.location.protocol||!m.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(t){}return!1}function s(t){return t===Object(t)}function a(t){if(!s(t))return t;var e=[];for(var r in t)null!=t[r]&&e.push(encodeURIComponent(r)+"="+encodeURIComponent(t[r]));return e.join("&")}function u(t){for(var e,r,n={},o=t.split("&"),i=0,s=o.length;s>i;++i)r=o[i],e=r.split("="),n[decodeURIComponent(e[0])]=decodeURIComponent(e[1]);return n}function p(t){var e,r,n,o,i=t.split(/\r?\n/),s={};i.pop();for(var a=0,u=i.length;u>a;++a)r=i[a],e=r.indexOf(":"),n=r.slice(0,e).toLowerCase(),o=v(r.slice(e+1)),s[n]=o;return s}function h(t){return t.split(/ *; */).shift()}function c(t){return _(t.split(/ *; */),function(t,e){var r=e.split(/ *= */),n=r.shift(),o=r.shift();return n&&o&&(t[n]=o),t},{})}function l(t,e){e=e||{},this.req=t,this.xhr=this.req.xhr,this.text="HEAD"!=this.req.method?this.xhr.responseText:null,this.setStatusProperties(this.xhr.status),this.header=this.headers=p(this.xhr.getAllResponseHeaders()),this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this.setHeaderProperties(this.header),this.body="HEAD"!=this.req.method?this.parseBody(this.text):null}function f(t,e){var r=this;y.call(this),this._query=this._query||[],this.method=t,this.url=e,this.header={},this._header={},this.on("end",function(){var t=null,e=null;try{e=new l(r)}catch(n){t=new Error("Parser is unable to parse the response"),t.parse=!0,t.original=n}r.callback(t,e)})}function d(t,e){return"function"==typeof e?new f("GET",t).end(e):1==arguments.length?new f("GET",t):new f(t,e)}var y=r(2),_=r(3),m="undefined"==typeof window?this:window,v="".trim?function(t){return t.trim()}:function(t){return t.replace(/(^\s*|\s*$)/g,"")};d.serializeObject=a,d.parseString=u,d.types={html:"text/html",json:"application/json",xml:"application/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},d.serialize={"application/x-www-form-urlencoded":a,"application/json":JSON.stringify},d.parse={"application/x-www-form-urlencoded":u,"application/json":JSON.parse},l.prototype.get=function(t){return this.header[t.toLowerCase()]},l.prototype.setHeaderProperties=function(){var t=this.header["content-type"]||"";this.type=h(t);var e=c(t);for(var r in e)this[r]=e[r]},l.prototype.parseBody=function(t){var e=d.parse[this.type];return e&&t&&t.length?e(t):null},l.prototype.setStatusProperties=function(t){var e=t/100|0;this.status=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.clientError=4==e,this.serverError=5==e,this.error=4==e||5==e?this.toError():!1,this.accepted=202==t,this.noContent=204==t||1223==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.notFound=404==t,this.forbidden=403==t},l.prototype.toError=function(){var t=this.req,e=t.method,r=t.url,n="cannot "+e+" "+r+" ("+this.status+")",o=new Error(n);return o.status=this.status,o.method=e,o.url=r,o},d.Response=l,y(f.prototype),f.prototype.use=function(t){return t(this),this},f.prototype.timeout=function(t){return this._timeout=t,this},f.prototype.clearTimeout=function(){return this._timeout=0,clearTimeout(this._timer),this},f.prototype.abort=function(){return this.aborted?void 0:(this.aborted=!0,this.xhr.abort(),this.clearTimeout(),this.emit("abort"),this)},f.prototype.set=function(t,e){if(s(t)){for(var r in t)this.set(r,t[r]);return this}return this._header[t.toLowerCase()]=e,this.header[t]=e,this},f.prototype.unset=function(t){return delete this._header[t.toLowerCase()],delete this.header[t],this},f.prototype.getHeader=function(t){return this._header[t.toLowerCase()]},f.prototype.type=function(t){return this.set("Content-Type",d.types[t]||t),this},f.prototype.accept=function(t){return this.set("Accept",d.types[t]||t),this},f.prototype.auth=function(t,e){var r=btoa(t+":"+e);return this.set("Authorization","Basic "+r),this},f.prototype.query=function(t){return"string"!=typeof t&&(t=a(t)),t&&this._query.push(t),this},f.prototype.field=function(t,e){return this._formData||(this._formData=new FormData),this._formData.append(t,e),this},f.prototype.attach=function(t,e,r){return this._formData||(this._formData=new FormData),this._formData.append(t,e,r),this},f.prototype.send=function(t){var e=s(t),r=this.getHeader("Content-Type");if(e&&s(this._data))for(var n in t)this._data[n]=t[n];else"string"==typeof t?(r||this.type("form"),r=this.getHeader("Content-Type"),this._data="application/x-www-form-urlencoded"==r?this._data?this._data+"&"+t:t:(this._data||"")+t):this._data=t;return e?(r||this.type("json"),this):this},f.prototype.callback=function(t,e){var r=this._callback;return this.clearTimeout(),2==r.length?r(t,e):t?this.emit("error",t):void r(e)},f.prototype.crossDomainError=function(){var t=new Error("Origin is not allowed by Access-Control-Allow-Origin");t.crossDomain=!0,this.callback(t)},f.prototype.timeoutError=function(){var t=this._timeout,e=new Error("timeout of "+t+"ms exceeded");e.timeout=t,this.callback(e)},f.prototype.withCredentials=function(){return this._withCredentials=!0,this},f.prototype.end=function(t){var e=this,r=this.xhr=i(),s=this._query.join("&"),a=this._timeout,u=this._formData||this._data;if(this._callback=t||n,r.onreadystatechange=function(){return 4==r.readyState?0==r.status?e.aborted?e.timeoutError():e.crossDomainError():void e.emit("end"):void 0},r.upload&&(r.upload.onprogress=function(t){t.percent=t.loaded/t.total*100,e.emit("progress",t)}),a&&!this._timer&&(this._timer=setTimeout(function(){e.abort()},a)),s&&(s=d.serializeObject(s),this.url+=~this.url.indexOf("?")?"&"+s:"?"+s),r.open(this.method,this.url,!0),this._withCredentials&&(r.withCredentials=!0),"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof u&&!o(u)){var p=d.serialize[this.getHeader("Content-Type")];p&&(u=p(u))}for(var h in this.header)null!=this.header[h]&&r.setRequestHeader(h,this.header[h]);return this.emit("request",this),r.send(u),this},d.Request=f,d.get=function(t,e,r){var n=d("GET",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},d.head=function(t,e,r){var n=d("HEAD",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},d.del=function(t,e){var r=d("DELETE",t);return e&&r.end(e),r},d.patch=function(t,e,r){var n=d("PATCH",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},d.post=function(t,e,r){var n=d("POST",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},d.put=function(t,e,r){var n=d("PUT",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},t.exports=d},function(t){function e(t){return t?r(t):void 0}function r(t){for(var r in e.prototype)t[r]=e.prototype[r];return t}t.exports=e,e.prototype.on=e.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks[t]=this._callbacks[t]||[]).push(e),this},e.prototype.once=function(t,e){function r(){n.off(t,r),e.apply(this,arguments)}var n=this;return this._callbacks=this._callbacks||{},r.fn=e,this.on(t,r),this},e.prototype.off=e.prototype.removeListener=e.prototype.removeAllListeners=e.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r=this._callbacks[t];if(!r)return this;if(1==arguments.length)return delete this._callbacks[t],this;for(var n,o=0;o<r.length;o++)if(n=r[o],n===e||n.fn===e){r.splice(o,1);break}return this},e.prototype.emit=function(t){this._callbacks=this._callbacks||{};var e=[].slice.call(arguments,1),r=this._callbacks[t];if(r){r=r.slice(0);for(var n=0,o=r.length;o>n;++n)r[n].apply(this,e)}return this},e.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks[t]||[]},e.prototype.hasListeners=function(t){return!!this.listeners(t).length}},function(t){t.exports=function(t,e,r){for(var n=0,o=t.length,i=3==arguments.length?r:t[n++];o>n;)i=e.call(null,i,t[n],++n,t);return i}}]); | ||
var a=r(1),u=function(t){for(var e,r,n=1;e=arguments[n++];)for(r in e)t[r]=e[r];return t},p=function(t){return Object.prototype.toString.call(t)},h=function(t){return"[object String]"==p(t)},c=function(t){return"[object Array]"==p(t)},l=function(t){return"[object Function]"==p(t)};n.version="0.8.0",n.defaultHost="http://127.0.0.1:5984",n.make=function(t){if(!t)return new i(this.defaultHost);t=n._parseURI(t);var e=/\/*([^\/]+)\/*$/.exec(t.path);e&&(t.path=t.path.substr(0,e.index),e=e[1]&&decodeURIComponent(e[1])),t.auth&&(t.auth="Basic "+n.btoa(t.auth));var r=new n.Client(t.base+t.path,t.auth);return e?r.db(e):r},n.btoa="undefined"!=typeof Buffer?function(t){return new Buffer(t).toString("base64")}:function(t){return btoa(t)},n._parseURI=function(t){var e;return t&&(e=/^(https?:\/\/)(?:([^\/@]+)@)?([^\/]+)(.*)\/*$/.exec(t))?{base:e[1]+e[3].replace(/\/+/g,"/"),path:e[4],auth:e[2]&&decodeURIComponent(e[2])}:{base:t||"",path:""}},o.prototype.request=function(){var t=[].slice.call(arguments),e=l(t[t.length-1])&&t.pop();return this._request({method:t[0],path:t[1],query:t[2],data:t[3],headers:t[4],fn:e})},o.prototype._request=function(t){function e(){var e=t._,n=t.fn;return n&&(t.fn=e?function(){n.apply(r,e.apply(r,arguments)||arguments)}:n),r._do(t)}var r=this;null==t.method&&(t.method="GET"),null==t.headers&&(t.headers={}),null==t.auth&&(t.auth=this.auth),t.path=t.path?"/"+t.path:"",null==t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/json"),null==t.headers.Accept&&(t.headers.Accept="application/json"),this.auth&&null==t.headers.Authorization&&(t.headers.Authorization=this.auth),t.uri=this.uri+t.path,t.body=t.data&&JSON.stringify(t.data,/^\/_design/.test(t.path)&&this._replacer)||"";var n,o;return t.fn||"undefined"==typeof Promise?void e():(n=new Promise(function(e,r){t.fn=function(t,n,o,i,s){t?(t.body=n,t.status=o,t.headers=i,t.res=s,r(t)):(Object.defineProperties&&Object.defineProperties(n,{_status:{value:o},_headers:{value:i},_response:{value:s}}),e(n))}}),o=e(),n.request=o,n.abort=function(){return o.abort(),t.fn(new Error("abort")),n},n)},o.prototype._do=function(t){var e,r,n=this,o=t.fn,i=a(t.method,t.uri);if(t.query){for(e in t.query)"object"==typeof(r=t.query[e])&&(t.query[e]=JSON.stringify(r));i.query(t.query)}return t.headers&&(i.set(t.headers),i.withCredentials&&null!=t.headers.Authorization&&i.withCredentials()),t.body&&i.send(t.body),i.end(function(t,e){var r;return t||((r=e.body)?r.error?t=n._error(r):r=n._response(r):r=e.text),t?o&&o(t):(e.data=r,void(o&&o(t||null,r,e.status,e.header,e)))}),i},o.prototype._response=function(t){var e,r,n=t.rows||t.results||t.uuids||c(t)&&t,o=this._meta,i=0;if(n)for(u(n,t).json=t,e=n.length;e>i;i++)r=n[i]=o(n[i]),r.doc&&(r.doc=o(r.doc));else n=o(t);return n},o.prototype._error=function(t){var e=new Error(t.reason);return e.code=t.error,u(e,t)},o.prototype._replacer=function(t,e){return l(e)?e.toString():e},o.prototype._meta=function(t){var e,r=!t._id&&t.id,n=!t._rev&&t.rev;return(r||n)&&(e=function(){},t=u(new e,t),e=e.prototype,r&&(e._id=t.id),n&&(e._rev=t.rev)),t},o.prototype._=function(t,e,r,n){function o(t,e,r){return r||(r={}),u._request({method:t,path:e||o.p,query:r.q||o.q,data:r.b||o.b,headers:r.h||o.h,fn:r.f||o.f,_:r._||o._})}var i,s,a,u=this;return t=[].slice.call(t,e||0),o.f=l(t[t.length-1])&&t.pop(),o.p=h(t[0])&&encodeURI(t.shift()),o.q=t[r?1:0]||{},o.h=t[r?2:1]||{},r&&(i=o.b=t[0],n||((s=o.p||i._id||i.id)&&(o.p=s),(a=o.q.rev||i._rev||i.rev)&&(o.q.rev=a))),o},i.prototype=new o,i.prototype.db=function(t){var e=this._db;return e[t]||(e[t]=new s(this,t,this.auth))},i.prototype.dbs=function(){return this._(arguments)("GET","_all_dbs")},i.prototype.uuids=function(t){var e=this._(arguments,+t==t?1:0);return t>1&&(e.q.count=t),e("GET","_uuids")},i.prototype.info=function(){return this._(arguments)("GET")},i.prototype.stats=function(){return this._(arguments)("GET","_stats")},i.prototype.log=function(){return this._(arguments)("GET","_log")},i.prototype.tasks=function(){return this._(arguments)("GET","_active_tasks")},i.prototype.config=function(){var t=[].slice.call(arguments),e=h(t[0])&&t.shift()||"",r=h(t[0])&&t.shift(),n=h(r)?"PUT":"GET";return this._(t)(n,"_config/"+e,{b:r})},i.prototype.replicate=function(t){return this._(arguments,1)("POST","_replicate",{b:t})},s.prototype=new o,s.prototype.create=function(){return this._(arguments)("PUT")},s.prototype.destroy=function(){return this._(arguments)("DELETE")},s.prototype.info=function(){return this._(arguments)("GET")},s.prototype.exists=function(){var t=this._(arguments);return t._=function(t,e,r,n,o){return[t,200===r,r,n,o]},t("HEAD")},s.prototype.get=function(){return this._(arguments)("GET")},s.prototype.head=function(){var t=this,e=t._(arguments);return e._=function(t,r,n,o,i){return[t,t?null:{_id:e.p,_rev:o.etag&&JSON.parse(o.etag),contentType:o["content-type"],contentLength:o["content-length"]},n,o,i]},e("HEAD")},s.prototype.post=function(t){var e=this._(arguments,1);return c(t)?(e.p="_bulk_docs",e.b=u({docs:t},e.q),e.q=null):e.b=t,e("POST")},s.prototype.put=function(){var t=this._(arguments,0,1);if(t.p||(t.p=t.b._id||t.b.id),!t.p)throw new Error("missing id");return t("PUT")},s.prototype.del=function(t){if(c(t)){for(var e,r=0,n=t.length;n>r;r++)e=t[r],t[r]={_id:e._id||e.id,_rev:e._rev||e.rev,_deleted:!0};return this.post.apply(this,arguments)}var o=this._(arguments,0,1);if(!o.p)throw new Error("missing id");return o("DELETE")},s.prototype.copy=function(t,e){var r=this._(arguments,2),n=encodeURIComponent(t.id||t._id||t),o=encodeURIComponent(e.id||e._id||e),i=t.rev||t._rev,s=e.rev||e._rev;return i&&(r.q.rev=i),s&&(o+="?rev="+encodeURIComponent(s)),r.h.Destination=o,r("COPY",n)},s.prototype.all=function(){var t=this._(arguments),e=this._viewOptions(t.q);return t(e?"POST":"GET","_all_docs",{b:e})},s.prototype.find=function(t){var e,r,n=this._(arguments,1);return h(t)?(e=t.split("/",2),e="_design/"+encodeURIComponent(e[0])+"/_view/"+encodeURIComponent(e[1])):(e="_temp_view",r=t),r=this._viewOptions(n.q,r),n(r?"POST":"GET",e,{b:r})},s.prototype.changes=function(){var t=this._(arguments);return"longpoll"!=t.q.feed&&delete t.q.feed,this._changes(t)},s.prototype.follow=function(){var t=this,e=this._(arguments),r=e.f;return r?(e.q.feed="longpoll",e.f=function(n,o){var i,s,a=[].slice.call(arguments);for(s=0;s<o.length&&(a[1]=o[s],!(i=r.apply(t,a)===!1||n));s++);i||t._changes(e)},this._changes(e)):this},s.prototype._changes=function(t){return t("GET","_changes")},s.prototype.update=function(t){var e=this._(arguments,1,1,1),r=t.split("/",2);return r="_design/"+encodeURIComponent(r[0])+"/_update/"+encodeURIComponent(r[1]),e.p&&(r+="/"+e.p),e("POST",r)},s.prototype.attachment=function(t,e){var r=this._(arguments,2),n=encodeURIComponent(t._id||t.id||t)+"/"+encodeURIComponent(e);return r("GET",n,options)},s.prototype.attach=function(t,e,r){var n=this._(arguments,3);return n.p=encodeURIComponent(t._id||t.id)+"/"+encodeURIComponent(e),n.q.rev||(n.q.rev=t._rev||t.rev),n.q.body=r,n("PUT",path)},s.prototype.replicate=function(t){return t.source||(t.source=this.name),t.target||(t.target=this.name),this.client.replicate.apply(this.client,arguments)},s.prototype.commit=function(){return this._(arguments)("POST","_ensure_full_commit")},s.prototype.purge=function(t){return this._(arguments,1)("POST","_purge",{b:t})},s.prototype.compact=function(){var t=this._(arguments);return t("POST","_compact/"+(t.p||""))},s.prototype.vacuum=function(){return this._(arguments)("POST","_view_cleanup")},s.prototype._viewOptions=function(t,e){return t&&(t.key&&(t.key=JSON.stringify(t.key)),t.startkey&&(t.startkey=JSON.stringify(t.startkey)),t.endkey&&(t.endkey=JSON.stringify(t.endkey)),t.stale&&"update_after"!=t.stale&&(t.stale="ok"),t.keys&&(e||(e={}),e.keys=t.keys,delete t.keys)),e},n.Base=o,n.Client=i,n.DB=s,t.exports=n},function(t,e,r){function n(){}function o(t){var e={}.toString.call(t);switch(e){case"[object File]":case"[object Blob]":case"[object FormData]":return!0;default:return!1}}function i(t){return t===Object(t)}function s(t){if(!i(t))return t;var e=[];for(var r in t)null!=t[r]&&e.push(encodeURIComponent(r)+"="+encodeURIComponent(t[r]));return e.join("&")}function a(t){for(var e,r,n={},o=t.split("&"),i=0,s=o.length;s>i;++i)r=o[i],e=r.split("="),n[decodeURIComponent(e[0])]=decodeURIComponent(e[1]);return n}function u(t){var e,r,n,o,i=t.split(/\r?\n/),s={};i.pop();for(var a=0,u=i.length;u>a;++a)r=i[a],e=r.indexOf(":"),n=r.slice(0,e).toLowerCase(),o=m(r.slice(e+1)),s[n]=o;return s}function p(t){return t.split(/ *; */).shift()}function h(t){return y(t.split(/ *; */),function(t,e){var r=e.split(/ *= */),n=r.shift(),o=r.shift();return n&&o&&(t[n]=o),t},{})}function c(t,e){e=e||{},this.req=t,this.xhr=this.req.xhr,this.text="HEAD"!=this.req.method&&(""===this.xhr.responseType||"text"===this.xhr.responseType)||"undefined"==typeof this.xhr.responseType?this.xhr.responseText:null,this.statusText=this.req.xhr.statusText,this.setStatusProperties(this.xhr.status),this.header=this.headers=u(this.xhr.getAllResponseHeaders()),this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this.setHeaderProperties(this.header),this.body="HEAD"!=this.req.method?this.parseBody(this.text?this.text:this.xhr.response):null}function l(t,e){var r=this;d.call(this),this._query=this._query||[],this.method=t,this.url=e,this.header={},this._header={},this.on("end",function(){var t=null,e=null;try{e=new c(r)}catch(n){return t=new Error("Parser is unable to parse the response"),t.parse=!0,t.original=n,r.callback(t)}if(r.emit("response",e),t)return r.callback(t,e);if(e.status>=200&&e.status<300)return r.callback(t,e);var o=new Error(e.statusText||"Unsuccessful HTTP response");o.original=t,o.response=e,o.status=e.status,r.callback(t||o,e)})}function f(t,e){return"function"==typeof e?new l("GET",t).end(e):1==arguments.length?new l("GET",t):new l(t,e)}var d=r(2),y=r(3),_="undefined"==typeof window?this||self:window;f.getXHR=function(){if(!(!_.XMLHttpRequest||_.location&&"file:"==_.location.protocol&&_.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(t){}return!1};var m="".trim?function(t){return t.trim()}:function(t){return t.replace(/(^\s*|\s*$)/g,"")};f.serializeObject=s,f.parseString=a,f.types={html:"text/html",json:"application/json",xml:"application/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},f.serialize={"application/x-www-form-urlencoded":s,"application/json":JSON.stringify},f.parse={"application/x-www-form-urlencoded":a,"application/json":JSON.parse},c.prototype.get=function(t){return this.header[t.toLowerCase()]},c.prototype.setHeaderProperties=function(t){var e=this.header["content-type"]||"";this.type=p(e);var r=h(e);for(var n in r)this[n]=r[n]},c.prototype.parseBody=function(t){var e=f.parse[this.type];return e&&t&&(t.length||t instanceof Object)?e(t):null},c.prototype.setStatusProperties=function(t){1223===t&&(t=204);var e=t/100|0;this.status=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.clientError=4==e,this.serverError=5==e,this.error=4==e||5==e?this.toError():!1,this.accepted=202==t,this.noContent=204==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.notFound=404==t,this.forbidden=403==t},c.prototype.toError=function(){var t=this.req,e=t.method,r=t.url,n="cannot "+e+" "+r+" ("+this.status+")",o=new Error(n);return o.status=this.status,o.method=e,o.url=r,o},f.Response=c,d(l.prototype),l.prototype.use=function(t){return t(this),this},l.prototype.timeout=function(t){return this._timeout=t,this},l.prototype.clearTimeout=function(){return this._timeout=0,clearTimeout(this._timer),this},l.prototype.abort=function(){return this.aborted?void 0:(this.aborted=!0,this.xhr.abort(),this.clearTimeout(),this.emit("abort"),this)},l.prototype.set=function(t,e){if(i(t)){for(var r in t)this.set(r,t[r]);return this}return this._header[t.toLowerCase()]=e,this.header[t]=e,this},l.prototype.unset=function(t){return delete this._header[t.toLowerCase()],delete this.header[t],this},l.prototype.getHeader=function(t){return this._header[t.toLowerCase()]},l.prototype.type=function(t){return this.set("Content-Type",f.types[t]||t),this},l.prototype.accept=function(t){return this.set("Accept",f.types[t]||t),this},l.prototype.auth=function(t,e){var r=btoa(t+":"+e);return this.set("Authorization","Basic "+r),this},l.prototype.query=function(t){return"string"!=typeof t&&(t=s(t)),t&&this._query.push(t),this},l.prototype.field=function(t,e){return this._formData||(this._formData=new _.FormData),this._formData.append(t,e),this},l.prototype.attach=function(t,e,r){return this._formData||(this._formData=new _.FormData),this._formData.append(t,e,r),this},l.prototype.send=function(t){var e=i(t),r=this.getHeader("Content-Type");if(e&&i(this._data))for(var n in t)this._data[n]=t[n];else"string"==typeof t?(r||this.type("form"),r=this.getHeader("Content-Type"),"application/x-www-form-urlencoded"==r?this._data=this._data?this._data+"&"+t:t:this._data=(this._data||"")+t):this._data=t;return!e||o(t)?this:(r||this.type("json"),this)},l.prototype.callback=function(t,e){var r=this._callback;this.clearTimeout(),r(t,e)},l.prototype.crossDomainError=function(){var t=new Error("Origin is not allowed by Access-Control-Allow-Origin");t.crossDomain=!0,this.callback(t)},l.prototype.timeoutError=function(){var t=this._timeout,e=new Error("timeout of "+t+"ms exceeded");e.timeout=t,this.callback(e)},l.prototype.withCredentials=function(){return this._withCredentials=!0,this},l.prototype.end=function(t){var e=this,r=this.xhr=f.getXHR(),i=this._query.join("&"),s=this._timeout,a=this._formData||this._data;this._callback=t||n,r.onreadystatechange=function(){if(4==r.readyState){var t;try{t=r.status}catch(n){t=0}if(0==t){if(e.timedout)return e.timeoutError();if(e.aborted)return;return e.crossDomainError()}e.emit("end")}};var u=function(t){t.total>0&&(t.percent=t.loaded/t.total*100),e.emit("progress",t)};this.hasListeners("progress")&&(r.onprogress=u);try{r.upload&&this.hasListeners("progress")&&(r.upload.onprogress=u)}catch(p){}if(s&&!this._timer&&(this._timer=setTimeout(function(){e.timedout=!0,e.abort()},s)),i&&(i=f.serializeObject(i),this.url+=~this.url.indexOf("?")?"&"+i:"?"+i),r.open(this.method,this.url,!0),this._withCredentials&&(r.withCredentials=!0),"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof a&&!o(a)){var h=f.serialize[this.getHeader("Content-Type")];h&&(a=h(a))}for(var c in this.header)null!=this.header[c]&&r.setRequestHeader(c,this.header[c]);return this.emit("request",this),r.send(a),this},f.Request=l,f.get=function(t,e,r){var n=f("GET",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},f.head=function(t,e,r){var n=f("HEAD",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.del=function(t,e){var r=f("DELETE",t);return e&&r.end(e),r},f.patch=function(t,e,r){var n=f("PATCH",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.post=function(t,e,r){var n=f("POST",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.put=function(t,e,r){var n=f("PUT",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},t.exports=f},function(t,e,r){function n(t){return t?o(t):void 0}function o(t){for(var e in n.prototype)t[e]=n.prototype[e];return t}t.exports=n,n.prototype.on=n.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks[t]=this._callbacks[t]||[]).push(e),this},n.prototype.once=function(t,e){function r(){n.off(t,r),e.apply(this,arguments)}var n=this;return this._callbacks=this._callbacks||{},r.fn=e,this.on(t,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r=this._callbacks[t];if(!r)return this;if(1==arguments.length)return delete this._callbacks[t],this;for(var n,o=0;o<r.length;o++)if(n=r[o],n===e||n.fn===e){r.splice(o,1);break}return this},n.prototype.emit=function(t){this._callbacks=this._callbacks||{};var e=[].slice.call(arguments,1),r=this._callbacks[t];if(r){r=r.slice(0);for(var n=0,o=r.length;o>n;++n)r[n].apply(this,e)}return this},n.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks[t]||[]},n.prototype.hasListeners=function(t){return!!this.listeners(t).length}},function(t,e,r){t.exports=function(t,e,r){for(var n=0,o=t.length,i=3==arguments.length?r:t[n++];o>n;)i=e.call(null,i,t[n],++n,t);return i}}]); | ||
//# sourceMappingURL=clerk.min.js.map |
@@ -0,1 +1,8 @@ | ||
0.8.1 / 2015-04-27 | ||
================== | ||
* Catch emitted errors from superagent | ||
* Update dependencies | ||
0.8.0 / 2015-02-15 | ||
@@ -2,0 +9,0 @@ ================== |
{ | ||
"name": "clerk", | ||
"description": "CouchDB library for Node and the browser", | ||
"version": "0.8.0", | ||
"version": "0.8.1", | ||
"author": "Michael Phan-Ba <michael@mikepb.com>", | ||
@@ -17,4 +17,4 @@ "homepage": "https://github.com/mikepb/clerk", | ||
"dependencies": { | ||
"follow": "^0.10.4", | ||
"superagent": "^0.21.0" | ||
"follow": "^0.11.4", | ||
"superagent": "^1.2.0" | ||
}, | ||
@@ -21,0 +21,0 @@ "devDependencies": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
423980
4400
+ Addedajv@6.12.6(transitive)
+ Addedasn1@0.2.6(transitive)
+ Addedassert-plus@1.0.0(transitive)
+ Addedasync@1.5.2(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedaws-sign2@0.7.0(transitive)
+ Addedaws4@1.13.2(transitive)
+ Addedbcrypt-pbkdf@1.0.2(transitive)
+ Addedcaseless@0.12.0(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addedcomponent-emitter@1.2.1(transitive)
+ Addedcookiejar@2.0.6(transitive)
+ Addedcore-util-is@1.0.2(transitive)
+ Addeddashdash@1.14.1(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedecc-jsbn@0.1.2(transitive)
+ Addedextend@3.0.03.0.2(transitive)
+ Addedextsprintf@1.3.0(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedfollow@0.11.4(transitive)
+ Addedforever-agent@0.6.1(transitive)
+ Addedform-data@1.0.0-rc32.3.3(transitive)
+ Addedformidable@1.0.17(transitive)
+ Addedgetpass@0.1.7(transitive)
+ Addedhar-schema@2.0.0(transitive)
+ Addedhar-validator@5.1.5(transitive)
+ Addedhttp-signature@1.2.0(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedisstream@0.1.2(transitive)
+ Addedjsbn@0.1.1(transitive)
+ Addedjson-schema@0.4.0(transitive)
+ Addedjson-schema-traverse@0.4.1(transitive)
+ Addedjsprim@1.4.2(transitive)
+ Addedmethods@1.1.2(transitive)
+ Addedmime@1.3.4(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedoauth-sign@0.9.0(transitive)
+ Addedperformance-now@2.1.0(transitive)
+ Addedpsl@1.15.0(transitive)
+ Addedqs@2.3.36.5.3(transitive)
+ Addedrequest@2.88.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsshpk@1.18.0(transitive)
+ Addedsuperagent@1.8.5(transitive)
+ Addedtough-cookie@2.5.0(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
+ Addedtweetnacl@0.14.5(transitive)
+ Addeduri-js@4.4.1(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedverror@1.10.0(transitive)
- Removedasn1@0.1.11(transitive)
- Removedassert-plus@0.1.5(transitive)
- Removedasync@0.9.2(transitive)
- Removedaws-sign2@0.5.0(transitive)
- Removedboom@0.4.2(transitive)
- Removedcombined-stream@0.0.7(transitive)
- Removedcomponent-emitter@1.1.2(transitive)
- Removedcookiejar@2.0.1(transitive)
- Removedcryptiles@0.2.2(transitive)
- Removedctype@0.5.3(transitive)
- Removeddelayed-stream@0.0.5(transitive)
- Removedextend@1.2.1(transitive)
- Removedfollow@0.10.4(transitive)
- Removedforever-agent@0.5.2(transitive)
- Removedform-data@0.1.30.1.4(transitive)
- Removedformidable@1.0.14(transitive)
- Removedhawk@1.0.0(transitive)
- Removedhoek@0.9.1(transitive)
- Removedhttp-signature@0.10.1(transitive)
- Removedmethods@1.0.1(transitive)
- Removedmime@1.2.11(transitive)
- Removednode-uuid@1.4.8(transitive)
- Removedoauth-sign@0.3.0(transitive)
- Removedqs@0.6.61.2.0(transitive)
- Removedrequest@2.30.0(transitive)
- Removedsntp@0.2.4(transitive)
- Removedsuperagent@0.21.0(transitive)
- Removedtough-cookie@0.9.15(transitive)
- Removedtunnel-agent@0.3.0(transitive)
Updatedfollow@^0.11.4
Updatedsuperagent@^1.2.0