From 653bec43bd526e57940704cb3b52f5b37cf3c017 Mon Sep 17 00:00:00 2001 From: Michael Phan-Ba Date: Sun, 15 Feb 2015 18:15:46 -0800 Subject: [PATCH] v0.8.0 --- HISTORY.md | 7 +++++++ README.md | 5 ++--- clerk.js | 17 ++++++----------- dist/clerk.js | 26 +++++++++----------------- dist/clerk.js.map | 2 +- dist/clerk.min.js | 2 +- dist/clerk.min.js.map | 2 +- package.json | 2 +- 8 files changed, 28 insertions(+), 35 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 6f9208a..3b7a328 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,10 @@ +0.8.0 / 2015-02-15 +================== + + * Update Travis-CI to test against node 0.10-12 and iojs + * Change DB#update() to accept data before query + + 0.7.2 / 2015-02-11 ================== diff --git a/README.md b/README.md index 7abd8cd..5a59c89 100644 --- a/README.md +++ b/README.md @@ -87,9 +87,8 @@ $ npm run karma The philosophy of *clerk* is to provide a thin wrapper around the CouchDB API, making the database easier to use from JavaScript. *clerk* is designed to -quickly allow you to get started with CouchDB. As you get more comfortable -with *clerk* and CouchDB, *clerk* gives you full access to CouchDB's -more advanced features. +quickly allow you to get started with CouchDB, while still giving you full +access to CouchDB's more advanced features. The library API generally follows the RESTful API, so you can use the CouchDB docs as well as the *clerk* docs to build your applications. If a feature is diff --git a/clerk.js b/clerk.js index bfa1c18..a5c939b 100644 --- a/clerk.js +++ b/clerk.js @@ -19,12 +19,7 @@ limitations under the License. */ -/** @namespace clerk */ - -/* - * Module dependencies. - */ - +// Module dependencies. var request = require("superagent"); /** @@ -124,7 +119,7 @@ function clerk (uri) { * @type {String} */ -clerk.version = "0.7.2"; +clerk.version = "0.8.0"; /** * Default host. @@ -204,6 +199,7 @@ clerk._parseURI = function (uri) { * Encapsulates HTTP methods, JSON handling, and response coersion. * * @constructor + * @memberof clerk */ function Base () {}; @@ -516,6 +512,7 @@ Base.prototype._ = function (args, start, withDoc) { * @param {String} uri Fully qualified URI. * @param {String} [auth] Authentication header value. * @constructor + * @memberof clerk * @see {@link http://wiki.apache.org/couchdb/Complete_HTTP_API_Reference|CouchDB Wiki} */ @@ -690,6 +687,7 @@ Client.prototype.replicate = function (options /* [query], [headers], [callback] * @param {String} name DB name. * @param {String} [auth] Authentication header value. * @constructor + * @memberof clerk * @return This object for chaining. */ @@ -1304,8 +1302,5 @@ clerk.Base = Base; clerk.Client = Client; clerk.DB = DB; -/** - * Export clerk. - */ - +// Export clerk. module.exports = clerk; diff --git a/dist/clerk.js b/dist/clerk.js index 29da092..914f220 100644 --- a/dist/clerk.js +++ b/dist/clerk.js @@ -66,12 +66,7 @@ limitations under the License. */ -/** @namespace clerk */ - -/* - * Module dependencies. - */ - +// Module dependencies. var request = __webpack_require__(1); /** @@ -171,7 +166,7 @@ function clerk (uri) { * @type {String} */ -clerk.version = "0.7.2"; +clerk.version = "0.8.0"; /** * Default host. @@ -251,6 +246,7 @@ clerk._parseURI = function (uri) { * Encapsulates HTTP methods, JSON handling, and response coersion. * * @constructor + * @memberof clerk */ function Base () {}; @@ -420,7 +416,7 @@ Base.prototype._do = function (options) { var data; if (!err) { - if (!(data = res.body || res.text)) {} + if (!(data = res.body)) { data = res.text; } else if (data.error) err = self._error(data); else data = self._response(data); } @@ -563,6 +559,7 @@ Base.prototype._ = function (args, start, withDoc) { * @param {String} uri Fully qualified URI. * @param {String} [auth] Authentication header value. * @constructor + * @memberof clerk * @see {@link http://wiki.apache.org/couchdb/Complete_HTTP_API_Reference|CouchDB Wiki} */ @@ -737,6 +734,7 @@ Client.prototype.replicate = function (options /* [query], [headers], [callback] * @param {String} name DB name. * @param {String} [auth] Authentication header value. * @constructor + * @memberof clerk * @return This object for chaining. */ @@ -1168,7 +1166,7 @@ DB.prototype._changes = function (request) { * @see {@link http://wiki.apache.org/couchdb/Document_Update_Handlers|CouchDB Wiki} */ -DB.prototype.update = function (handler /* [id], [query], [data], [headers], [callback] */) { +DB.prototype.update = function (handler /* [id], [data], [query], [headers], [callback] */) { var request = this._(arguments, 1, 1); var path = handler.split("/", 2); @@ -1177,10 +1175,7 @@ DB.prototype.update = function (handler /* [id], [query], [data], [headers], [ca if (request.p) path += "/" + request.p; - return request(request.p ? "PUT" : "POST", path, { - q: request.b, - b: request.q - }); + return request("POST", path); }; /** @@ -1354,10 +1349,7 @@ clerk.Base = Base; clerk.Client = Client; clerk.DB = DB; -/** - * Export clerk. - */ - +// Export clerk. module.exports = clerk; diff --git a/dist/clerk.js.map b/dist/clerk.js.map index 011b0d7..75be115 100644 --- a/dist/clerk.js.map +++ b/dist/clerk.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap 34865662eca32f659b62","webpack:///./clerk.js","webpack:///./~/superagent/lib/client.js","webpack:///./~/superagent/~/component-emitter/index.js","webpack:///./~/superagent/~/reduce-component/index.js"],"names":[],"mappings":";;AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,wC;;;;;;;ACtCA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,UAAU;AACrB,YAAY,OAAO;AACnB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,OAAO;AACnB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,UAAU;AACtB;AACA,SAAS;AACT,SAAS;AACT,SAAS;AACT;;AAEA;AACA;AACA;;AAEA;AACA;AACA,UAAU;AACV;;AAEA;;AAEA;AACA;AACA,UAAU;AACV;;AAEA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,UAAU;AACtB;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;;AAEA;AACA;AACA,CAAC;AACD;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,OAAO;AACnB;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,QAAQ;AACnB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB,WAAW,QAAQ;AACnB;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,wBAAwB,gBAAgB;AACxC,yBAAyB,iBAAiB;AAC1C,0BAA0B,aAAa;AACvC,aAAa;AACb;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB,WAAW,QAAQ;AACnB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,2BAA2B,SAAS;AACpC;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,YAAY,OAAO;AACnB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,OAAO;AACnB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB;AACA,YAAY,QAAQ;AACpB;AACA;AACA;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AAQ;AACnB,YAAY,QAAQ;AACpB;AACA,SAAS;AACT;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,QAAQ;AACnB,YAAY,QAAQ;AACpB;AACA,SAAS;AACT;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,gBAAgB;AAC3B,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB;AACA,aAAa,OAAO;AACpB;AACA,eAAe,OAAO;AACtB;AACA,eAAe,OAAO;AACtB;AACA,eAAe,cAAc;AAC7B;AACA,WAAW,OAAO;AAClB,aAAa,QAAQ;AACrB;AACA;AACA,aAAa,QAAQ;AACrB;AACA,WAAW,OAAO;AAClB,WAAW,QAAQ;AACnB,YAAY,QAAQ;AACpB;AACA,SAAS;AACT,SAAS;AACT;;AAEA;AACA;AACA;AACA;AACA,wBAAwB,aAAa;AACrC;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,QAAQ;AACnB,YAAY,QAAQ;AACpB;AACA,SAAS;AACT;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,gBAAgB;AAC3B,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,QAAQ;AACnB,YAAY,QAAQ;AACpB;AACA,SAAS;AACT,SAAS;AACT;;AAEA;AACA;AACA;AACA,UAAU,SAAS;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB;AACA,aAAa,OAA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;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,QAAQ;AACnB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,QAAQ;AACnB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA,iDAAiD,UAAU;AAC3D;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,QAAQ;AACnB,YAAY,QAAQ;AACpB;AACA,SAAS;AACT;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,QAAQ;AACnB,YAAY,QAAQ;AACpB;AACA,SAAS;AACT;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,QAAQ;AACnB,YAAY,OAAO;AACnB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,WAAW;AACtB,WAAW,OAAO;AAClB,WAAW,QAAQ;AACnB,WAAW,OAAO;AAClB,WAAW,oBAAoB;AAC/B;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;;;;;;ACjyCA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;;AAEA;AACA,cAAc;;AAEd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH,SAAS,+CAA+C,EAAE;AAC1D,SAAS,gDAAgD,EAAE;AAC3D,SAAS,gDAAgD,EAAE;AAC3D,SAAS,4CAA4C,EAAE;AACvD;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;;AAEA;AACA,iBAAiB,iBAAiB;AAClC,iBAAiB,sCAAsC;;AAEvD;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,YAAY,OAAO;AACnB,aAAa;AACb;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,qCAAqC,SAAS;AAC9C;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,cAAc;;AAEd,qCAAqC,SAAS;AAC9C;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;;AAEA;AACA,uBAAuB;AACvB;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;;AAEA;AACA,8BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA,GAAG,IAAI;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4CAA4C;AAC5C,wCAAwC;AACxC;AACA;AACA;AACA;AACA;AACA,iBAAiB,aAAa;AAC9B,8BAA8B;AAC9B;AACA;AACA;AACA;AACA;AACA,iBAAiB,aAAa,iBAAiB;AAC/C;AACA;AACA;AACA;AACA,0BAA0B,aAAa;AACvC,8BAA8B;AAC9B;AACA;AACA;AACA;AACA,0BAA0B,aAAa,iBAAiB;AACxD;AACA,WAAW,eAAe;AAC1B,WAAW,OAAO;AAClB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,2CAA2C;AAC3C;AACA;AACA,WAAW,OAAO;AAClB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,+B;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA,GAAG;AACH;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,oDAAoD;AACpE;AACA;AACA,WAAW,cAAc;AACzB,WAAW,OAAO;AAClB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc,gBAAgB;AAC9B;AACA,UAAU,cAAc;AACxB,WAAW,QAAQ;AACnB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,iBAAiB;AAC5B,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,6DAA6D,mBAAmB;AAChF;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,UAAU;AACrB,WAAW,OAAO;AAClB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,kBAAkB;AACpC,kBAAkB,gBAAgB;AAClC,kBAAkB,gBAAgB;AAClC;AACA;AACA;AACA;AACA;AACA,mBAAmB,YAAY;AAC/B;AACA;AACA;AACA;AACA,kBAAkB,aAAa;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,aAAa;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,cAAc;AACzB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,SAAS;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,SAAS;AACpB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,gBAAgB;AAC3B,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,eAAe;AAC1B,WAAW,SAAS;AACpB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,eAAe;AAC1B,WAAW,SAAS;AACpB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,SAAS;AACpB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,MAAM;AACjB,WAAW,SAAS;AACpB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,MAAM;AACjB,WAAW,SAAS;AACpB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,eAAe;AAC1B,WAAW,SAAS;AACpB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;;;;;;;ACvjCA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,SAAS;AACpB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,SAAS;AACpB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,SAAS;AACpB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,sBAAsB;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,MAAM;AACjB,YAAY;AACZ;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,2CAA2C,SAAS;AACpD;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;;;;;;;;AClKA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,SAAS;AACpB,WAAW,MAAM;AACjB;AACA;AACA;;AAEA,4C;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,E","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 34865662eca32f659b62\n **/","\"use strict\";\n\n/*!\n\nclerk - CouchDB client for node and the browser.\nCopyright 2012-2015 Michael Phan-Ba\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n*/\n\n/** @namespace clerk */\n\n/*\n * Module dependencies.\n */\n\nvar request = require(\"superagent\");\n\n/**\n * Copy properties from sources to target.\n *\n * @param {Object} target The target object.\n * @param {...Object} sources The source object.\n * @return {Object} The target object.\n * @private\n */\n\nvar extend = function (target /* ...sources */) {\n var source, key, i = 1;\n while (source = arguments[i++]) {\n for (key in source) target[key] = source[key];\n }\n return target;\n};\n\n/**\n * Stringify value.\n *\n * @param {Object} that That value to stringify.\n * @return {String} The stringifyed value.\n * @private\n */\n\nvar asString = function (that) {\n return Object.prototype.toString.call(that);\n};\n\n/**\n * Check if value is a string.\n *\n * @param {Object} that That value to check.\n * @return {Boolean} `true` if string, `false` otherwise.\n * @private\n */\n\nvar isString = function (that) {\n return asString(that) == \"[object String]\";\n};\n\n/**\n * Check if value is an object.\n *\n * @param {Object} that That value to check.\n * @return {Boolean} `true` if object, `false` otherwise.\n * @private\n */\n\nvar isObject = function (that) {\n return asString(that) == \"[object Object]\";\n};\n\n/**\n * Check if value is an array.\n *\n * @param {Object} that That value to check.\n * @return {Boolean} `true` if array, `false` otherwise.\n * @private\n */\n\nvar isArray = function (that) {\n return asString(that) == \"[object Array]\";\n};\n\n/**\n * Check if value is a function.\n *\n * @param {Object} that That value to check.\n * @return {Boolean} `true` if function, `false` otherwise.\n * @private\n */\n\nvar isFunction = function (that) {\n return asString(that) == \"[object Function]\";\n};\n\n/**\n * Clerk library entry point.\n *\n * @param {String} uri CouchDB server URI.\n * @return {Client|DB} If a URI path is given, returns a `DB`, otherwise\n * returns a `Client`.\n * @see {@link http://docs.couchdb.org|CouchDB Documentation}\n * @see {@link http://guide.couchdb.org/|CouchDB Guide}\n * @see {@link http://wiki.apache.org/couchdb/|CouchDB Wiki}\n */\n\nfunction clerk (uri) {\n return clerk.make(uri);\n};\n\n/**\n * Library version.\n * @type {String}\n */\n\nclerk.version = \"0.7.2\";\n\n/**\n * Default host.\n * @type {String}\n */\n\nclerk.defaultHost = \"http://127.0.0.1:5984\";\n\n/**\n * Create single CouchDB client.\n *\n * @param {String} uri Fully qualified URI.\n * @return {Client|DB} If `uri` has a path, the last segment of the\n * path is used as the database name and a `DB` instance is\n * returned. Otherwise, a `Client` instance is returned.\n */\n\nclerk.make = function (uri) {\n if (!uri) return new Client(this.defaultHost);\n\n uri = clerk._parseURI(uri);\n\n var db = /\\/*([^\\/]+)\\/*$/.exec(uri.path);\n if (db) {\n uri.path = uri.path.substr(0, db.index);\n db = db[1] && decodeURIComponent(db[1]);\n }\n\n // weird way of doing it, but it's more efficient...\n if (uri.auth) uri.auth = 'Basic ' + clerk.btoa(uri.auth);\n\n var client = new clerk.Client(uri.base + uri.path, uri.auth);\n return db ? client.db(db) : client;\n};\n\n/**\n * Base64-encode a string.\n *\n * @param {String} str\n * @return {String}\n */\n\nclerk.btoa = typeof Buffer != \"undefined\" ? function (str) {\n return new Buffer(str).toString(\"base64\");\n} : function (str) {\n return btoa(str);\n};\n\n/**\n * Parse URI.\n *\n * The URI is normalized by removing extra `//` in the path.\n *\n * @param {String} uri Fully qualified URI.\n * @return {String} The normalized URI.\n * @private\n */\n\nclerk._parseURI = function (uri) {\n var match;\n\n if (uri) {\n if (match = /^(https?:\\/\\/)(?:([^\\/@]+)@)?([^\\/]+)(.*)\\/*$/.exec(uri)) {\n return {\n base: match[1] + match[3].replace(/\\/+/g, \"\\/\"),\n path: match[4],\n auth: match[2] && decodeURIComponent(match[2])\n };\n }\n }\n\n return { base: uri || \"\", path: \"\" };\n};\n\n/**\n * Base prototype for `Client` and `DB`.\n * Encapsulates HTTP methods, JSON handling, and response coersion.\n *\n * @constructor\n */\n\nfunction Base () {};\n\n/**\n * Service request and parse JSON response.\n *\n * @param {String} [method=GET] HTTP method.\n * @param {String} [path=this.uri] HTTP URI.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [body] HTTP body.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nBase.prototype.request = function (/* [method], [path], [query], [body], [headers], [callback] */) {\n var args = [].slice.call(arguments);\n var callback = isFunction (args[args.length - 1]) && args.pop();\n\n return this._request({\n method: args[0],\n path: args[1],\n query: args[2],\n data: args[3],\n headers: args[4],\n fn: callback\n });\n};\n\n/**\n * Internal service request and parse JSON response handler.\n *\n * @param {String} options\n * @param {String} method HTTP method.\n * @param {String} path HTTP URI.\n * @param {Object} query HTTP query options.\n * @param {Object} data HTTP body data.\n * @param {Object} headers HTTP headers.\n * @param {handler} [callback] Callback function.\n * @private\n */\n\nBase.prototype._request = function (options) {\n var self = this;\n\n if (options.method == null) options.method = \"GET\";\n if (options.headers == null) options.headers = {};\n if (options.auth == null) options.auth = this.auth;\n\n options.path = options.path ? \"/\" + options.path : \"\";\n\n // set default headers\n if (options.headers[\"Content-Type\"] == null) {\n options.headers[\"Content-Type\"] = \"application/json\";\n }\n if (options.headers[\"Accept\"] == null) {\n options.headers[\"Accept\"] = \"application/json\";\n }\n if (this.auth && options.headers[\"Authorization\"] == null) {\n options.headers[\"Authorization\"] = this.auth;\n }\n\n options.uri = this.uri + options.path;\n options.body = options.data && JSON.stringify(options.data,\n /^\\/_design/.test(options.path) && this._replacer\n ) || \"\";\n\n // create promise if no callback given\n var promise, req;\n if (!options.fn && typeof Promise != \"undefined\") {\n promise = new Promise(function (resolve, reject) {\n options.fn = function (err, data, status, headers, res) {\n if (err) {\n err.body = data;\n err.status = status;\n err.headers = headers;\n err.res = res;\n reject(err);\n } else {\n if (Object.defineProperties) {\n Object.defineProperties(data, {\n _status: { value: status },\n _headers: { value: headers },\n _response: { value: res },\n });\n }\n resolve(data);\n };\n };\n });\n req = send();\n promise.request = req;\n promise.abort = function () {\n req.abort();\n options.fn(new Error(\"abort\"));\n return promise;\n };\n return promise;\n }\n\n send();\n\n function send () {\n // apply response transforms\n var g = options._;\n var fn = options.fn;\n if (fn) {\n options.fn = g ? function () {\n fn.apply(self, g.apply(self, arguments) || arguments);\n } : fn;\n }\n return self._do(options);\n }\n};\n\n/**\n * Provider for servicing requests and parsing JSON responses.\n *\n * @param {String} options\n * @param {String} method HTTP method.\n * @param {String} uri HTTP URI.\n * @param {Object} query HTTP query options.\n * @param {Object} body HTTP body.\n * @param {Object} headers HTTP headers.\n * @param {Object} auth HTTP authentication.\n * @param {handler} [callback] Callback function.\n * @private\n */\n\nBase.prototype._do = function (options) {\n var self = this;\n var key, value;\n\n // create request\n var req = request(options.method, options.uri);\n\n // query string\n if (options.query) {\n // ensure query Array values are JSON encoded\n for (key in options.query) {\n if (typeof(value = options.query[key]) === \"object\") {\n options.query[key] = JSON.stringify(value);\n }\n }\n // set query on request\n req.query(options.query);\n }\n\n // set headers\n if (options.headers) {\n req.set(options.headers);\n // if authenticating\n if (req.withCredentials && options.headers[\"Authorization\"] != null) {\n req.withCredentials();\n }\n }\n\n // send body\n if (options.body) req.send(options.body);\n\n // send request\n var fn = options.fn;\n req.end(function (res) {\n var err = res.error;\n var data;\n\n if (!err) {\n if (!(data = res.body || res.text)) {}\n else if (data.error) err = self._error(data);\n else data = self._response(data);\n }\n\n res.data = data;\n\n fn && fn(err || null, data, res.status, res.header, res);\n });\n\n return req;\n};\n\n/**\n * Coerce response to normalize access to `_id` and `_rev`.\n *\n * @param {Object} json The response JSON.\n * @return The coerced JSON.\n * @private\n */\n\nBase.prototype._response = function (json) {\n var data = json.rows || json.results || json.uuids || isArray(json) && json;\n var meta = this._meta;\n var i = 0, len, item;\n\n if (data) {\n extend(data, json).json = json;\n for (len = data.length; i < len; i++) {\n item = data[i] = meta(data[i]);\n if (item.doc) item.doc = meta(item.doc);\n }\n } else {\n data = meta(json);\n }\n\n return data;\n};\n\n/**\n * Make an error out of the response.\n *\n * @param {Object} json The response JSON.\n * @return An `Error` object.\n * @private\n */\n\nBase.prototype._error = function (json) {\n var err = new Error(json.reason);\n err.code = json.error;\n return extend(err, json);\n};\n\n/**\n * JSON stringify functions. Used for encoding view documents to JSON.\n *\n * @param {String} key The key to stringify.\n * @param {Object} val The value to stringify.\n * @return {Object} The stringified function value or the value.\n * @private\n */\n\nBase.prototype._replacer = function (key, val) {\n return isFunction (val) ? val.toString() : val;\n};\n\n/**\n * Coerce documents with prototypical `_id` and `_rev`\n * values.\n *\n * @param {Object} doc The document to coerce.\n * @return {Object} The coerced document.\n * @private\n */\n\nBase.prototype._meta = function (doc) {\n var hasId = !doc._id && doc.id;\n var hasRev = !doc._rev && doc.rev;\n var proto;\n\n if (hasId || hasRev) {\n proto = function (){};\n doc = extend(new proto(), doc);\n proto = proto.prototype;\n if (hasId) proto._id = doc.id;\n if (hasRev) proto._rev = doc.rev;\n }\n\n return doc;\n};\n\n/**\n * Parse arguments.\n *\n * @param {Array} args The arguments.\n * @param {Integer} start The index from which to start reading arguments.\n * @param {Boolean} withDoc Set to `true` if the doc source is given as a\n * parameter before HTTP query options.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @private\n */\n\nBase.prototype._ = function (args, start, withDoc) {\n var self = this, doc, id, rev;\n\n function request(method, path, options) {\n if (!options) options = {};\n return self._request({\n method: method,\n path: path || request.p,\n query: options.q || request.q,\n data: options.b || request.b,\n headers: options.h || request.h,\n fn: options.f || request.f,\n _: options._ || request._\n });\n }\n\n // [id], [doc], [query], [header], [callback]\n args = [].slice.call(args, start || 0);\n\n request.f = isFunction(args[args.length - 1]) && args.pop();\n request.p = isString(args[0]) && encodeURI(args.shift());\n request.q = args[withDoc ? 1 : 0] || {};\n request.h = args[withDoc ? 2 : 1] || {};\n\n if (withDoc) {\n if (doc = (request.b = args[0])) {\n if (id = request.p || doc._id || doc.id) request.p = id;\n if (rev = request.q.rev || doc._rev || doc.rev) request.q.rev = rev;\n }\n }\n\n return request;\n};\n\n/**\n * Clerk CouchDB client.\n *\n * @param {String} uri Fully qualified URI.\n * @param {String} [auth] Authentication header value.\n * @constructor\n * @see {@link http://wiki.apache.org/couchdb/Complete_HTTP_API_Reference|CouchDB Wiki}\n */\n\nfunction Client (uri, auth) {\n this.uri = uri;\n this._db = {};\n this.auth = auth;\n};\n\nClient.prototype = new Base();\n\n/**\n * Select database to manipulate.\n *\n * @param {String} name DB name.\n * @return {DB} DB object.\n */\n\nClient.prototype.db = function (name) {\n var db = this._db;\n return db[name] || (db[name] = new DB(this, name, this.auth));\n};\n\n/**\n * List all databases.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetAllDbs|CouchDB Wiki}\n */\n\nClient.prototype.dbs = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\", \"_all_dbs\");\n};\n\n/**\n * Get UUIDs.\n *\n * @param {Integer} [count=1] Number of UUIDs to get.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetUuids|CouchDB Wiki}\n */\n\nClient.prototype.uuids = function (count /* [query], [headers], [callback] */) {\n var request = this._(arguments, +count == count ? 1 : 0);\n if (count > 1) request.q.count = count;\n return request(\"GET\", \"_uuids\");\n};\n\n/**\n * Get server information.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetRoot|CouchDB Wiki}\n */\n\nClient.prototype.info = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\");\n};\n\n/**\n * Get server stats.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetLog|CouchDB Wiki}\n */\n\nClient.prototype.stats = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\", \"_stats\");\n};\n\n/**\n * Get tail of the server log file.\n *\n * @param {Object} [query] Query parameters.\n * @param {Integer} [query.bytes] Number of bytes to read.\n * @param {Integer} [query.offset] Number of bytes from the end of\n * log file to start reading.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetLog|CouchDB Wiki}\n */\n\nClient.prototype.log = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\", \"_log\");\n};\n\n/**\n * List running tasks.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetActiveTasks|CouchDB Wiki}\n */\n\nClient.prototype.tasks = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\", \"_active_tasks\");\n};\n\n/**\n * Get or set configuration values.\n *\n * @param {String} [key] Configuration section or key.\n * @param {String} [value] Configuration value.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nClient.prototype.config = function (/* [key], [value], [query], [headers], [callback] */) {\n var args = [].slice.call(arguments);\n var key = isString(args[0]) && args.shift() || \"\";\n var value = isString(args[0]) && args.shift();\n var method = isString(value) ? \"PUT\" : \"GET\";\n return this._(args)(method, \"_config/\" + key, { b: value });\n};\n\n/**\n * Replicate databases.\n *\n * @param {Object} options Options.\n * @param {String} options.source Source database URL or local name.\n * @param {String} options.target Target database URL or local name.\n * @param {Boolean} [options.cancel] Set to `true` to cancel replication.\n * @param {Boolean} [options.continuous] Set to `true` for continuous\n * replication.\n * @param {Boolean} [options.create_target] Set to `true` to create the\n * target database.\n * @param {String} [options.filter] Filter name for filtered replication.\n * Example: \"mydesign/myfilter\".\n * @param {Object} [options.query] Query parameters for filter.\n * @param {String[]} [options.doc_ids] Document IDs to replicate.\n * @param {String} [options.proxy] Proxy through which to replicate.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/Replication|CouchDB Wiki}\n */\n\nClient.prototype.replicate = function (options /* [query], [headers], [callback] */) {\n return this._(arguments, 1)(\"POST\", \"_replicate\", { b: options });\n};\n\n/**\n * Methods for CouchDB database.\n *\n * @param {Client} client Clerk client.\n * @param {String} name DB name.\n * @param {String} [auth] Authentication header value.\n * @constructor\n * @return This object for chaining.\n */\n\nfunction DB (client, name, auth) {\n this.client = client;\n this.name = name;\n this.uri = client.uri + \"/\" + encodeURIComponent(name);\n this.auth = auth;\n};\n\nDB.prototype = new Base();\n\n/**\n * Create database.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.create = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"PUT\");\n};\n\n/**\n * Destroy database.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.destroy = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"DELETE\");\n};\n\n/**\n * Get database info.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.info = function (/* [query], [headers], callback */) {\n return this._(arguments)(\"GET\");\n};\n\n/**\n * Check if database exists.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.exists = function (/* [query], [headers], callback */) {\n var request = this._(arguments);\n request._ = function (err, body, status, headers, req) {\n return [err, status === 200, status, headers, req];\n };\n return request(\"HEAD\");\n};\n\n/**\n * Fetch document.\n *\n * Set `rev` in `query`.\n *\n * @param {String} id Document ID.\n * @param {Object} [query] HTTP query options.\n * @param {Boolean} [query.revs] Fetch list of revisions.\n * @param {Boolean} [query.revs_info] Fetch detailed revision information.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#GET|CouchDB Wiki}\n */\n\nDB.prototype.get = function (/* [id], [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\");\n};\n\n/**\n * Get document metadata.\n *\n * @param {String} id Document ID.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#HEAD|CouchDB Wiki}\n */\n\nDB.prototype.head = function (/* [id], [query], [headers], callback */) {\n var self = this;\n var request = self._(arguments);\n request._ = function (err, body, status, headers, res) {\n return [err, err ? null : {\n _id: request.p,\n _rev: headers.etag && JSON.parse(headers.etag),\n contentType: headers[\"content-type\"],\n contentLength: headers[\"content-length\"]\n }, status, headers, res];\n };\n return request(\"HEAD\");\n};\n\n/**\n * Post document(s) to database.\n *\n * If documents have no ID, a document ID will be automatically generated\n * on the server. Attachments are not currently supported.\n *\n * @param {Object|Object[]} doc Document or array of documents.\n * @param {String} [doc._id] Document ID. If set, uses given document ID.\n * @param {String} [doc._rev] Document revision. If set, allows update to\n * existing document.\n * @param {Object} [doc._attachments] Attachments. If given, must be a\n * map of filenames to attachment properties.\n * @param {String} [doc._attachments[filename]] Attachment filename, as\n * hash key.\n * @param {String} [doc._attachments[filename].contentType] Attachment\n * MIME content type.\n * @param {String|Object} [doc._attachments[filename].data] Attachment\n * data. Will be Base64 encoded.\n * @param {Object} [query] HTTP query options.\n * @param {Boolean} [query.batch] Allow server to write document in\n * batch mode. Documents will not be written to disk immediately,\n * increasing the chances of write failure.\n * @param {Boolean} [query.all_or_nothing] For batch updating of\n * documents, use all-or-nothing semantics.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#POST|CouchDB Wiki}\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API|CouchDB Wiki}\n */\n\nDB.prototype.post = function (docs /* [query], [headers], [callback] */) {\n var request = this._(arguments, 1);\n if (isArray(docs)) {\n request.p = \"_bulk_docs\";\n request.b = extend({ docs: docs }, request.q);\n request.q = null\n } else {\n request.b = docs;\n }\n return request(\"POST\");\n};\n\n/**\n * Put document in database.\n *\n * @param {Object} doc Document data. Requires `_id` and `_rev`.\n * @param {String} [options] Options.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#PUT|CouchDB Wiki}\n */\n\nDB.prototype.put = function (/* [id], [doc], [query], [headers], [callback] */) {\n var request = this._(arguments, 0, 1);\n // prevent acidentally creating database\n if (!request.p) request.p = request.b._id || request.b.id;\n if (!request.p) throw new Error(\"missing id\");\n return request(\"PUT\");\n};\n\n/**\n * Delete document(s).\n *\n * @param {Object|Object[]} docs Document or array of documents.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#DELETE|CouchDB Wiki}\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API|CouchDB Wiki}\n */\n\nDB.prototype.del = function (docs /* [query], [headers], [callback] */) {\n if (isArray(docs)) {\n var i = 0, len = docs.length, doc;\n for (; i < len; i++) {\n doc = docs[i], docs[i] = {\n _id: doc._id || doc.id,\n _rev: doc._rev || doc.rev,\n _deleted: true\n };\n }\n return this.post.apply(this, arguments);\n } else {\n var request = this._(arguments, 0, 1);\n // prevent acidentally deleting database\n if (!request.p) throw new Error(\"missing id\");\n return request(\"DELETE\");\n }\n};\n\n/**\n * Copy document.\n *\n * @param {Object} source Source document.\n * @param {String} source.id Source document ID.\n * @param {String} [source.rev] Source document revision.\n * @param {String} [source._id] Source document ID. Alternate key for\n * `source.id`.\n * @param {String} [source._rev] Source document revision. Alternate key\n * for `source.id`.\n * @param {Object} target Target document.\n * @param {String} target.id Target document ID.\n * @param {String} [target.rev] Target document revision.\n * @param {String} [target._id] Target document ID. Alternate key for\n * `target.id`.\n * @param {String} [target._rev] Target document revision. Alternate key\n * for `target.id`.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#COPY|CouchDB Wiki}\n */\n\nDB.prototype.copy = function (source, target /* [query], [headers], [callback] */) {\n var request = this._(arguments, 2);\n var sourcePath = encodeURIComponent(source.id || source._id || source);\n var targetPath = encodeURIComponent(target.id || target._id || target);\n var sourceRev = source.rev || source._rev;\n var targetRev = target.rev || target._rev;\n\n if (sourceRev) request.q.rev = sourceRev;\n if (targetRev) targetPath += \"?rev=\" + encodeURIComponent(targetRev);\n\n request.h.Destination = targetPath;\n\n return request(\"COPY\", sourcePath);\n};\n\n/**\n * Query all documents by ID.\n *\n * @param {Object} [query] HTTP query options.\n * @param {JSON} [query.startkey] Start returning results from this\n * document ID.\n * @param {JSON} [query.endkey] Stop returning results at this document\n * ID.\n * @param {Integer} [query.limit] Limit number of results returned.\n * @param {Boolean} [query.descending=false] Lookup results in reverse\n * order by key, returning documents in descending order by key.\n * @param {Integer} [query.skip] Skip this many records before\n * returning results.\n * @param {Boolean} [query.include_docs=false] Include document source for\n * each result.\n * @param {Boolean} [query.include_end=true] Include `query.endkey`\n * in results.\n * @param {Boolean} [query.update_seq=false] Include sequence value\n * of the database corresponding to the view.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API|CouchDB Wiki}\n */\n\nDB.prototype.all = function (/* [query], [headers], [callback] */) {\n var request = this._(arguments);\n var body = this._viewOptions(request.q);\n return request(body ? \"POST\" : \"GET\", \"_all_docs\", { b: body });\n};\n\n/**\n * Query a view.\n *\n * @param {String|Object} view View name (e.g. mydesign/myview) or\n * temporary view definition. Using a temporary view is strongly not\n * recommended for production use.\n * @param {Object} [query] HTTP query options.\n * @param {JSON} [query.key] Key to lookup.\n * @param {JSON} [query.startkey] Start returning results from this key.\n * @param {String} [query.startkey_docid] Start returning results\n * from this document ID. Allows pagination with duplicate keys.\n * @param {JSON} [query.endkey] Stop returning results at this key.\n * @param {String} [query.endkey_docid] Stop returning results at\n * this document ID. Allows pagination with duplicate keys.\n * @param {Integer} [query.limit] Limit number of results returned.\n * @param {Boolean|String} [query.stale] Do not refresh view even if\n * stale. For CouchDB versions `1.1.0` and up, set to `update_after` to\n * update view after results are returned.\n * @param {Boolean} [query.descending=false] Lookup results in reverse\n * order by key, returning documents in descending order by key.\n * @param {Integer} [query.skip] Skip this many records before\n * returning results.\n * @param {Boolean|Integer} [query.group=false] Use the reduce function\n * to group results by key. Set to an integer specify `group_level`.\n * @param {Boolean|Integer} [query.reduce=true] Use the reduce function.\n * @param {Boolean} [query.fetch=false] Include document source for\n * each result.\n * @param {Boolean} [query.include_end=true] Include `query.endkey`\n * in results.\n * @param {Boolean} [query.update_seq=false] Include sequence value\n * of the database corresponding to the view.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_view_API|CouchDB Wiki}\n */\n\nDB.prototype.find = function (view /* [query], [headers], [callback] */) {\n var request = this._(arguments, 1), path, body;\n\n if (isString(view)) {\n path = view.split(\"/\", 2);\n path = \"_design/\" + encodeURIComponent(path[0]) +\n \"/_view/\" + encodeURIComponent(path[1]);\n } else {\n path = \"_temp_view\";\n body = view;\n }\n\n body = this._viewOptions(request.q, body);\n return request(body ? \"POST\" : \"GET\", path, { b: body });\n};\n\n/**\n * Get database changes.\n *\n * The `feed` option determines how the callback is called:\n *\n * - `normal` calls the callback once.\n * - `longpoll` waits for a response, then calls the callback once.\n * - `continuous` calls the callback each time an update is received.\n * Implemented as the `database#follow()` method.\n *\n * @param {Object} [query] HTTP query options.\n * @param {String} [query.feed=\"normal\"] Type of feed. See comments\n * above.\n * @param {String} [query.filter] Filter updates using this filter.\n * @param {Integer} [query.limit] Maximum number of rows to return.\n * @param {Integer} [query.since=0] Start results from this sequence\n * number.\n * @param {Boolean} [query.include_docs=false] Include documents with\n * results.\n * @param {Integer} [query.timeout=1000] Maximum period in milliseconds\n * to wait for a change before sending a response, even if there are no\n * results.\n * @param {Integer} [query.heartbeat=1000] Period in milliseconds after\n * which an empty line is sent. Applicable only to feed types\n * `longpoll` and `continuous`. Overrides `query.timeout` to keep the\n * feed alive indefinitely.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_database_API#Changes|CouchDB Wiki}\n */\n\nDB.prototype.changes = function (/* [query], [headers], [callback] */) {\n var request = this._(arguments);\n if (request.q.feed != \"longpoll\") delete request.q.feed;\n return this._changes(request);\n};\n\n/**\n * Follow database changes.\n *\n * @see `#changes()`.\n */\n\nDB.prototype.follow = function (/* [query], [headers], callback */) {\n var self = this;\n var request = this._(arguments);\n var fn = request.f;\n\n if (!fn) return this;\n\n request.q.feed = \"longpoll\";\n request.f = function (err, body) {\n var args = [].slice.call(arguments);\n var done, i;\n for (i = 0; i < body.length; i++) {\n args[1] = body[i];\n if (done = fn.apply(self, args) === false || err) break;\n }\n if (!done) self._changes(request);\n };\n\n return this._changes(request);\n};\n\n/**\n * Service a changes request.\n *\n * @private\n */\n\nDB.prototype._changes = function (request) {\n return request(\"GET\", \"_changes\");\n};\n\n/**\n * Update document using server-side handler.\n *\n * @param {String} handler Update handler. Example: mydesign/myhandler\n * @param {String} [id] Document ID.\n * @param {Object} [query] HTTP query options.\n * @param {Object|String} [data] Data.\n * @param {Object} [headers] Headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/Document_Update_Handlers|CouchDB Wiki}\n */\n\nDB.prototype.update = function (handler /* [id], [query], [data], [headers], [callback] */) {\n var request = this._(arguments, 1, 1);\n var path = handler.split(\"/\", 2);\n\n path = \"_design/\" + encodeURIComponent(path[0]) +\n \"/_update/\" + encodeURIComponent(path[1]);\n\n if (request.p) path += \"/\" + request.p;\n\n return request(request.p ? \"PUT\" : \"POST\", path, {\n q: request.b,\n b: request.q\n });\n};\n\n/**\n * Download attachment from document.\n *\n * @param {Object|String} docOrId Document or document ID.\n * @param {String} attachmentName Attachment name.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.attachment = function (doc, attachmentName /* [query], [headers], [callback] */) {\n var request = this._(arguments, 2);\n var path = encodeURIComponent(doc._id || doc.id || doc) + \"/\" +\n encodeURIComponent(attachmentName);\n return request(\"GET\", path, options);\n};\n\n/**\n * Upload attachment to document.\n *\n * Set the `Content-Type` header.\n *\n * @param {Object} [doc] Document. Requires `id`. `rev` can be specified\n * here or in `query`.\n * @param {String} attachmentName Attachment name.\n * @param {Object} data Data.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.attach = function (doc, attachmentName, data /* [query], [headers], [callback] */) {\n var request = this._(arguments, 3);\n request.p = encodeURIComponent(doc._id || doc.id) + \"/\" +\n encodeURIComponent(attachmentName);\n if (!request.q.rev) request.q.rev = doc._rev || doc.rev;\n request.q.body = data;\n return request(\"PUT\", path);\n};\n\n/**\n * Replicate database.\n *\n * This convenience function sets `options.source` and `options.target` to\n * the selected database name. Either `options.source` or `options.target`\n * must be overridden for a successful replication request.\n *\n * @param {Options} options Options. Accepts all options from\n * `Client.replicate()`.\n * @param {String} [options.source=this.name] Source database URL or\n * local name. Defaults to the selected database name if not given.\n * @param {String} [options.target=this.name] Target database URL or\n * local name. Defaults to the selected database name if not given.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.replicate = function (options /* [query], [headers], [callback] */) {\n if (!options.source) options.source = this.name;\n if (!options.target) options.target = this.name;\n return this.client.replicate.apply(this.client, arguments);\n};\n\n/**\n * Ensure recent changes are committed to disk.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.commit = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"POST\", \"_ensure_full_commit\");\n};\n\n/**\n * Purge deleted documents from database.\n *\n * @param {Object} revs Map of document IDs to revisions to be purged.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.purge = function (revs /* [query], [headers], [callback] */) {\n return this._(arguments, 1)(\"POST\", \"_purge\", { b: revs });\n};\n\n/**\n * Compact database or design.\n *\n * @param {String} [design] Design name if compacting design indexes.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/Compaction|CouchDB Wiki}\n */\n\nDB.prototype.compact = function (/* [design], [query], [headers], [callback] */) {\n var request = this._(arguments);\n return request(\"POST\", \"_compact/\" + (request.p || \"\"));\n};\n\n/**\n * Remove unused views.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/Compaction|CouchDB Wiki}\n */\n\nDB.prototype.vacuum = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"POST\", \"_view_cleanup\");\n};\n\n/**\n * Parse view options.\n *\n * @param {Object} query The HTTP query options.\n * @param {Object} body The body payload.\n * @param {handler} [callback] Callback function.\n * @return {Object} The body payload.\n * @private\n */\n\nDB.prototype._viewOptions = function (q, body) {\n if (q) {\n if (q.key) q.key = JSON.stringify(q.key);\n if (q.startkey) q.startkey = JSON.stringify(q.startkey);\n if (q.endkey) q.endkey = JSON.stringify(q.endkey);\n if (q.stale && q.stale != \"update_after\") q.stale = \"ok\";\n if (q.keys) {\n if (!body) body = {};\n body.keys = q.keys;\n delete q.keys;\n }\n }\n return body;\n};\n\n/**\n * Handle a clerk response.\n *\n * @callback handler\n * @param {Error|null} error Error or `null` on success.\n * @param {Object} data Response data.\n * @param {Integer} status Response status code.\n * @param {Object} headers Response headers.\n * @param {superagent.Response} res Superagent response object.\n */\n\nclerk.Base = Base;\nclerk.Client = Client;\nclerk.DB = DB;\n\n/**\n * Export clerk.\n */\n\nmodule.exports = clerk;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./clerk.js\n ** module id = 0\n ** module chunks = 0\n **/","/**\n * Module dependencies.\n */\n\nvar Emitter = require('emitter');\nvar reduce = require('reduce');\n\n/**\n * Root reference for iframes.\n */\n\nvar root = 'undefined' == typeof window\n ? this\n : window;\n\n/**\n * Noop.\n */\n\nfunction noop(){};\n\n/**\n * Check if `obj` is a host object,\n * we don't want to serialize these :)\n *\n * TODO: future proof, move to compoent land\n *\n * @param {Object} obj\n * @return {Boolean}\n * @api private\n */\n\nfunction isHost(obj) {\n var str = {}.toString.call(obj);\n\n switch (str) {\n case '[object File]':\n case '[object Blob]':\n case '[object FormData]':\n return true;\n default:\n return false;\n }\n}\n\n/**\n * Determine XHR.\n */\n\nfunction getXHR() {\n if (root.XMLHttpRequest\n && ('file:' != root.location.protocol || !root.ActiveXObject)) {\n return new XMLHttpRequest;\n } else {\n try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) {}\n }\n return false;\n}\n\n/**\n * Removes leading and trailing whitespace, added to support IE.\n *\n * @param {String} s\n * @return {String}\n * @api private\n */\n\nvar trim = ''.trim\n ? function(s) { return s.trim(); }\n : function(s) { return s.replace(/(^\\s*|\\s*$)/g, ''); };\n\n/**\n * Check if `obj` is an object.\n *\n * @param {Object} obj\n * @return {Boolean}\n * @api private\n */\n\nfunction isObject(obj) {\n return obj === Object(obj);\n}\n\n/**\n * Serialize the given `obj`.\n *\n * @param {Object} obj\n * @return {String}\n * @api private\n */\n\nfunction serialize(obj) {\n if (!isObject(obj)) return obj;\n var pairs = [];\n for (var key in obj) {\n if (null != obj[key]) {\n pairs.push(encodeURIComponent(key)\n + '=' + encodeURIComponent(obj[key]));\n }\n }\n return pairs.join('&');\n}\n\n/**\n * Expose serialization method.\n */\n\n request.serializeObject = serialize;\n\n /**\n * Parse the given x-www-form-urlencoded `str`.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\nfunction parseString(str) {\n var obj = {};\n var pairs = str.split('&');\n var parts;\n var pair;\n\n for (var i = 0, len = pairs.length; i < len; ++i) {\n pair = pairs[i];\n parts = pair.split('=');\n obj[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]);\n }\n\n return obj;\n}\n\n/**\n * Expose parser.\n */\n\nrequest.parseString = parseString;\n\n/**\n * Default MIME type map.\n *\n * superagent.types.xml = 'application/xml';\n *\n */\n\nrequest.types = {\n html: 'text/html',\n json: 'application/json',\n xml: 'application/xml',\n urlencoded: 'application/x-www-form-urlencoded',\n 'form': 'application/x-www-form-urlencoded',\n 'form-data': 'application/x-www-form-urlencoded'\n};\n\n/**\n * Default serialization map.\n *\n * superagent.serialize['application/xml'] = function(obj){\n * return 'generated xml here';\n * };\n *\n */\n\n request.serialize = {\n 'application/x-www-form-urlencoded': serialize,\n 'application/json': JSON.stringify\n };\n\n /**\n * Default parsers.\n *\n * superagent.parse['application/xml'] = function(str){\n * return { object parsed from str };\n * };\n *\n */\n\nrequest.parse = {\n 'application/x-www-form-urlencoded': parseString,\n 'application/json': JSON.parse\n};\n\n/**\n * Parse the given header `str` into\n * an object containing the mapped fields.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\nfunction parseHeader(str) {\n var lines = str.split(/\\r?\\n/);\n var fields = {};\n var index;\n var line;\n var field;\n var val;\n\n lines.pop(); // trailing CRLF\n\n for (var i = 0, len = lines.length; i < len; ++i) {\n line = lines[i];\n index = line.indexOf(':');\n field = line.slice(0, index).toLowerCase();\n val = trim(line.slice(index + 1));\n fields[field] = val;\n }\n\n return fields;\n}\n\n/**\n * Return the mime type for the given `str`.\n *\n * @param {String} str\n * @return {String}\n * @api private\n */\n\nfunction type(str){\n return str.split(/ *; */).shift();\n};\n\n/**\n * Return header field parameters.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\nfunction params(str){\n return reduce(str.split(/ *; */), function(obj, str){\n var parts = str.split(/ *= */)\n , key = parts.shift()\n , val = parts.shift();\n\n if (key && val) obj[key] = val;\n return obj;\n }, {});\n};\n\n/**\n * Initialize a new `Response` with the given `xhr`.\n *\n * - set flags (.ok, .error, etc)\n * - parse header\n *\n * Examples:\n *\n * Aliasing `superagent` as `request` is nice:\n *\n * request = superagent;\n *\n * We can use the promise-like API, or pass callbacks:\n *\n * request.get('/').end(function(res){});\n * request.get('/', function(res){});\n *\n * Sending data can be chained:\n *\n * request\n * .post('/user')\n * .send({ name: 'tj' })\n * .end(function(res){});\n *\n * Or passed to `.send()`:\n *\n * request\n * .post('/user')\n * .send({ name: 'tj' }, function(res){});\n *\n * Or passed to `.post()`:\n *\n * request\n * .post('/user', { name: 'tj' })\n * .end(function(res){});\n *\n * Or further reduced to a single call for simple cases:\n *\n * request\n * .post('/user', { name: 'tj' }, function(res){});\n *\n * @param {XMLHTTPRequest} xhr\n * @param {Object} options\n * @api private\n */\n\nfunction Response(req, options) {\n options = options || {};\n this.req = req;\n this.xhr = this.req.xhr;\n this.text = this.req.method !='HEAD' \n ? this.xhr.responseText \n : null;\n this.setStatusProperties(this.xhr.status);\n this.header = this.headers = parseHeader(this.xhr.getAllResponseHeaders());\n // getAllResponseHeaders sometimes falsely returns \"\" for CORS requests, but\n // getResponseHeader still works. so we get content-type even if getting\n // other headers fails.\n this.header['content-type'] = this.xhr.getResponseHeader('content-type');\n this.setHeaderProperties(this.header);\n this.body = this.req.method != 'HEAD'\n ? this.parseBody(this.text)\n : null;\n}\n\n/**\n * Get case-insensitive `field` value.\n *\n * @param {String} field\n * @return {String}\n * @api public\n */\n\nResponse.prototype.get = function(field){\n return this.header[field.toLowerCase()];\n};\n\n/**\n * Set header related properties:\n *\n * - `.type` the content type without params\n *\n * A response of \"Content-Type: text/plain; charset=utf-8\"\n * will provide you with a `.type` of \"text/plain\".\n *\n * @param {Object} header\n * @api private\n */\n\nResponse.prototype.setHeaderProperties = function(header){\n // content-type\n var ct = this.header['content-type'] || '';\n this.type = type(ct);\n\n // params\n var obj = params(ct);\n for (var key in obj) this[key] = obj[key];\n};\n\n/**\n * Parse the given body `str`.\n *\n * Used for auto-parsing of bodies. Parsers\n * are defined on the `superagent.parse` object.\n *\n * @param {String} str\n * @return {Mixed}\n * @api private\n */\n\nResponse.prototype.parseBody = function(str){\n var parse = request.parse[this.type];\n return parse && str && str.length\n ? parse(str)\n : null;\n};\n\n/**\n * Set flags such as `.ok` based on `status`.\n *\n * For example a 2xx response will give you a `.ok` of __true__\n * whereas 5xx will be __false__ and `.error` will be __true__. The\n * `.clientError` and `.serverError` are also available to be more\n * specific, and `.statusType` is the class of error ranging from 1..5\n * sometimes useful for mapping respond colors etc.\n *\n * \"sugar\" properties are also defined for common cases. Currently providing:\n *\n * - .noContent\n * - .badRequest\n * - .unauthorized\n * - .notAcceptable\n * - .notFound\n *\n * @param {Number} status\n * @api private\n */\n\nResponse.prototype.setStatusProperties = function(status){\n var type = status / 100 | 0;\n\n // status / class\n this.status = status;\n this.statusType = type;\n\n // basics\n this.info = 1 == type;\n this.ok = 2 == type;\n this.clientError = 4 == type;\n this.serverError = 5 == type;\n this.error = (4 == type || 5 == type)\n ? this.toError()\n : false;\n\n // sugar\n this.accepted = 202 == status;\n this.noContent = 204 == status || 1223 == status;\n this.badRequest = 400 == status;\n this.unauthorized = 401 == status;\n this.notAcceptable = 406 == status;\n this.notFound = 404 == status;\n this.forbidden = 403 == status;\n};\n\n/**\n * Return an `Error` representative of this response.\n *\n * @return {Error}\n * @api public\n */\n\nResponse.prototype.toError = function(){\n var req = this.req;\n var method = req.method;\n var url = req.url;\n\n var msg = 'cannot ' + method + ' ' + url + ' (' + this.status + ')';\n var err = new Error(msg);\n err.status = this.status;\n err.method = method;\n err.url = url;\n\n return err;\n};\n\n/**\n * Expose `Response`.\n */\n\nrequest.Response = Response;\n\n/**\n * Initialize a new `Request` with the given `method` and `url`.\n *\n * @param {String} method\n * @param {String} url\n * @api public\n */\n\nfunction Request(method, url) {\n var self = this;\n Emitter.call(this);\n this._query = this._query || [];\n this.method = method;\n this.url = url;\n this.header = {};\n this._header = {};\n this.on('end', function(){\n var err = null;\n var res = null;\n\n try {\n res = new Response(self); \n } catch(e) {\n err = new Error('Parser is unable to parse the response');\n err.parse = true;\n err.original = e;\n }\n\n self.callback(err, res);\n });\n}\n\n/**\n * Mixin `Emitter`.\n */\n\nEmitter(Request.prototype);\n\n/**\n * Allow for extension\n */\n\nRequest.prototype.use = function(fn) {\n fn(this);\n return this;\n}\n\n/**\n * Set timeout to `ms`.\n *\n * @param {Number} ms\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.timeout = function(ms){\n this._timeout = ms;\n return this;\n};\n\n/**\n * Clear previous timeout.\n *\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.clearTimeout = function(){\n this._timeout = 0;\n clearTimeout(this._timer);\n return this;\n};\n\n/**\n * Abort the request, and clear potential timeout.\n *\n * @return {Request}\n * @api public\n */\n\nRequest.prototype.abort = function(){\n if (this.aborted) return;\n this.aborted = true;\n this.xhr.abort();\n this.clearTimeout();\n this.emit('abort');\n return this;\n};\n\n/**\n * Set header `field` to `val`, or multiple fields with one object.\n *\n * Examples:\n *\n * req.get('/')\n * .set('Accept', 'application/json')\n * .set('X-API-Key', 'foobar')\n * .end(callback);\n *\n * req.get('/')\n * .set({ Accept: 'application/json', 'X-API-Key': 'foobar' })\n * .end(callback);\n *\n * @param {String|Object} field\n * @param {String} val\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.set = function(field, val){\n if (isObject(field)) {\n for (var key in field) {\n this.set(key, field[key]);\n }\n return this;\n }\n this._header[field.toLowerCase()] = val;\n this.header[field] = val;\n return this;\n};\n\n/**\n * Remove header `field`.\n *\n * Example:\n *\n * req.get('/')\n * .unset('User-Agent')\n * .end(callback);\n *\n * @param {String} field\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.unset = function(field){\n delete this._header[field.toLowerCase()];\n delete this.header[field];\n return this;\n};\n\n/**\n * Get case-insensitive header `field` value.\n *\n * @param {String} field\n * @return {String}\n * @api private\n */\n\nRequest.prototype.getHeader = function(field){\n return this._header[field.toLowerCase()];\n};\n\n/**\n * Set Content-Type to `type`, mapping values from `request.types`.\n *\n * Examples:\n *\n * superagent.types.xml = 'application/xml';\n *\n * request.post('/')\n * .type('xml')\n * .send(xmlstring)\n * .end(callback);\n *\n * request.post('/')\n * .type('application/xml')\n * .send(xmlstring)\n * .end(callback);\n *\n * @param {String} type\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.type = function(type){\n this.set('Content-Type', request.types[type] || type);\n return this;\n};\n\n/**\n * Set Accept to `type`, mapping values from `request.types`.\n *\n * Examples:\n *\n * superagent.types.json = 'application/json';\n *\n * request.get('/agent')\n * .accept('json')\n * .end(callback);\n *\n * request.get('/agent')\n * .accept('application/json')\n * .end(callback);\n *\n * @param {String} accept\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.accept = function(type){\n this.set('Accept', request.types[type] || type);\n return this;\n};\n\n/**\n * Set Authorization field value with `user` and `pass`.\n *\n * @param {String} user\n * @param {String} pass\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.auth = function(user, pass){\n var str = btoa(user + ':' + pass);\n this.set('Authorization', 'Basic ' + str);\n return this;\n};\n\n/**\n* Add query-string `val`.\n*\n* Examples:\n*\n* request.get('/shoes')\n* .query('size=10')\n* .query({ color: 'blue' })\n*\n* @param {Object|String} val\n* @return {Request} for chaining\n* @api public\n*/\n\nRequest.prototype.query = function(val){\n if ('string' != typeof val) val = serialize(val);\n if (val) this._query.push(val);\n return this;\n};\n\n/**\n * Write the field `name` and `val` for \"multipart/form-data\"\n * request bodies.\n *\n * ``` js\n * request.post('/upload')\n * .field('foo', 'bar')\n * .end(callback);\n * ```\n *\n * @param {String} name\n * @param {String|Blob|File} val\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.field = function(name, val){\n if (!this._formData) this._formData = new FormData();\n this._formData.append(name, val);\n return this;\n};\n\n/**\n * Queue the given `file` as an attachment to the specified `field`,\n * with optional `filename`.\n *\n * ``` js\n * request.post('/upload')\n * .attach(new Blob(['hey!'], { type: \"text/html\"}))\n * .end(callback);\n * ```\n *\n * @param {String} field\n * @param {Blob|File} file\n * @param {String} filename\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.attach = function(field, file, filename){\n if (!this._formData) this._formData = new FormData();\n this._formData.append(field, file, filename);\n return this;\n};\n\n/**\n * Send `data`, defaulting the `.type()` to \"json\" when\n * an object is given.\n *\n * Examples:\n *\n * // querystring\n * request.get('/search')\n * .end(callback)\n *\n * // multiple data \"writes\"\n * request.get('/search')\n * .send({ search: 'query' })\n * .send({ range: '1..5' })\n * .send({ order: 'desc' })\n * .end(callback)\n *\n * // manual json\n * request.post('/user')\n * .type('json')\n * .send('{\"name\":\"tj\"})\n * .end(callback)\n *\n * // auto json\n * request.post('/user')\n * .send({ name: 'tj' })\n * .end(callback)\n *\n * // manual x-www-form-urlencoded\n * request.post('/user')\n * .type('form')\n * .send('name=tj')\n * .end(callback)\n *\n * // auto x-www-form-urlencoded\n * request.post('/user')\n * .type('form')\n * .send({ name: 'tj' })\n * .end(callback)\n *\n * // defaults to x-www-form-urlencoded\n * request.post('/user')\n * .send('name=tobi')\n * .send('species=ferret')\n * .end(callback)\n *\n * @param {String|Object} data\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.send = function(data){\n var obj = isObject(data);\n var type = this.getHeader('Content-Type');\n\n // merge\n if (obj && isObject(this._data)) {\n for (var key in data) {\n this._data[key] = data[key];\n }\n } else if ('string' == typeof data) {\n if (!type) this.type('form');\n type = this.getHeader('Content-Type');\n if ('application/x-www-form-urlencoded' == type) {\n this._data = this._data\n ? this._data + '&' + data\n : data;\n } else {\n this._data = (this._data || '') + data;\n }\n } else {\n this._data = data;\n }\n\n if (!obj) return this;\n if (!type) this.type('json');\n return this;\n};\n\n/**\n * Invoke the callback with `err` and `res`\n * and handle arity check.\n *\n * @param {Error} err\n * @param {Response} res\n * @api private\n */\n\nRequest.prototype.callback = function(err, res){\n var fn = this._callback;\n this.clearTimeout();\n if (2 == fn.length) return fn(err, res);\n if (err) return this.emit('error', err);\n fn(res);\n};\n\n/**\n * Invoke callback with x-domain error.\n *\n * @api private\n */\n\nRequest.prototype.crossDomainError = function(){\n var err = new Error('Origin is not allowed by Access-Control-Allow-Origin');\n err.crossDomain = true;\n this.callback(err);\n};\n\n/**\n * Invoke callback with timeout error.\n *\n * @api private\n */\n\nRequest.prototype.timeoutError = function(){\n var timeout = this._timeout;\n var err = new Error('timeout of ' + timeout + 'ms exceeded');\n err.timeout = timeout;\n this.callback(err);\n};\n\n/**\n * Enable transmission of cookies with x-domain requests.\n *\n * Note that for this to work the origin must not be\n * using \"Access-Control-Allow-Origin\" with a wildcard,\n * and also must set \"Access-Control-Allow-Credentials\"\n * to \"true\".\n *\n * @api public\n */\n\nRequest.prototype.withCredentials = function(){\n this._withCredentials = true;\n return this;\n};\n\n/**\n * Initiate request, invoking callback `fn(res)`\n * with an instanceof `Response`.\n *\n * @param {Function} fn\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.end = function(fn){\n var self = this;\n var xhr = this.xhr = getXHR();\n var query = this._query.join('&');\n var timeout = this._timeout;\n var data = this._formData || this._data;\n\n // store callback\n this._callback = fn || noop;\n\n // state change\n xhr.onreadystatechange = function(){\n if (4 != xhr.readyState) return;\n if (0 == xhr.status) {\n if (self.aborted) return self.timeoutError();\n return self.crossDomainError();\n }\n self.emit('end');\n };\n\n // progress\n if (xhr.upload) {\n xhr.upload.onprogress = function(e){\n e.percent = e.loaded / e.total * 100;\n self.emit('progress', e);\n };\n }\n\n // timeout\n if (timeout && !this._timer) {\n this._timer = setTimeout(function(){\n self.abort();\n }, timeout);\n }\n\n // querystring\n if (query) {\n query = request.serializeObject(query);\n this.url += ~this.url.indexOf('?')\n ? '&' + query\n : '?' + query;\n }\n\n // initiate request\n xhr.open(this.method, this.url, true);\n\n // CORS\n if (this._withCredentials) xhr.withCredentials = true;\n\n // body\n if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !isHost(data)) {\n // serialize stuff\n var serialize = request.serialize[this.getHeader('Content-Type')];\n if (serialize) data = serialize(data);\n }\n\n // set header fields\n for (var field in this.header) {\n if (null == this.header[field]) continue;\n xhr.setRequestHeader(field, this.header[field]);\n }\n\n // send stuff\n this.emit('request', this);\n xhr.send(data);\n return this;\n};\n\n/**\n * Expose `Request`.\n */\n\nrequest.Request = Request;\n\n/**\n * Issue a request:\n *\n * Examples:\n *\n * request('GET', '/users').end(callback)\n * request('/users').end(callback)\n * request('/users', callback)\n *\n * @param {String} method\n * @param {String|Function} url or callback\n * @return {Request}\n * @api public\n */\n\nfunction request(method, url) {\n // callback\n if ('function' == typeof url) {\n return new Request('GET', method).end(url);\n }\n\n // url first\n if (1 == arguments.length) {\n return new Request('GET', method);\n }\n\n return new Request(method, url);\n}\n\n/**\n * GET `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} data or fn\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.get = function(url, data, fn){\n var req = request('GET', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.query(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * HEAD `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} data or fn\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.head = function(url, data, fn){\n var req = request('HEAD', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * DELETE `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.del = function(url, fn){\n var req = request('DELETE', url);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * PATCH `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed} data\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.patch = function(url, data, fn){\n var req = request('PATCH', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * POST `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed} data\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.post = function(url, data, fn){\n var req = request('POST', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * PUT `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} data or fn\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.put = function(url, data, fn){\n var req = request('PUT', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * Expose `request`.\n */\n\nmodule.exports = request;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/superagent/lib/client.js\n ** module id = 1\n ** module chunks = 0\n **/","\n/**\n * Expose `Emitter`.\n */\n\nmodule.exports = Emitter;\n\n/**\n * Initialize a new `Emitter`.\n *\n * @api public\n */\n\nfunction Emitter(obj) {\n if (obj) return mixin(obj);\n};\n\n/**\n * Mixin the emitter properties.\n *\n * @param {Object} obj\n * @return {Object}\n * @api private\n */\n\nfunction mixin(obj) {\n for (var key in Emitter.prototype) {\n obj[key] = Emitter.prototype[key];\n }\n return obj;\n}\n\n/**\n * Listen on the given `event` with `fn`.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.on =\nEmitter.prototype.addEventListener = function(event, fn){\n this._callbacks = this._callbacks || {};\n (this._callbacks[event] = this._callbacks[event] || [])\n .push(fn);\n return this;\n};\n\n/**\n * Adds an `event` listener that will be invoked a single\n * time then automatically removed.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.once = function(event, fn){\n var self = this;\n this._callbacks = this._callbacks || {};\n\n function on() {\n self.off(event, on);\n fn.apply(this, arguments);\n }\n\n on.fn = fn;\n this.on(event, on);\n return this;\n};\n\n/**\n * Remove the given callback for `event` or all\n * registered callbacks.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.off =\nEmitter.prototype.removeListener =\nEmitter.prototype.removeAllListeners =\nEmitter.prototype.removeEventListener = function(event, fn){\n this._callbacks = this._callbacks || {};\n\n // all\n if (0 == arguments.length) {\n this._callbacks = {};\n return this;\n }\n\n // specific event\n var callbacks = this._callbacks[event];\n if (!callbacks) return this;\n\n // remove all handlers\n if (1 == arguments.length) {\n delete this._callbacks[event];\n return this;\n }\n\n // remove specific handler\n var cb;\n for (var i = 0; i < callbacks.length; i++) {\n cb = callbacks[i];\n if (cb === fn || cb.fn === fn) {\n callbacks.splice(i, 1);\n break;\n }\n }\n return this;\n};\n\n/**\n * Emit `event` with the given args.\n *\n * @param {String} event\n * @param {Mixed} ...\n * @return {Emitter}\n */\n\nEmitter.prototype.emit = function(event){\n this._callbacks = this._callbacks || {};\n var args = [].slice.call(arguments, 1)\n , callbacks = this._callbacks[event];\n\n if (callbacks) {\n callbacks = callbacks.slice(0);\n for (var i = 0, len = callbacks.length; i < len; ++i) {\n callbacks[i].apply(this, args);\n }\n }\n\n return this;\n};\n\n/**\n * Return array of callbacks for `event`.\n *\n * @param {String} event\n * @return {Array}\n * @api public\n */\n\nEmitter.prototype.listeners = function(event){\n this._callbacks = this._callbacks || {};\n return this._callbacks[event] || [];\n};\n\n/**\n * Check if this emitter has `event` handlers.\n *\n * @param {String} event\n * @return {Boolean}\n * @api public\n */\n\nEmitter.prototype.hasListeners = function(event){\n return !! this.listeners(event).length;\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/superagent/~/component-emitter/index.js\n ** module id = 2\n ** module chunks = 0\n **/","\n/**\n * Reduce `arr` with `fn`.\n *\n * @param {Array} arr\n * @param {Function} fn\n * @param {Mixed} initial\n *\n * TODO: combatible error handling?\n */\n\nmodule.exports = function(arr, fn, initial){ \n var idx = 0;\n var len = arr.length;\n var curr = arguments.length == 3\n ? initial\n : arr[idx++];\n\n while (idx < len) {\n curr = fn.call(null, curr, arr[idx], ++idx, arr);\n }\n \n return curr;\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/superagent/~/reduce-component/index.js\n ** module id = 3\n ** module chunks = 0\n **/"],"sourceRoot":"","file":"clerk.js"} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap 44f255cf130f3cbddf56","webpack:///./clerk.js","webpack:///./~/superagent/lib/client.js","webpack:///./~/superagent/~/component-emitter/index.js","webpack:///./~/superagent/~/reduce-component/index.js"],"names":[],"mappings":";;AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,wC;;;;;;;ACtCA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,UAAU;AACrB,YAAY,OAAO;AACnB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,OAAO;AACnB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,UAAU;AACtB;AACA,SAAS;AACT,SAAS;AACT,SAAS;AACT;;AAEA;AACA;AACA;;AAEA;AACA;AACA,UAAU;AACV;;AAEA;;AAEA;AACA;AACA,UAAU;AACV;;AAEA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,UAAU;AACtB;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;;AAEA;AACA;AACA,CAAC;AACD;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,OAAO;AACnB;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,QAAQ;AACnB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB,WAAW,QAAQ;AACnB;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,wBAAwB,gBAAgB;AACxC,yBAAyB,iBAAiB;AAC1C,0BAA0B,aAAa;AACvC,aAAa;AACb;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB,WAAW,QAAQ;AACnB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA,+BAA+B,iBAAiB;AAChD;AACA;AACA;;AAEA;;AAEA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,2BAA2B,SAAS;AACpC;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,YAAY,OAAO;AACnB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,OAAO;AACnB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB;AACA,YAAY,QAAQ;AACpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAA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AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,gBAAgB;AAC3B,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB;AACA,aAAa,OAAO;AACpB;AACA,eAAe,OAAO;AACtB;AACA,eAAe,OAAO;AACtB;AACA,eAAe,cAAc;AAC7B;AACA,WAAW,OAAO;AAClB,aAAa,QAAQ;AACrB;AACA;AACA,aAAa,QAAQ;AACrB;AACA,WAAW,OAAO;AAClB,WAAW,QAAQ;AACnB,YAAY,QAAQ;AACpB;AACA,SAAS;AACT,SAAS;AACT;;AAEA;AACA;AACA;AACA;AACA,wBAAwB,aAAa;AACrC;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,QAAQ;AACnB,YAAY,QAAQ;AACpB;AACA,SAAS;AACT;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,gBAAgB;AAC3B,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,QAAQ;AACnB,YAAY,QAAQ;AACpB;AACA,SAAS;AACT,SAAS;AACT;;AAEA;AACA;AACA;AACA,UAAU,SAAS;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB;AACA,aAAa,OAAO;AACpB;AACA,WAAW,OAAO;AAClB,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB;AACA,aAAa,OAAO;AACpB;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,QAAQ;AACnB,YAAY,QAAQ;AACpB;AACA,SA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;AACnB,YAAY,QAAQ;AACpB;AACA,SAAS;AACT;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,eAAe,iBAAiB;AAChC;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,cAAc;AACzB,WAAW,OAAO;AAClB,WAAW,QAAQ;AACnB,YAAY,QAAQ;AACpB;AACA,SAAS;AACT;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,cAAc;AACzB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,QAAQ;AACnB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,QAAQ;AACnB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,QAAQ;AACnB;AACA,aAAa,OAAO;AACpB;AACA,aAAa,OAAO;AACpB;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,QAAQ;AACnB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,QAAQ;AACnB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,W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W,OAAO;AAClB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,YAAY,OAAO;AACnB,aAAa;AACb;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,qCAAqC,SAAS;AAC9C;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,cAAc;;AAEd,qCAAqC,SAAS;AAC9C;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;;AAEA;AACA,uBAAuB;AACvB;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;;AAEA;AACA,8BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA,GAAG,IAAI;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4CAA4C;AAC5C,wCAAwC;AACxC;AACA;AACA;AACA;AACA;AACA,iBAAiB,aAAa;AAC9B,8BAA8B;AAC9B;AACA;AACA;AACA;AACA;AACA,iBAAiB,aAAa,iBAAiB;AAC/C;AACA;AACA;AACA;AACA,0BAA0B,aAAa;AACvC,8BAA8B;AAC9B;AACA;AACA;AACA;AACA,0BAA0B,aAAa,iBAAiB;AACxD;AACA,WAAW,eAAe;AAC1B,WAAW,OAAO;AAClB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,2CAA2C;AAC3C;AACA;AACA,WAAW,OAAO;AAClB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,+B;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA,GAAG;AACH;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,oDAAoD;AACpE;AACA;AACA,WAAW,cAAc;AACzB,WAAW,OAAO;AAClB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc,gBAAgB;AAC9B;AACA,UAAU,cAAc;AACxB,WAAW,QAAQ;AACnB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,iBAAiB;AAC5B,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,6DAA6D,mBAAmB;AAChF;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,UAAU;AACrB,WAAW,OAAO;AAClB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,kBAAkB;AACpC,kBAAkB,gBAAgB;AAClC,kBAAkB,gBAAgB;AAClC;AACA;AACA;AACA;AACA;AACA,mBAAmB,YAAY;AAC/B;AACA;AACA;AACA;AACA,kBAAkB,aAAa;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,aAAa;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,cAAc;AACzB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,SAAS;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,SAAS;AACpB,YAAY,QAAQ;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,gBAAgB;AAC3B,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,eAAe;AAC1B,WAAW,SAAS;AACpB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,eAAe;AAC1B,WAAW,SAAS;AACpB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,SAAS;AACpB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,MAAM;AACjB,WAAW,SAAS;AACpB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,MAAM;AACjB,WAAW,SAAS;AACpB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,eAAe;AAC1B,WAAW,SAAS;AACpB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;;;;;;;ACvjCA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,SAAS;AACpB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,SAAS;AACpB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,SAAS;AACpB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,sBAAsB;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,MAAM;AACjB,YAAY;AACZ;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,2CAA2C,SAAS;AACpD;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;;;;;;;;AClKA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,SAAS;AACpB,WAAW,MAAM;AACjB;AACA;AACA;;AAEA,4C;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,E","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 44f255cf130f3cbddf56\n **/","\"use strict\";\n\n/*!\n\nclerk - CouchDB client for node and the browser.\nCopyright 2012-2015 Michael Phan-Ba\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n*/\n\n// Module dependencies.\nvar request = require(\"superagent\");\n\n/**\n * Copy properties from sources to target.\n *\n * @param {Object} target The target object.\n * @param {...Object} sources The source object.\n * @return {Object} The target object.\n * @private\n */\n\nvar extend = function (target /* ...sources */) {\n var source, key, i = 1;\n while (source = arguments[i++]) {\n for (key in source) target[key] = source[key];\n }\n return target;\n};\n\n/**\n * Stringify value.\n *\n * @param {Object} that That value to stringify.\n * @return {String} The stringifyed value.\n * @private\n */\n\nvar asString = function (that) {\n return Object.prototype.toString.call(that);\n};\n\n/**\n * Check if value is a string.\n *\n * @param {Object} that That value to check.\n * @return {Boolean} `true` if string, `false` otherwise.\n * @private\n */\n\nvar isString = function (that) {\n return asString(that) == \"[object String]\";\n};\n\n/**\n * Check if value is an object.\n *\n * @param {Object} that That value to check.\n * @return {Boolean} `true` if object, `false` otherwise.\n * @private\n */\n\nvar isObject = function (that) {\n return asString(that) == \"[object Object]\";\n};\n\n/**\n * Check if value is an array.\n *\n * @param {Object} that That value to check.\n * @return {Boolean} `true` if array, `false` otherwise.\n * @private\n */\n\nvar isArray = function (that) {\n return asString(that) == \"[object Array]\";\n};\n\n/**\n * Check if value is a function.\n *\n * @param {Object} that That value to check.\n * @return {Boolean} `true` if function, `false` otherwise.\n * @private\n */\n\nvar isFunction = function (that) {\n return asString(that) == \"[object Function]\";\n};\n\n/**\n * Clerk library entry point.\n *\n * @param {String} uri CouchDB server URI.\n * @return {Client|DB} If a URI path is given, returns a `DB`, otherwise\n * returns a `Client`.\n * @see {@link http://docs.couchdb.org|CouchDB Documentation}\n * @see {@link http://guide.couchdb.org/|CouchDB Guide}\n * @see {@link http://wiki.apache.org/couchdb/|CouchDB Wiki}\n */\n\nfunction clerk (uri) {\n return clerk.make(uri);\n};\n\n/**\n * Library version.\n * @type {String}\n */\n\nclerk.version = \"0.8.0\";\n\n/**\n * Default host.\n * @type {String}\n */\n\nclerk.defaultHost = \"http://127.0.0.1:5984\";\n\n/**\n * Create single CouchDB client.\n *\n * @param {String} uri Fully qualified URI.\n * @return {Client|DB} If `uri` has a path, the last segment of the\n * path is used as the database name and a `DB` instance is\n * returned. Otherwise, a `Client` instance is returned.\n */\n\nclerk.make = function (uri) {\n if (!uri) return new Client(this.defaultHost);\n\n uri = clerk._parseURI(uri);\n\n var db = /\\/*([^\\/]+)\\/*$/.exec(uri.path);\n if (db) {\n uri.path = uri.path.substr(0, db.index);\n db = db[1] && decodeURIComponent(db[1]);\n }\n\n // weird way of doing it, but it's more efficient...\n if (uri.auth) uri.auth = 'Basic ' + clerk.btoa(uri.auth);\n\n var client = new clerk.Client(uri.base + uri.path, uri.auth);\n return db ? client.db(db) : client;\n};\n\n/**\n * Base64-encode a string.\n *\n * @param {String} str\n * @return {String}\n */\n\nclerk.btoa = typeof Buffer != \"undefined\" ? function (str) {\n return new Buffer(str).toString(\"base64\");\n} : function (str) {\n return btoa(str);\n};\n\n/**\n * Parse URI.\n *\n * The URI is normalized by removing extra `//` in the path.\n *\n * @param {String} uri Fully qualified URI.\n * @return {String} The normalized URI.\n * @private\n */\n\nclerk._parseURI = function (uri) {\n var match;\n\n if (uri) {\n if (match = /^(https?:\\/\\/)(?:([^\\/@]+)@)?([^\\/]+)(.*)\\/*$/.exec(uri)) {\n return {\n base: match[1] + match[3].replace(/\\/+/g, \"\\/\"),\n path: match[4],\n auth: match[2] && decodeURIComponent(match[2])\n };\n }\n }\n\n return { base: uri || \"\", path: \"\" };\n};\n\n/**\n * Base prototype for `Client` and `DB`.\n * Encapsulates HTTP methods, JSON handling, and response coersion.\n *\n * @constructor\n * @memberof clerk\n */\n\nfunction Base () {};\n\n/**\n * Service request and parse JSON response.\n *\n * @param {String} [method=GET] HTTP method.\n * @param {String} [path=this.uri] HTTP URI.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [body] HTTP body.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nBase.prototype.request = function (/* [method], [path], [query], [body], [headers], [callback] */) {\n var args = [].slice.call(arguments);\n var callback = isFunction (args[args.length - 1]) && args.pop();\n\n return this._request({\n method: args[0],\n path: args[1],\n query: args[2],\n data: args[3],\n headers: args[4],\n fn: callback\n });\n};\n\n/**\n * Internal service request and parse JSON response handler.\n *\n * @param {String} options\n * @param {String} method HTTP method.\n * @param {String} path HTTP URI.\n * @param {Object} query HTTP query options.\n * @param {Object} data HTTP body data.\n * @param {Object} headers HTTP headers.\n * @param {handler} [callback] Callback function.\n * @private\n */\n\nBase.prototype._request = function (options) {\n var self = this;\n\n if (options.method == null) options.method = \"GET\";\n if (options.headers == null) options.headers = {};\n if (options.auth == null) options.auth = this.auth;\n\n options.path = options.path ? \"/\" + options.path : \"\";\n\n // set default headers\n if (options.headers[\"Content-Type\"] == null) {\n options.headers[\"Content-Type\"] = \"application/json\";\n }\n if (options.headers[\"Accept\"] == null) {\n options.headers[\"Accept\"] = \"application/json\";\n }\n if (this.auth && options.headers[\"Authorization\"] == null) {\n options.headers[\"Authorization\"] = this.auth;\n }\n\n options.uri = this.uri + options.path;\n options.body = options.data && JSON.stringify(options.data,\n /^\\/_design/.test(options.path) && this._replacer\n ) || \"\";\n\n // create promise if no callback given\n var promise, req;\n if (!options.fn && typeof Promise != \"undefined\") {\n promise = new Promise(function (resolve, reject) {\n options.fn = function (err, data, status, headers, res) {\n if (err) {\n err.body = data;\n err.status = status;\n err.headers = headers;\n err.res = res;\n reject(err);\n } else {\n if (Object.defineProperties) {\n Object.defineProperties(data, {\n _status: { value: status },\n _headers: { value: headers },\n _response: { value: res },\n });\n }\n resolve(data);\n };\n };\n });\n req = send();\n promise.request = req;\n promise.abort = function () {\n req.abort();\n options.fn(new Error(\"abort\"));\n return promise;\n };\n return promise;\n }\n\n send();\n\n function send () {\n // apply response transforms\n var g = options._;\n var fn = options.fn;\n if (fn) {\n options.fn = g ? function () {\n fn.apply(self, g.apply(self, arguments) || arguments);\n } : fn;\n }\n return self._do(options);\n }\n};\n\n/**\n * Provider for servicing requests and parsing JSON responses.\n *\n * @param {String} options\n * @param {String} method HTTP method.\n * @param {String} uri HTTP URI.\n * @param {Object} query HTTP query options.\n * @param {Object} body HTTP body.\n * @param {Object} headers HTTP headers.\n * @param {Object} auth HTTP authentication.\n * @param {handler} [callback] Callback function.\n * @private\n */\n\nBase.prototype._do = function (options) {\n var self = this;\n var key, value;\n\n // create request\n var req = request(options.method, options.uri);\n\n // query string\n if (options.query) {\n // ensure query Array values are JSON encoded\n for (key in options.query) {\n if (typeof(value = options.query[key]) === \"object\") {\n options.query[key] = JSON.stringify(value);\n }\n }\n // set query on request\n req.query(options.query);\n }\n\n // set headers\n if (options.headers) {\n req.set(options.headers);\n // if authenticating\n if (req.withCredentials && options.headers[\"Authorization\"] != null) {\n req.withCredentials();\n }\n }\n\n // send body\n if (options.body) req.send(options.body);\n\n // send request\n var fn = options.fn;\n req.end(function (res) {\n var err = res.error;\n var data;\n\n if (!err) {\n if (!(data = res.body)) { data = res.text; }\n else if (data.error) err = self._error(data);\n else data = self._response(data);\n }\n\n res.data = data;\n\n fn && fn(err || null, data, res.status, res.header, res);\n });\n\n return req;\n};\n\n/**\n * Coerce response to normalize access to `_id` and `_rev`.\n *\n * @param {Object} json The response JSON.\n * @return The coerced JSON.\n * @private\n */\n\nBase.prototype._response = function (json) {\n var data = json.rows || json.results || json.uuids || isArray(json) && json;\n var meta = this._meta;\n var i = 0, len, item;\n\n if (data) {\n extend(data, json).json = json;\n for (len = data.length; i < len; i++) {\n item = data[i] = meta(data[i]);\n if (item.doc) item.doc = meta(item.doc);\n }\n } else {\n data = meta(json);\n }\n\n return data;\n};\n\n/**\n * Make an error out of the response.\n *\n * @param {Object} json The response JSON.\n * @return An `Error` object.\n * @private\n */\n\nBase.prototype._error = function (json) {\n var err = new Error(json.reason);\n err.code = json.error;\n return extend(err, json);\n};\n\n/**\n * JSON stringify functions. Used for encoding view documents to JSON.\n *\n * @param {String} key The key to stringify.\n * @param {Object} val The value to stringify.\n * @return {Object} The stringified function value or the value.\n * @private\n */\n\nBase.prototype._replacer = function (key, val) {\n return isFunction (val) ? val.toString() : val;\n};\n\n/**\n * Coerce documents with prototypical `_id` and `_rev`\n * values.\n *\n * @param {Object} doc The document to coerce.\n * @return {Object} The coerced document.\n * @private\n */\n\nBase.prototype._meta = function (doc) {\n var hasId = !doc._id && doc.id;\n var hasRev = !doc._rev && doc.rev;\n var proto;\n\n if (hasId || hasRev) {\n proto = function (){};\n doc = extend(new proto(), doc);\n proto = proto.prototype;\n if (hasId) proto._id = doc.id;\n if (hasRev) proto._rev = doc.rev;\n }\n\n return doc;\n};\n\n/**\n * Parse arguments.\n *\n * @param {Array} args The arguments.\n * @param {Integer} start The index from which to start reading arguments.\n * @param {Boolean} withDoc Set to `true` if the doc source is given as a\n * parameter before HTTP query options.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @private\n */\n\nBase.prototype._ = function (args, start, withDoc) {\n var self = this, doc, id, rev;\n\n function request(method, path, options) {\n if (!options) options = {};\n return self._request({\n method: method,\n path: path || request.p,\n query: options.q || request.q,\n data: options.b || request.b,\n headers: options.h || request.h,\n fn: options.f || request.f,\n _: options._ || request._\n });\n }\n\n // [id], [doc], [query], [header], [callback]\n args = [].slice.call(args, start || 0);\n\n request.f = isFunction(args[args.length - 1]) && args.pop();\n request.p = isString(args[0]) && encodeURI(args.shift());\n request.q = args[withDoc ? 1 : 0] || {};\n request.h = args[withDoc ? 2 : 1] || {};\n\n if (withDoc) {\n if (doc = (request.b = args[0])) {\n if (id = request.p || doc._id || doc.id) request.p = id;\n if (rev = request.q.rev || doc._rev || doc.rev) request.q.rev = rev;\n }\n }\n\n return request;\n};\n\n/**\n * Clerk CouchDB client.\n *\n * @param {String} uri Fully qualified URI.\n * @param {String} [auth] Authentication header value.\n * @constructor\n * @memberof clerk\n * @see {@link http://wiki.apache.org/couchdb/Complete_HTTP_API_Reference|CouchDB Wiki}\n */\n\nfunction Client (uri, auth) {\n this.uri = uri;\n this._db = {};\n this.auth = auth;\n};\n\nClient.prototype = new Base();\n\n/**\n * Select database to manipulate.\n *\n * @param {String} name DB name.\n * @return {DB} DB object.\n */\n\nClient.prototype.db = function (name) {\n var db = this._db;\n return db[name] || (db[name] = new DB(this, name, this.auth));\n};\n\n/**\n * List all databases.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetAllDbs|CouchDB Wiki}\n */\n\nClient.prototype.dbs = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\", \"_all_dbs\");\n};\n\n/**\n * Get UUIDs.\n *\n * @param {Integer} [count=1] Number of UUIDs to get.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetUuids|CouchDB Wiki}\n */\n\nClient.prototype.uuids = function (count /* [query], [headers], [callback] */) {\n var request = this._(arguments, +count == count ? 1 : 0);\n if (count > 1) request.q.count = count;\n return request(\"GET\", \"_uuids\");\n};\n\n/**\n * Get server information.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetRoot|CouchDB Wiki}\n */\n\nClient.prototype.info = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\");\n};\n\n/**\n * Get server stats.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetLog|CouchDB Wiki}\n */\n\nClient.prototype.stats = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\", \"_stats\");\n};\n\n/**\n * Get tail of the server log file.\n *\n * @param {Object} [query] Query parameters.\n * @param {Integer} [query.bytes] Number of bytes to read.\n * @param {Integer} [query.offset] Number of bytes from the end of\n * log file to start reading.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetLog|CouchDB Wiki}\n */\n\nClient.prototype.log = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\", \"_log\");\n};\n\n/**\n * List running tasks.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetActiveTasks|CouchDB Wiki}\n */\n\nClient.prototype.tasks = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\", \"_active_tasks\");\n};\n\n/**\n * Get or set configuration values.\n *\n * @param {String} [key] Configuration section or key.\n * @param {String} [value] Configuration value.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nClient.prototype.config = function (/* [key], [value], [query], [headers], [callback] */) {\n var args = [].slice.call(arguments);\n var key = isString(args[0]) && args.shift() || \"\";\n var value = isString(args[0]) && args.shift();\n var method = isString(value) ? \"PUT\" : \"GET\";\n return this._(args)(method, \"_config/\" + key, { b: value });\n};\n\n/**\n * Replicate databases.\n *\n * @param {Object} options Options.\n * @param {String} options.source Source database URL or local name.\n * @param {String} options.target Target database URL or local name.\n * @param {Boolean} [options.cancel] Set to `true` to cancel replication.\n * @param {Boolean} [options.continuous] Set to `true` for continuous\n * replication.\n * @param {Boolean} [options.create_target] Set to `true` to create the\n * target database.\n * @param {String} [options.filter] Filter name for filtered replication.\n * Example: \"mydesign/myfilter\".\n * @param {Object} [options.query] Query parameters for filter.\n * @param {String[]} [options.doc_ids] Document IDs to replicate.\n * @param {String} [options.proxy] Proxy through which to replicate.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/Replication|CouchDB Wiki}\n */\n\nClient.prototype.replicate = function (options /* [query], [headers], [callback] */) {\n return this._(arguments, 1)(\"POST\", \"_replicate\", { b: options });\n};\n\n/**\n * Methods for CouchDB database.\n *\n * @param {Client} client Clerk client.\n * @param {String} name DB name.\n * @param {String} [auth] Authentication header value.\n * @constructor\n * @memberof clerk\n * @return This object for chaining.\n */\n\nfunction DB (client, name, auth) {\n this.client = client;\n this.name = name;\n this.uri = client.uri + \"/\" + encodeURIComponent(name);\n this.auth = auth;\n};\n\nDB.prototype = new Base();\n\n/**\n * Create database.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.create = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"PUT\");\n};\n\n/**\n * Destroy database.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.destroy = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"DELETE\");\n};\n\n/**\n * Get database info.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.info = function (/* [query], [headers], callback */) {\n return this._(arguments)(\"GET\");\n};\n\n/**\n * Check if database exists.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.exists = function (/* [query], [headers], callback */) {\n var request = this._(arguments);\n request._ = function (err, body, status, headers, req) {\n return [err, status === 200, status, headers, req];\n };\n return request(\"HEAD\");\n};\n\n/**\n * Fetch document.\n *\n * Set `rev` in `query`.\n *\n * @param {String} id Document ID.\n * @param {Object} [query] HTTP query options.\n * @param {Boolean} [query.revs] Fetch list of revisions.\n * @param {Boolean} [query.revs_info] Fetch detailed revision information.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#GET|CouchDB Wiki}\n */\n\nDB.prototype.get = function (/* [id], [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\");\n};\n\n/**\n * Get document metadata.\n *\n * @param {String} id Document ID.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#HEAD|CouchDB Wiki}\n */\n\nDB.prototype.head = function (/* [id], [query], [headers], callback */) {\n var self = this;\n var request = self._(arguments);\n request._ = function (err, body, status, headers, res) {\n return [err, err ? null : {\n _id: request.p,\n _rev: headers.etag && JSON.parse(headers.etag),\n contentType: headers[\"content-type\"],\n contentLength: headers[\"content-length\"]\n }, status, headers, res];\n };\n return request(\"HEAD\");\n};\n\n/**\n * Post document(s) to database.\n *\n * If documents have no ID, a document ID will be automatically generated\n * on the server. Attachments are not currently supported.\n *\n * @param {Object|Object[]} doc Document or array of documents.\n * @param {String} [doc._id] Document ID. If set, uses given document ID.\n * @param {String} [doc._rev] Document revision. If set, allows update to\n * existing document.\n * @param {Object} [doc._attachments] Attachments. If given, must be a\n * map of filenames to attachment properties.\n * @param {String} [doc._attachments[filename]] Attachment filename, as\n * hash key.\n * @param {String} [doc._attachments[filename].contentType] Attachment\n * MIME content type.\n * @param {String|Object} [doc._attachments[filename].data] Attachment\n * data. Will be Base64 encoded.\n * @param {Object} [query] HTTP query options.\n * @param {Boolean} [query.batch] Allow server to write document in\n * batch mode. Documents will not be written to disk immediately,\n * increasing the chances of write failure.\n * @param {Boolean} [query.all_or_nothing] For batch updating of\n * documents, use all-or-nothing semantics.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#POST|CouchDB Wiki}\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API|CouchDB Wiki}\n */\n\nDB.prototype.post = function (docs /* [query], [headers], [callback] */) {\n var request = this._(arguments, 1);\n if (isArray(docs)) {\n request.p = \"_bulk_docs\";\n request.b = extend({ docs: docs }, request.q);\n request.q = null\n } else {\n request.b = docs;\n }\n return request(\"POST\");\n};\n\n/**\n * Put document in database.\n *\n * @param {Object} doc Document data. Requires `_id` and `_rev`.\n * @param {String} [options] Options.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#PUT|CouchDB Wiki}\n */\n\nDB.prototype.put = function (/* [id], [doc], [query], [headers], [callback] */) {\n var request = this._(arguments, 0, 1);\n // prevent acidentally creating database\n if (!request.p) request.p = request.b._id || request.b.id;\n if (!request.p) throw new Error(\"missing id\");\n return request(\"PUT\");\n};\n\n/**\n * Delete document(s).\n *\n * @param {Object|Object[]} docs Document or array of documents.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#DELETE|CouchDB Wiki}\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API|CouchDB Wiki}\n */\n\nDB.prototype.del = function (docs /* [query], [headers], [callback] */) {\n if (isArray(docs)) {\n var i = 0, len = docs.length, doc;\n for (; i < len; i++) {\n doc = docs[i], docs[i] = {\n _id: doc._id || doc.id,\n _rev: doc._rev || doc.rev,\n _deleted: true\n };\n }\n return this.post.apply(this, arguments);\n } else {\n var request = this._(arguments, 0, 1);\n // prevent acidentally deleting database\n if (!request.p) throw new Error(\"missing id\");\n return request(\"DELETE\");\n }\n};\n\n/**\n * Copy document.\n *\n * @param {Object} source Source document.\n * @param {String} source.id Source document ID.\n * @param {String} [source.rev] Source document revision.\n * @param {String} [source._id] Source document ID. Alternate key for\n * `source.id`.\n * @param {String} [source._rev] Source document revision. Alternate key\n * for `source.id`.\n * @param {Object} target Target document.\n * @param {String} target.id Target document ID.\n * @param {String} [target.rev] Target document revision.\n * @param {String} [target._id] Target document ID. Alternate key for\n * `target.id`.\n * @param {String} [target._rev] Target document revision. Alternate key\n * for `target.id`.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#COPY|CouchDB Wiki}\n */\n\nDB.prototype.copy = function (source, target /* [query], [headers], [callback] */) {\n var request = this._(arguments, 2);\n var sourcePath = encodeURIComponent(source.id || source._id || source);\n var targetPath = encodeURIComponent(target.id || target._id || target);\n var sourceRev = source.rev || source._rev;\n var targetRev = target.rev || target._rev;\n\n if (sourceRev) request.q.rev = sourceRev;\n if (targetRev) targetPath += \"?rev=\" + encodeURIComponent(targetRev);\n\n request.h.Destination = targetPath;\n\n return request(\"COPY\", sourcePath);\n};\n\n/**\n * Query all documents by ID.\n *\n * @param {Object} [query] HTTP query options.\n * @param {JSON} [query.startkey] Start returning results from this\n * document ID.\n * @param {JSON} [query.endkey] Stop returning results at this document\n * ID.\n * @param {Integer} [query.limit] Limit number of results returned.\n * @param {Boolean} [query.descending=false] Lookup results in reverse\n * order by key, returning documents in descending order by key.\n * @param {Integer} [query.skip] Skip this many records before\n * returning results.\n * @param {Boolean} [query.include_docs=false] Include document source for\n * each result.\n * @param {Boolean} [query.include_end=true] Include `query.endkey`\n * in results.\n * @param {Boolean} [query.update_seq=false] Include sequence value\n * of the database corresponding to the view.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API|CouchDB Wiki}\n */\n\nDB.prototype.all = function (/* [query], [headers], [callback] */) {\n var request = this._(arguments);\n var body = this._viewOptions(request.q);\n return request(body ? \"POST\" : \"GET\", \"_all_docs\", { b: body });\n};\n\n/**\n * Query a view.\n *\n * @param {String|Object} view View name (e.g. mydesign/myview) or\n * temporary view definition. Using a temporary view is strongly not\n * recommended for production use.\n * @param {Object} [query] HTTP query options.\n * @param {JSON} [query.key] Key to lookup.\n * @param {JSON} [query.startkey] Start returning results from this key.\n * @param {String} [query.startkey_docid] Start returning results\n * from this document ID. Allows pagination with duplicate keys.\n * @param {JSON} [query.endkey] Stop returning results at this key.\n * @param {String} [query.endkey_docid] Stop returning results at\n * this document ID. Allows pagination with duplicate keys.\n * @param {Integer} [query.limit] Limit number of results returned.\n * @param {Boolean|String} [query.stale] Do not refresh view even if\n * stale. For CouchDB versions `1.1.0` and up, set to `update_after` to\n * update view after results are returned.\n * @param {Boolean} [query.descending=false] Lookup results in reverse\n * order by key, returning documents in descending order by key.\n * @param {Integer} [query.skip] Skip this many records before\n * returning results.\n * @param {Boolean|Integer} [query.group=false] Use the reduce function\n * to group results by key. Set to an integer specify `group_level`.\n * @param {Boolean|Integer} [query.reduce=true] Use the reduce function.\n * @param {Boolean} [query.fetch=false] Include document source for\n * each result.\n * @param {Boolean} [query.include_end=true] Include `query.endkey`\n * in results.\n * @param {Boolean} [query.update_seq=false] Include sequence value\n * of the database corresponding to the view.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_view_API|CouchDB Wiki}\n */\n\nDB.prototype.find = function (view /* [query], [headers], [callback] */) {\n var request = this._(arguments, 1), path, body;\n\n if (isString(view)) {\n path = view.split(\"/\", 2);\n path = \"_design/\" + encodeURIComponent(path[0]) +\n \"/_view/\" + encodeURIComponent(path[1]);\n } else {\n path = \"_temp_view\";\n body = view;\n }\n\n body = this._viewOptions(request.q, body);\n return request(body ? \"POST\" : \"GET\", path, { b: body });\n};\n\n/**\n * Get database changes.\n *\n * The `feed` option determines how the callback is called:\n *\n * - `normal` calls the callback once.\n * - `longpoll` waits for a response, then calls the callback once.\n * - `continuous` calls the callback each time an update is received.\n * Implemented as the `database#follow()` method.\n *\n * @param {Object} [query] HTTP query options.\n * @param {String} [query.feed=\"normal\"] Type of feed. See comments\n * above.\n * @param {String} [query.filter] Filter updates using this filter.\n * @param {Integer} [query.limit] Maximum number of rows to return.\n * @param {Integer} [query.since=0] Start results from this sequence\n * number.\n * @param {Boolean} [query.include_docs=false] Include documents with\n * results.\n * @param {Integer} [query.timeout=1000] Maximum period in milliseconds\n * to wait for a change before sending a response, even if there are no\n * results.\n * @param {Integer} [query.heartbeat=1000] Period in milliseconds after\n * which an empty line is sent. Applicable only to feed types\n * `longpoll` and `continuous`. Overrides `query.timeout` to keep the\n * feed alive indefinitely.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_database_API#Changes|CouchDB Wiki}\n */\n\nDB.prototype.changes = function (/* [query], [headers], [callback] */) {\n var request = this._(arguments);\n if (request.q.feed != \"longpoll\") delete request.q.feed;\n return this._changes(request);\n};\n\n/**\n * Follow database changes.\n *\n * @see `#changes()`.\n */\n\nDB.prototype.follow = function (/* [query], [headers], callback */) {\n var self = this;\n var request = this._(arguments);\n var fn = request.f;\n\n if (!fn) return this;\n\n request.q.feed = \"longpoll\";\n request.f = function (err, body) {\n var args = [].slice.call(arguments);\n var done, i;\n for (i = 0; i < body.length; i++) {\n args[1] = body[i];\n if (done = fn.apply(self, args) === false || err) break;\n }\n if (!done) self._changes(request);\n };\n\n return this._changes(request);\n};\n\n/**\n * Service a changes request.\n *\n * @private\n */\n\nDB.prototype._changes = function (request) {\n return request(\"GET\", \"_changes\");\n};\n\n/**\n * Update document using server-side handler.\n *\n * @param {String} handler Update handler. Example: mydesign/myhandler\n * @param {String} [id] Document ID.\n * @param {Object} [query] HTTP query options.\n * @param {Object|String} [data] Data.\n * @param {Object} [headers] Headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/Document_Update_Handlers|CouchDB Wiki}\n */\n\nDB.prototype.update = function (handler /* [id], [data], [query], [headers], [callback] */) {\n var request = this._(arguments, 1, 1);\n var path = handler.split(\"/\", 2);\n\n path = \"_design/\" + encodeURIComponent(path[0]) +\n \"/_update/\" + encodeURIComponent(path[1]);\n\n if (request.p) path += \"/\" + request.p;\n\n return request(\"POST\", path);\n};\n\n/**\n * Download attachment from document.\n *\n * @param {Object|String} docOrId Document or document ID.\n * @param {String} attachmentName Attachment name.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.attachment = function (doc, attachmentName /* [query], [headers], [callback] */) {\n var request = this._(arguments, 2);\n var path = encodeURIComponent(doc._id || doc.id || doc) + \"/\" +\n encodeURIComponent(attachmentName);\n return request(\"GET\", path, options);\n};\n\n/**\n * Upload attachment to document.\n *\n * Set the `Content-Type` header.\n *\n * @param {Object} [doc] Document. Requires `id`. `rev` can be specified\n * here or in `query`.\n * @param {String} attachmentName Attachment name.\n * @param {Object} data Data.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.attach = function (doc, attachmentName, data /* [query], [headers], [callback] */) {\n var request = this._(arguments, 3);\n request.p = encodeURIComponent(doc._id || doc.id) + \"/\" +\n encodeURIComponent(attachmentName);\n if (!request.q.rev) request.q.rev = doc._rev || doc.rev;\n request.q.body = data;\n return request(\"PUT\", path);\n};\n\n/**\n * Replicate database.\n *\n * This convenience function sets `options.source` and `options.target` to\n * the selected database name. Either `options.source` or `options.target`\n * must be overridden for a successful replication request.\n *\n * @param {Options} options Options. Accepts all options from\n * `Client.replicate()`.\n * @param {String} [options.source=this.name] Source database URL or\n * local name. Defaults to the selected database name if not given.\n * @param {String} [options.target=this.name] Target database URL or\n * local name. Defaults to the selected database name if not given.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.replicate = function (options /* [query], [headers], [callback] */) {\n if (!options.source) options.source = this.name;\n if (!options.target) options.target = this.name;\n return this.client.replicate.apply(this.client, arguments);\n};\n\n/**\n * Ensure recent changes are committed to disk.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.commit = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"POST\", \"_ensure_full_commit\");\n};\n\n/**\n * Purge deleted documents from database.\n *\n * @param {Object} revs Map of document IDs to revisions to be purged.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.purge = function (revs /* [query], [headers], [callback] */) {\n return this._(arguments, 1)(\"POST\", \"_purge\", { b: revs });\n};\n\n/**\n * Compact database or design.\n *\n * @param {String} [design] Design name if compacting design indexes.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/Compaction|CouchDB Wiki}\n */\n\nDB.prototype.compact = function (/* [design], [query], [headers], [callback] */) {\n var request = this._(arguments);\n return request(\"POST\", \"_compact/\" + (request.p || \"\"));\n};\n\n/**\n * Remove unused views.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/Compaction|CouchDB Wiki}\n */\n\nDB.prototype.vacuum = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"POST\", \"_view_cleanup\");\n};\n\n/**\n * Parse view options.\n *\n * @param {Object} query The HTTP query options.\n * @param {Object} body The body payload.\n * @param {handler} [callback] Callback function.\n * @return {Object} The body payload.\n * @private\n */\n\nDB.prototype._viewOptions = function (q, body) {\n if (q) {\n if (q.key) q.key = JSON.stringify(q.key);\n if (q.startkey) q.startkey = JSON.stringify(q.startkey);\n if (q.endkey) q.endkey = JSON.stringify(q.endkey);\n if (q.stale && q.stale != \"update_after\") q.stale = \"ok\";\n if (q.keys) {\n if (!body) body = {};\n body.keys = q.keys;\n delete q.keys;\n }\n }\n return body;\n};\n\n/**\n * Handle a clerk response.\n *\n * @callback handler\n * @param {Error|null} error Error or `null` on success.\n * @param {Object} data Response data.\n * @param {Integer} status Response status code.\n * @param {Object} headers Response headers.\n * @param {superagent.Response} res Superagent response object.\n */\n\nclerk.Base = Base;\nclerk.Client = Client;\nclerk.DB = DB;\n\n// Export clerk.\nmodule.exports = clerk;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./clerk.js\n ** module id = 0\n ** module chunks = 0\n **/","/**\n * Module dependencies.\n */\n\nvar Emitter = require('emitter');\nvar reduce = require('reduce');\n\n/**\n * Root reference for iframes.\n */\n\nvar root = 'undefined' == typeof window\n ? this\n : window;\n\n/**\n * Noop.\n */\n\nfunction noop(){};\n\n/**\n * Check if `obj` is a host object,\n * we don't want to serialize these :)\n *\n * TODO: future proof, move to compoent land\n *\n * @param {Object} obj\n * @return {Boolean}\n * @api private\n */\n\nfunction isHost(obj) {\n var str = {}.toString.call(obj);\n\n switch (str) {\n case '[object File]':\n case '[object Blob]':\n case '[object FormData]':\n return true;\n default:\n return false;\n }\n}\n\n/**\n * Determine XHR.\n */\n\nfunction getXHR() {\n if (root.XMLHttpRequest\n && ('file:' != root.location.protocol || !root.ActiveXObject)) {\n return new XMLHttpRequest;\n } else {\n try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) {}\n }\n return false;\n}\n\n/**\n * Removes leading and trailing whitespace, added to support IE.\n *\n * @param {String} s\n * @return {String}\n * @api private\n */\n\nvar trim = ''.trim\n ? function(s) { return s.trim(); }\n : function(s) { return s.replace(/(^\\s*|\\s*$)/g, ''); };\n\n/**\n * Check if `obj` is an object.\n *\n * @param {Object} obj\n * @return {Boolean}\n * @api private\n */\n\nfunction isObject(obj) {\n return obj === Object(obj);\n}\n\n/**\n * Serialize the given `obj`.\n *\n * @param {Object} obj\n * @return {String}\n * @api private\n */\n\nfunction serialize(obj) {\n if (!isObject(obj)) return obj;\n var pairs = [];\n for (var key in obj) {\n if (null != obj[key]) {\n pairs.push(encodeURIComponent(key)\n + '=' + encodeURIComponent(obj[key]));\n }\n }\n return pairs.join('&');\n}\n\n/**\n * Expose serialization method.\n */\n\n request.serializeObject = serialize;\n\n /**\n * Parse the given x-www-form-urlencoded `str`.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\nfunction parseString(str) {\n var obj = {};\n var pairs = str.split('&');\n var parts;\n var pair;\n\n for (var i = 0, len = pairs.length; i < len; ++i) {\n pair = pairs[i];\n parts = pair.split('=');\n obj[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]);\n }\n\n return obj;\n}\n\n/**\n * Expose parser.\n */\n\nrequest.parseString = parseString;\n\n/**\n * Default MIME type map.\n *\n * superagent.types.xml = 'application/xml';\n *\n */\n\nrequest.types = {\n html: 'text/html',\n json: 'application/json',\n xml: 'application/xml',\n urlencoded: 'application/x-www-form-urlencoded',\n 'form': 'application/x-www-form-urlencoded',\n 'form-data': 'application/x-www-form-urlencoded'\n};\n\n/**\n * Default serialization map.\n *\n * superagent.serialize['application/xml'] = function(obj){\n * return 'generated xml here';\n * };\n *\n */\n\n request.serialize = {\n 'application/x-www-form-urlencoded': serialize,\n 'application/json': JSON.stringify\n };\n\n /**\n * Default parsers.\n *\n * superagent.parse['application/xml'] = function(str){\n * return { object parsed from str };\n * };\n *\n */\n\nrequest.parse = {\n 'application/x-www-form-urlencoded': parseString,\n 'application/json': JSON.parse\n};\n\n/**\n * Parse the given header `str` into\n * an object containing the mapped fields.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\nfunction parseHeader(str) {\n var lines = str.split(/\\r?\\n/);\n var fields = {};\n var index;\n var line;\n var field;\n var val;\n\n lines.pop(); // trailing CRLF\n\n for (var i = 0, len = lines.length; i < len; ++i) {\n line = lines[i];\n index = line.indexOf(':');\n field = line.slice(0, index).toLowerCase();\n val = trim(line.slice(index + 1));\n fields[field] = val;\n }\n\n return fields;\n}\n\n/**\n * Return the mime type for the given `str`.\n *\n * @param {String} str\n * @return {String}\n * @api private\n */\n\nfunction type(str){\n return str.split(/ *; */).shift();\n};\n\n/**\n * Return header field parameters.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\nfunction params(str){\n return reduce(str.split(/ *; */), function(obj, str){\n var parts = str.split(/ *= */)\n , key = parts.shift()\n , val = parts.shift();\n\n if (key && val) obj[key] = val;\n return obj;\n }, {});\n};\n\n/**\n * Initialize a new `Response` with the given `xhr`.\n *\n * - set flags (.ok, .error, etc)\n * - parse header\n *\n * Examples:\n *\n * Aliasing `superagent` as `request` is nice:\n *\n * request = superagent;\n *\n * We can use the promise-like API, or pass callbacks:\n *\n * request.get('/').end(function(res){});\n * request.get('/', function(res){});\n *\n * Sending data can be chained:\n *\n * request\n * .post('/user')\n * .send({ name: 'tj' })\n * .end(function(res){});\n *\n * Or passed to `.send()`:\n *\n * request\n * .post('/user')\n * .send({ name: 'tj' }, function(res){});\n *\n * Or passed to `.post()`:\n *\n * request\n * .post('/user', { name: 'tj' })\n * .end(function(res){});\n *\n * Or further reduced to a single call for simple cases:\n *\n * request\n * .post('/user', { name: 'tj' }, function(res){});\n *\n * @param {XMLHTTPRequest} xhr\n * @param {Object} options\n * @api private\n */\n\nfunction Response(req, options) {\n options = options || {};\n this.req = req;\n this.xhr = this.req.xhr;\n this.text = this.req.method !='HEAD' \n ? this.xhr.responseText \n : null;\n this.setStatusProperties(this.xhr.status);\n this.header = this.headers = parseHeader(this.xhr.getAllResponseHeaders());\n // getAllResponseHeaders sometimes falsely returns \"\" for CORS requests, but\n // getResponseHeader still works. so we get content-type even if getting\n // other headers fails.\n this.header['content-type'] = this.xhr.getResponseHeader('content-type');\n this.setHeaderProperties(this.header);\n this.body = this.req.method != 'HEAD'\n ? this.parseBody(this.text)\n : null;\n}\n\n/**\n * Get case-insensitive `field` value.\n *\n * @param {String} field\n * @return {String}\n * @api public\n */\n\nResponse.prototype.get = function(field){\n return this.header[field.toLowerCase()];\n};\n\n/**\n * Set header related properties:\n *\n * - `.type` the content type without params\n *\n * A response of \"Content-Type: text/plain; charset=utf-8\"\n * will provide you with a `.type` of \"text/plain\".\n *\n * @param {Object} header\n * @api private\n */\n\nResponse.prototype.setHeaderProperties = function(header){\n // content-type\n var ct = this.header['content-type'] || '';\n this.type = type(ct);\n\n // params\n var obj = params(ct);\n for (var key in obj) this[key] = obj[key];\n};\n\n/**\n * Parse the given body `str`.\n *\n * Used for auto-parsing of bodies. Parsers\n * are defined on the `superagent.parse` object.\n *\n * @param {String} str\n * @return {Mixed}\n * @api private\n */\n\nResponse.prototype.parseBody = function(str){\n var parse = request.parse[this.type];\n return parse && str && str.length\n ? parse(str)\n : null;\n};\n\n/**\n * Set flags such as `.ok` based on `status`.\n *\n * For example a 2xx response will give you a `.ok` of __true__\n * whereas 5xx will be __false__ and `.error` will be __true__. The\n * `.clientError` and `.serverError` are also available to be more\n * specific, and `.statusType` is the class of error ranging from 1..5\n * sometimes useful for mapping respond colors etc.\n *\n * \"sugar\" properties are also defined for common cases. Currently providing:\n *\n * - .noContent\n * - .badRequest\n * - .unauthorized\n * - .notAcceptable\n * - .notFound\n *\n * @param {Number} status\n * @api private\n */\n\nResponse.prototype.setStatusProperties = function(status){\n var type = status / 100 | 0;\n\n // status / class\n this.status = status;\n this.statusType = type;\n\n // basics\n this.info = 1 == type;\n this.ok = 2 == type;\n this.clientError = 4 == type;\n this.serverError = 5 == type;\n this.error = (4 == type || 5 == type)\n ? this.toError()\n : false;\n\n // sugar\n this.accepted = 202 == status;\n this.noContent = 204 == status || 1223 == status;\n this.badRequest = 400 == status;\n this.unauthorized = 401 == status;\n this.notAcceptable = 406 == status;\n this.notFound = 404 == status;\n this.forbidden = 403 == status;\n};\n\n/**\n * Return an `Error` representative of this response.\n *\n * @return {Error}\n * @api public\n */\n\nResponse.prototype.toError = function(){\n var req = this.req;\n var method = req.method;\n var url = req.url;\n\n var msg = 'cannot ' + method + ' ' + url + ' (' + this.status + ')';\n var err = new Error(msg);\n err.status = this.status;\n err.method = method;\n err.url = url;\n\n return err;\n};\n\n/**\n * Expose `Response`.\n */\n\nrequest.Response = Response;\n\n/**\n * Initialize a new `Request` with the given `method` and `url`.\n *\n * @param {String} method\n * @param {String} url\n * @api public\n */\n\nfunction Request(method, url) {\n var self = this;\n Emitter.call(this);\n this._query = this._query || [];\n this.method = method;\n this.url = url;\n this.header = {};\n this._header = {};\n this.on('end', function(){\n var err = null;\n var res = null;\n\n try {\n res = new Response(self); \n } catch(e) {\n err = new Error('Parser is unable to parse the response');\n err.parse = true;\n err.original = e;\n }\n\n self.callback(err, res);\n });\n}\n\n/**\n * Mixin `Emitter`.\n */\n\nEmitter(Request.prototype);\n\n/**\n * Allow for extension\n */\n\nRequest.prototype.use = function(fn) {\n fn(this);\n return this;\n}\n\n/**\n * Set timeout to `ms`.\n *\n * @param {Number} ms\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.timeout = function(ms){\n this._timeout = ms;\n return this;\n};\n\n/**\n * Clear previous timeout.\n *\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.clearTimeout = function(){\n this._timeout = 0;\n clearTimeout(this._timer);\n return this;\n};\n\n/**\n * Abort the request, and clear potential timeout.\n *\n * @return {Request}\n * @api public\n */\n\nRequest.prototype.abort = function(){\n if (this.aborted) return;\n this.aborted = true;\n this.xhr.abort();\n this.clearTimeout();\n this.emit('abort');\n return this;\n};\n\n/**\n * Set header `field` to `val`, or multiple fields with one object.\n *\n * Examples:\n *\n * req.get('/')\n * .set('Accept', 'application/json')\n * .set('X-API-Key', 'foobar')\n * .end(callback);\n *\n * req.get('/')\n * .set({ Accept: 'application/json', 'X-API-Key': 'foobar' })\n * .end(callback);\n *\n * @param {String|Object} field\n * @param {String} val\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.set = function(field, val){\n if (isObject(field)) {\n for (var key in field) {\n this.set(key, field[key]);\n }\n return this;\n }\n this._header[field.toLowerCase()] = val;\n this.header[field] = val;\n return this;\n};\n\n/**\n * Remove header `field`.\n *\n * Example:\n *\n * req.get('/')\n * .unset('User-Agent')\n * .end(callback);\n *\n * @param {String} field\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.unset = function(field){\n delete this._header[field.toLowerCase()];\n delete this.header[field];\n return this;\n};\n\n/**\n * Get case-insensitive header `field` value.\n *\n * @param {String} field\n * @return {String}\n * @api private\n */\n\nRequest.prototype.getHeader = function(field){\n return this._header[field.toLowerCase()];\n};\n\n/**\n * Set Content-Type to `type`, mapping values from `request.types`.\n *\n * Examples:\n *\n * superagent.types.xml = 'application/xml';\n *\n * request.post('/')\n * .type('xml')\n * .send(xmlstring)\n * .end(callback);\n *\n * request.post('/')\n * .type('application/xml')\n * .send(xmlstring)\n * .end(callback);\n *\n * @param {String} type\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.type = function(type){\n this.set('Content-Type', request.types[type] || type);\n return this;\n};\n\n/**\n * Set Accept to `type`, mapping values from `request.types`.\n *\n * Examples:\n *\n * superagent.types.json = 'application/json';\n *\n * request.get('/agent')\n * .accept('json')\n * .end(callback);\n *\n * request.get('/agent')\n * .accept('application/json')\n * .end(callback);\n *\n * @param {String} accept\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.accept = function(type){\n this.set('Accept', request.types[type] || type);\n return this;\n};\n\n/**\n * Set Authorization field value with `user` and `pass`.\n *\n * @param {String} user\n * @param {String} pass\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.auth = function(user, pass){\n var str = btoa(user + ':' + pass);\n this.set('Authorization', 'Basic ' + str);\n return this;\n};\n\n/**\n* Add query-string `val`.\n*\n* Examples:\n*\n* request.get('/shoes')\n* .query('size=10')\n* .query({ color: 'blue' })\n*\n* @param {Object|String} val\n* @return {Request} for chaining\n* @api public\n*/\n\nRequest.prototype.query = function(val){\n if ('string' != typeof val) val = serialize(val);\n if (val) this._query.push(val);\n return this;\n};\n\n/**\n * Write the field `name` and `val` for \"multipart/form-data\"\n * request bodies.\n *\n * ``` js\n * request.post('/upload')\n * .field('foo', 'bar')\n * .end(callback);\n * ```\n *\n * @param {String} name\n * @param {String|Blob|File} val\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.field = function(name, val){\n if (!this._formData) this._formData = new FormData();\n this._formData.append(name, val);\n return this;\n};\n\n/**\n * Queue the given `file` as an attachment to the specified `field`,\n * with optional `filename`.\n *\n * ``` js\n * request.post('/upload')\n * .attach(new Blob(['hey!'], { type: \"text/html\"}))\n * .end(callback);\n * ```\n *\n * @param {String} field\n * @param {Blob|File} file\n * @param {String} filename\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.attach = function(field, file, filename){\n if (!this._formData) this._formData = new FormData();\n this._formData.append(field, file, filename);\n return this;\n};\n\n/**\n * Send `data`, defaulting the `.type()` to \"json\" when\n * an object is given.\n *\n * Examples:\n *\n * // querystring\n * request.get('/search')\n * .end(callback)\n *\n * // multiple data \"writes\"\n * request.get('/search')\n * .send({ search: 'query' })\n * .send({ range: '1..5' })\n * .send({ order: 'desc' })\n * .end(callback)\n *\n * // manual json\n * request.post('/user')\n * .type('json')\n * .send('{\"name\":\"tj\"})\n * .end(callback)\n *\n * // auto json\n * request.post('/user')\n * .send({ name: 'tj' })\n * .end(callback)\n *\n * // manual x-www-form-urlencoded\n * request.post('/user')\n * .type('form')\n * .send('name=tj')\n * .end(callback)\n *\n * // auto x-www-form-urlencoded\n * request.post('/user')\n * .type('form')\n * .send({ name: 'tj' })\n * .end(callback)\n *\n * // defaults to x-www-form-urlencoded\n * request.post('/user')\n * .send('name=tobi')\n * .send('species=ferret')\n * .end(callback)\n *\n * @param {String|Object} data\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.send = function(data){\n var obj = isObject(data);\n var type = this.getHeader('Content-Type');\n\n // merge\n if (obj && isObject(this._data)) {\n for (var key in data) {\n this._data[key] = data[key];\n }\n } else if ('string' == typeof data) {\n if (!type) this.type('form');\n type = this.getHeader('Content-Type');\n if ('application/x-www-form-urlencoded' == type) {\n this._data = this._data\n ? this._data + '&' + data\n : data;\n } else {\n this._data = (this._data || '') + data;\n }\n } else {\n this._data = data;\n }\n\n if (!obj) return this;\n if (!type) this.type('json');\n return this;\n};\n\n/**\n * Invoke the callback with `err` and `res`\n * and handle arity check.\n *\n * @param {Error} err\n * @param {Response} res\n * @api private\n */\n\nRequest.prototype.callback = function(err, res){\n var fn = this._callback;\n this.clearTimeout();\n if (2 == fn.length) return fn(err, res);\n if (err) return this.emit('error', err);\n fn(res);\n};\n\n/**\n * Invoke callback with x-domain error.\n *\n * @api private\n */\n\nRequest.prototype.crossDomainError = function(){\n var err = new Error('Origin is not allowed by Access-Control-Allow-Origin');\n err.crossDomain = true;\n this.callback(err);\n};\n\n/**\n * Invoke callback with timeout error.\n *\n * @api private\n */\n\nRequest.prototype.timeoutError = function(){\n var timeout = this._timeout;\n var err = new Error('timeout of ' + timeout + 'ms exceeded');\n err.timeout = timeout;\n this.callback(err);\n};\n\n/**\n * Enable transmission of cookies with x-domain requests.\n *\n * Note that for this to work the origin must not be\n * using \"Access-Control-Allow-Origin\" with a wildcard,\n * and also must set \"Access-Control-Allow-Credentials\"\n * to \"true\".\n *\n * @api public\n */\n\nRequest.prototype.withCredentials = function(){\n this._withCredentials = true;\n return this;\n};\n\n/**\n * Initiate request, invoking callback `fn(res)`\n * with an instanceof `Response`.\n *\n * @param {Function} fn\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.end = function(fn){\n var self = this;\n var xhr = this.xhr = getXHR();\n var query = this._query.join('&');\n var timeout = this._timeout;\n var data = this._formData || this._data;\n\n // store callback\n this._callback = fn || noop;\n\n // state change\n xhr.onreadystatechange = function(){\n if (4 != xhr.readyState) return;\n if (0 == xhr.status) {\n if (self.aborted) return self.timeoutError();\n return self.crossDomainError();\n }\n self.emit('end');\n };\n\n // progress\n if (xhr.upload) {\n xhr.upload.onprogress = function(e){\n e.percent = e.loaded / e.total * 100;\n self.emit('progress', e);\n };\n }\n\n // timeout\n if (timeout && !this._timer) {\n this._timer = setTimeout(function(){\n self.abort();\n }, timeout);\n }\n\n // querystring\n if (query) {\n query = request.serializeObject(query);\n this.url += ~this.url.indexOf('?')\n ? '&' + query\n : '?' + query;\n }\n\n // initiate request\n xhr.open(this.method, this.url, true);\n\n // CORS\n if (this._withCredentials) xhr.withCredentials = true;\n\n // body\n if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !isHost(data)) {\n // serialize stuff\n var serialize = request.serialize[this.getHeader('Content-Type')];\n if (serialize) data = serialize(data);\n }\n\n // set header fields\n for (var field in this.header) {\n if (null == this.header[field]) continue;\n xhr.setRequestHeader(field, this.header[field]);\n }\n\n // send stuff\n this.emit('request', this);\n xhr.send(data);\n return this;\n};\n\n/**\n * Expose `Request`.\n */\n\nrequest.Request = Request;\n\n/**\n * Issue a request:\n *\n * Examples:\n *\n * request('GET', '/users').end(callback)\n * request('/users').end(callback)\n * request('/users', callback)\n *\n * @param {String} method\n * @param {String|Function} url or callback\n * @return {Request}\n * @api public\n */\n\nfunction request(method, url) {\n // callback\n if ('function' == typeof url) {\n return new Request('GET', method).end(url);\n }\n\n // url first\n if (1 == arguments.length) {\n return new Request('GET', method);\n }\n\n return new Request(method, url);\n}\n\n/**\n * GET `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} data or fn\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.get = function(url, data, fn){\n var req = request('GET', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.query(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * HEAD `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} data or fn\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.head = function(url, data, fn){\n var req = request('HEAD', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * DELETE `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.del = function(url, fn){\n var req = request('DELETE', url);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * PATCH `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed} data\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.patch = function(url, data, fn){\n var req = request('PATCH', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * POST `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed} data\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.post = function(url, data, fn){\n var req = request('POST', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * PUT `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} data or fn\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.put = function(url, data, fn){\n var req = request('PUT', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * Expose `request`.\n */\n\nmodule.exports = request;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/superagent/lib/client.js\n ** module id = 1\n ** module chunks = 0\n **/","\n/**\n * Expose `Emitter`.\n */\n\nmodule.exports = Emitter;\n\n/**\n * Initialize a new `Emitter`.\n *\n * @api public\n */\n\nfunction Emitter(obj) {\n if (obj) return mixin(obj);\n};\n\n/**\n * Mixin the emitter properties.\n *\n * @param {Object} obj\n * @return {Object}\n * @api private\n */\n\nfunction mixin(obj) {\n for (var key in Emitter.prototype) {\n obj[key] = Emitter.prototype[key];\n }\n return obj;\n}\n\n/**\n * Listen on the given `event` with `fn`.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.on =\nEmitter.prototype.addEventListener = function(event, fn){\n this._callbacks = this._callbacks || {};\n (this._callbacks[event] = this._callbacks[event] || [])\n .push(fn);\n return this;\n};\n\n/**\n * Adds an `event` listener that will be invoked a single\n * time then automatically removed.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.once = function(event, fn){\n var self = this;\n this._callbacks = this._callbacks || {};\n\n function on() {\n self.off(event, on);\n fn.apply(this, arguments);\n }\n\n on.fn = fn;\n this.on(event, on);\n return this;\n};\n\n/**\n * Remove the given callback for `event` or all\n * registered callbacks.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.off =\nEmitter.prototype.removeListener =\nEmitter.prototype.removeAllListeners =\nEmitter.prototype.removeEventListener = function(event, fn){\n this._callbacks = this._callbacks || {};\n\n // all\n if (0 == arguments.length) {\n this._callbacks = {};\n return this;\n }\n\n // specific event\n var callbacks = this._callbacks[event];\n if (!callbacks) return this;\n\n // remove all handlers\n if (1 == arguments.length) {\n delete this._callbacks[event];\n return this;\n }\n\n // remove specific handler\n var cb;\n for (var i = 0; i < callbacks.length; i++) {\n cb = callbacks[i];\n if (cb === fn || cb.fn === fn) {\n callbacks.splice(i, 1);\n break;\n }\n }\n return this;\n};\n\n/**\n * Emit `event` with the given args.\n *\n * @param {String} event\n * @param {Mixed} ...\n * @return {Emitter}\n */\n\nEmitter.prototype.emit = function(event){\n this._callbacks = this._callbacks || {};\n var args = [].slice.call(arguments, 1)\n , callbacks = this._callbacks[event];\n\n if (callbacks) {\n callbacks = callbacks.slice(0);\n for (var i = 0, len = callbacks.length; i < len; ++i) {\n callbacks[i].apply(this, args);\n }\n }\n\n return this;\n};\n\n/**\n * Return array of callbacks for `event`.\n *\n * @param {String} event\n * @return {Array}\n * @api public\n */\n\nEmitter.prototype.listeners = function(event){\n this._callbacks = this._callbacks || {};\n return this._callbacks[event] || [];\n};\n\n/**\n * Check if this emitter has `event` handlers.\n *\n * @param {String} event\n * @return {Boolean}\n * @api public\n */\n\nEmitter.prototype.hasListeners = function(event){\n return !! this.listeners(event).length;\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/superagent/~/component-emitter/index.js\n ** module id = 2\n ** module chunks = 0\n **/","\n/**\n * Reduce `arr` with `fn`.\n *\n * @param {Array} arr\n * @param {Function} fn\n * @param {Mixed} initial\n *\n * TODO: combatible error handling?\n */\n\nmodule.exports = function(arr, fn, initial){ \n var idx = 0;\n var len = arr.length;\n var curr = arguments.length == 3\n ? initial\n : arr[idx++];\n\n while (idx < len) {\n curr = fn.call(null, curr, arr[idx], ++idx, arr);\n }\n \n return curr;\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/superagent/~/reduce-component/index.js\n ** module id = 3\n ** module chunks = 0\n **/"],"sourceRoot":"","file":"clerk.js"} \ No newline at end of file diff --git a/dist/clerk.min.js b/dist/clerk.min.js index 9792192..2293923 100644 --- a/dist/clerk.min.js +++ b/dist/clerk.min.js @@ -16,5 +16,5 @@ See the License for the specific language governing permissions and limitations under the License. */ -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.7.2",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||t.text)&&(e.error?r=n._error(e):e=n._response(e)),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;si;++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;on;++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=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;si;++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;on;++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}}]); //# sourceMappingURL=clerk.min.js.map \ No newline at end of file diff --git a/dist/clerk.min.js.map b/dist/clerk.min.js.map index e715773..37216e8 100644 --- a/dist/clerk.min.js.map +++ b/dist/clerk.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///clerk.min.js","webpack:///webpack/bootstrap 56e07271c8805efce757","webpack:///./clerk.js","webpack:///./~/superagent/lib/client.js","webpack:///./~/superagent/~/component-emitter/index.js","webpack:///./~/superagent/~/reduce-component/index.js"],"names":["this","modules","__webpack_require__","moduleId","installedModules","exports","module","id","loaded","call","m","c","p","clerk","uri","make","Base","Client","auth","_db","DB","client","name","encodeURIComponent","request","extend","target","source","key","i","arguments","asString","that","Object","prototype","toString","isString","isArray","isFunction","version","defaultHost","_parseURI","db","exec","path","substr","index","decodeURIComponent","btoa","base","Buffer","str","match","replace","args","slice","callback","length","pop","_request","method","query","data","headers","fn","options","send","g","_","apply","self","_do","body","JSON","stringify","test","_replacer","promise","req","Promise","resolve","reject","err","status","res","defineProperties","_status","value","_headers","_response","abort","Error","set","withCredentials","end","error","text","_error","header","json","len","item","rows","results","uuids","meta","_meta","doc","reason","code","val","proto","hasId","_id","hasRev","_rev","rev","start","withDoc","q","b","h","f","encodeURI","shift","dbs","count","info","stats","log","tasks","config","replicate","create","destroy","exists","get","head","etag","parse","contentType","contentLength","post","docs","put","del","_deleted","copy","sourcePath","targetPath","sourceRev","targetRev","Destination","all","_viewOptions","find","view","split","changes","feed","_changes","follow","done","update","handler","attachment","attachmentName","attach","commit","purge","revs","compact","vacuum","startkey","endkey","stale","keys","noop","isHost","obj","getXHR","root","XMLHttpRequest","location","protocol","ActiveXObject","e","isObject","serialize","pairs","push","join","parseString","parts","pair","parseHeader","line","field","lines","fields","indexOf","toLowerCase","trim","type","params","reduce","Response","xhr","responseText","setStatusProperties","getAllResponseHeaders","getResponseHeader","setHeaderProperties","parseBody","Request","url","Emitter","_query","_header","on","original","window","s","serializeObject","types","html","xml","urlencoded","form","form-data","application/x-www-form-urlencoded","application/json","ct","statusType","ok","clientError","serverError","toError","accepted","noContent","badRequest","unauthorized","notAcceptable","notFound","forbidden","msg","use","timeout","ms","_timeout","clearTimeout","_timer","aborted","emit","unset","getHeader","accept","user","pass","_formData","FormData","append","file","filename","_data","_callback","crossDomainError","crossDomain","timeoutError","_withCredentials","onreadystatechange","readyState","upload","onprogress","percent","total","setTimeout","open","setRequestHeader","patch","mixin","addEventListener","event","_callbacks","once","off","removeListener","removeAllListeners","removeEventListener","callbacks","cb","splice","listeners","hasListeners","arr","initial","idx","curr"],"mappings":"AAAAA,KAAY,MACH,SAAUC,GCGnB,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAE,OAGA,IAAAC,GAAAF,EAAAD,IACAE,WACAE,GAAAJ,EACAK,QAAA,EAUA,OANAP,GAAAE,GAAAM,KAAAH,EAAAD,QAAAC,I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,KAAAqB,UAAA,GACAmQ,EAAAjS,KAAA2R,WAAAD,EAEA,IAAAO,EAAA,CACAA,IAAA1O,MAAA,EACA,QAAA1B,GAAA,EAAAuE,EAAA6L,EAAAxO,OAA2C2C,EAAAvE,IAASA,EACpDoQ,EAAApQ,GAAAwC,MAAArE,KAAAsD,GAIA,MAAAtD,OAWAwN,EAAAtL,UAAAkQ,UAAA,SAAAV,GAEA,MADA1R,MAAA2R,WAAA3R,KAAA2R,eACA3R,KAAA2R,WAAAD,QAWAlE,EAAAtL,UAAAmQ,aAAA,SAAAX,GACA,QAAA1R,KAAAoS,UAAAV,GAAAjO,SJ45EM,SAASnD,GKnjFfA,EAAAD,QAAA,SAAAiS,EAAAtO,EAAAuO,GAOA,IANA,GAAAC,GAAA,EACApM,EAAAkM,EAAA7O,OACAgP,EAAA,GAAA3Q,UAAA2B,OACA8O,EACAD,EAAAE,KAEApM,EAAAoM,GACAC,EAAAzO,EAAAvD,KAAA,KAAAgS,EAAAH,EAAAE,OAAAF,EAGA,OAAAG","file":"clerk.min.js","sourcesContent":["this[\"clerk\"] =\n/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n/*!\n\nclerk - CouchDB client for node and the browser.\nCopyright 2012-2015 Michael Phan-Ba\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n*/\n\n/** @namespace clerk */\n\n/*\n * Module dependencies.\n */\n\nvar request = __webpack_require__(1);\n\n/**\n * Copy properties from sources to target.\n *\n * @param {Object} target The target object.\n * @param {...Object} sources The source object.\n * @return {Object} The target object.\n * @private\n */\n\nvar extend = function (target /* ...sources */) {\n var source, key, i = 1;\n while (source = arguments[i++]) {\n for (key in source) target[key] = source[key];\n }\n return target;\n};\n\n/**\n * Stringify value.\n *\n * @param {Object} that That value to stringify.\n * @return {String} The stringifyed value.\n * @private\n */\n\nvar asString = function (that) {\n return Object.prototype.toString.call(that);\n};\n\n/**\n * Check if value is a string.\n *\n * @param {Object} that That value to check.\n * @return {Boolean} `true` if string, `false` otherwise.\n * @private\n */\n\nvar isString = function (that) {\n return asString(that) == \"[object String]\";\n};\n\n/**\n * Check if value is an object.\n *\n * @param {Object} that That value to check.\n * @return {Boolean} `true` if object, `false` otherwise.\n * @private\n */\n\nvar isObject = function (that) {\n return asString(that) == \"[object Object]\";\n};\n\n/**\n * Check if value is an array.\n *\n * @param {Object} that That value to check.\n * @return {Boolean} `true` if array, `false` otherwise.\n * @private\n */\n\nvar isArray = function (that) {\n return asString(that) == \"[object Array]\";\n};\n\n/**\n * Check if value is a function.\n *\n * @param {Object} that That value to check.\n * @return {Boolean} `true` if function, `false` otherwise.\n * @private\n */\n\nvar isFunction = function (that) {\n return asString(that) == \"[object Function]\";\n};\n\n/**\n * Clerk library entry point.\n *\n * @param {String} uri CouchDB server URI.\n * @return {Client|DB} If a URI path is given, returns a `DB`, otherwise\n * returns a `Client`.\n * @see {@link http://docs.couchdb.org|CouchDB Documentation}\n * @see {@link http://guide.couchdb.org/|CouchDB Guide}\n * @see {@link http://wiki.apache.org/couchdb/|CouchDB Wiki}\n */\n\nfunction clerk (uri) {\n return clerk.make(uri);\n};\n\n/**\n * Library version.\n * @type {String}\n */\n\nclerk.version = \"0.7.2\";\n\n/**\n * Default host.\n * @type {String}\n */\n\nclerk.defaultHost = \"http://127.0.0.1:5984\";\n\n/**\n * Create single CouchDB client.\n *\n * @param {String} uri Fully qualified URI.\n * @return {Client|DB} If `uri` has a path, the last segment of the\n * path is used as the database name and a `DB` instance is\n * returned. Otherwise, a `Client` instance is returned.\n */\n\nclerk.make = function (uri) {\n if (!uri) return new Client(this.defaultHost);\n\n uri = clerk._parseURI(uri);\n\n var db = /\\/*([^\\/]+)\\/*$/.exec(uri.path);\n if (db) {\n uri.path = uri.path.substr(0, db.index);\n db = db[1] && decodeURIComponent(db[1]);\n }\n\n // weird way of doing it, but it's more efficient...\n if (uri.auth) uri.auth = 'Basic ' + clerk.btoa(uri.auth);\n\n var client = new clerk.Client(uri.base + uri.path, uri.auth);\n return db ? client.db(db) : client;\n};\n\n/**\n * Base64-encode a string.\n *\n * @param {String} str\n * @return {String}\n */\n\nclerk.btoa = typeof Buffer != \"undefined\" ? function (str) {\n return new Buffer(str).toString(\"base64\");\n} : function (str) {\n return btoa(str);\n};\n\n/**\n * Parse URI.\n *\n * The URI is normalized by removing extra `//` in the path.\n *\n * @param {String} uri Fully qualified URI.\n * @return {String} The normalized URI.\n * @private\n */\n\nclerk._parseURI = function (uri) {\n var match;\n\n if (uri) {\n if (match = /^(https?:\\/\\/)(?:([^\\/@]+)@)?([^\\/]+)(.*)\\/*$/.exec(uri)) {\n return {\n base: match[1] + match[3].replace(/\\/+/g, \"\\/\"),\n path: match[4],\n auth: match[2] && decodeURIComponent(match[2])\n };\n }\n }\n\n return { base: uri || \"\", path: \"\" };\n};\n\n/**\n * Base prototype for `Client` and `DB`.\n * Encapsulates HTTP methods, JSON handling, and response coersion.\n *\n * @constructor\n */\n\nfunction Base () {};\n\n/**\n * Service request and parse JSON response.\n *\n * @param {String} [method=GET] HTTP method.\n * @param {String} [path=this.uri] HTTP URI.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [body] HTTP body.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nBase.prototype.request = function (/* [method], [path], [query], [body], [headers], [callback] */) {\n var args = [].slice.call(arguments);\n var callback = isFunction (args[args.length - 1]) && args.pop();\n\n return this._request({\n method: args[0],\n path: args[1],\n query: args[2],\n data: args[3],\n headers: args[4],\n fn: callback\n });\n};\n\n/**\n * Internal service request and parse JSON response handler.\n *\n * @param {String} options\n * @param {String} method HTTP method.\n * @param {String} path HTTP URI.\n * @param {Object} query HTTP query options.\n * @param {Object} data HTTP body data.\n * @param {Object} headers HTTP headers.\n * @param {handler} [callback] Callback function.\n * @private\n */\n\nBase.prototype._request = function (options) {\n var self = this;\n\n if (options.method == null) options.method = \"GET\";\n if (options.headers == null) options.headers = {};\n if (options.auth == null) options.auth = this.auth;\n\n options.path = options.path ? \"/\" + options.path : \"\";\n\n // set default headers\n if (options.headers[\"Content-Type\"] == null) {\n options.headers[\"Content-Type\"] = \"application/json\";\n }\n if (options.headers[\"Accept\"] == null) {\n options.headers[\"Accept\"] = \"application/json\";\n }\n if (this.auth && options.headers[\"Authorization\"] == null) {\n options.headers[\"Authorization\"] = this.auth;\n }\n\n options.uri = this.uri + options.path;\n options.body = options.data && JSON.stringify(options.data,\n /^\\/_design/.test(options.path) && this._replacer\n ) || \"\";\n\n // create promise if no callback given\n var promise, req;\n if (!options.fn && typeof Promise != \"undefined\") {\n promise = new Promise(function (resolve, reject) {\n options.fn = function (err, data, status, headers, res) {\n if (err) {\n err.body = data;\n err.status = status;\n err.headers = headers;\n err.res = res;\n reject(err);\n } else {\n if (Object.defineProperties) {\n Object.defineProperties(data, {\n _status: { value: status },\n _headers: { value: headers },\n _response: { value: res },\n });\n }\n resolve(data);\n };\n };\n });\n req = send();\n promise.request = req;\n promise.abort = function () {\n req.abort();\n options.fn(new Error(\"abort\"));\n return promise;\n };\n return promise;\n }\n\n send();\n\n function send () {\n // apply response transforms\n var g = options._;\n var fn = options.fn;\n if (fn) {\n options.fn = g ? function () {\n fn.apply(self, g.apply(self, arguments) || arguments);\n } : fn;\n }\n return self._do(options);\n }\n};\n\n/**\n * Provider for servicing requests and parsing JSON responses.\n *\n * @param {String} options\n * @param {String} method HTTP method.\n * @param {String} uri HTTP URI.\n * @param {Object} query HTTP query options.\n * @param {Object} body HTTP body.\n * @param {Object} headers HTTP headers.\n * @param {Object} auth HTTP authentication.\n * @param {handler} [callback] Callback function.\n * @private\n */\n\nBase.prototype._do = function (options) {\n var self = this;\n var key, value;\n\n // create request\n var req = request(options.method, options.uri);\n\n // query string\n if (options.query) {\n // ensure query Array values are JSON encoded\n for (key in options.query) {\n if (typeof(value = options.query[key]) === \"object\") {\n options.query[key] = JSON.stringify(value);\n }\n }\n // set query on request\n req.query(options.query);\n }\n\n // set headers\n if (options.headers) {\n req.set(options.headers);\n // if authenticating\n if (req.withCredentials && options.headers[\"Authorization\"] != null) {\n req.withCredentials();\n }\n }\n\n // send body\n if (options.body) req.send(options.body);\n\n // send request\n var fn = options.fn;\n req.end(function (res) {\n var err = res.error;\n var data;\n\n if (!err) {\n if (!(data = res.body || res.text)) {}\n else if (data.error) err = self._error(data);\n else data = self._response(data);\n }\n\n res.data = data;\n\n fn && fn(err || null, data, res.status, res.header, res);\n });\n\n return req;\n};\n\n/**\n * Coerce response to normalize access to `_id` and `_rev`.\n *\n * @param {Object} json The response JSON.\n * @return The coerced JSON.\n * @private\n */\n\nBase.prototype._response = function (json) {\n var data = json.rows || json.results || json.uuids || isArray(json) && json;\n var meta = this._meta;\n var i = 0, len, item;\n\n if (data) {\n extend(data, json).json = json;\n for (len = data.length; i < len; i++) {\n item = data[i] = meta(data[i]);\n if (item.doc) item.doc = meta(item.doc);\n }\n } else {\n data = meta(json);\n }\n\n return data;\n};\n\n/**\n * Make an error out of the response.\n *\n * @param {Object} json The response JSON.\n * @return An `Error` object.\n * @private\n */\n\nBase.prototype._error = function (json) {\n var err = new Error(json.reason);\n err.code = json.error;\n return extend(err, json);\n};\n\n/**\n * JSON stringify functions. Used for encoding view documents to JSON.\n *\n * @param {String} key The key to stringify.\n * @param {Object} val The value to stringify.\n * @return {Object} The stringified function value or the value.\n * @private\n */\n\nBase.prototype._replacer = function (key, val) {\n return isFunction (val) ? val.toString() : val;\n};\n\n/**\n * Coerce documents with prototypical `_id` and `_rev`\n * values.\n *\n * @param {Object} doc The document to coerce.\n * @return {Object} The coerced document.\n * @private\n */\n\nBase.prototype._meta = function (doc) {\n var hasId = !doc._id && doc.id;\n var hasRev = !doc._rev && doc.rev;\n var proto;\n\n if (hasId || hasRev) {\n proto = function (){};\n doc = extend(new proto(), doc);\n proto = proto.prototype;\n if (hasId) proto._id = doc.id;\n if (hasRev) proto._rev = doc.rev;\n }\n\n return doc;\n};\n\n/**\n * Parse arguments.\n *\n * @param {Array} args The arguments.\n * @param {Integer} start The index from which to start reading arguments.\n * @param {Boolean} withDoc Set to `true` if the doc source is given as a\n * parameter before HTTP query options.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @private\n */\n\nBase.prototype._ = function (args, start, withDoc) {\n var self = this, doc, id, rev;\n\n function request(method, path, options) {\n if (!options) options = {};\n return self._request({\n method: method,\n path: path || request.p,\n query: options.q || request.q,\n data: options.b || request.b,\n headers: options.h || request.h,\n fn: options.f || request.f,\n _: options._ || request._\n });\n }\n\n // [id], [doc], [query], [header], [callback]\n args = [].slice.call(args, start || 0);\n\n request.f = isFunction(args[args.length - 1]) && args.pop();\n request.p = isString(args[0]) && encodeURI(args.shift());\n request.q = args[withDoc ? 1 : 0] || {};\n request.h = args[withDoc ? 2 : 1] || {};\n\n if (withDoc) {\n if (doc = (request.b = args[0])) {\n if (id = request.p || doc._id || doc.id) request.p = id;\n if (rev = request.q.rev || doc._rev || doc.rev) request.q.rev = rev;\n }\n }\n\n return request;\n};\n\n/**\n * Clerk CouchDB client.\n *\n * @param {String} uri Fully qualified URI.\n * @param {String} [auth] Authentication header value.\n * @constructor\n * @see {@link http://wiki.apache.org/couchdb/Complete_HTTP_API_Reference|CouchDB Wiki}\n */\n\nfunction Client (uri, auth) {\n this.uri = uri;\n this._db = {};\n this.auth = auth;\n};\n\nClient.prototype = new Base();\n\n/**\n * Select database to manipulate.\n *\n * @param {String} name DB name.\n * @return {DB} DB object.\n */\n\nClient.prototype.db = function (name) {\n var db = this._db;\n return db[name] || (db[name] = new DB(this, name, this.auth));\n};\n\n/**\n * List all databases.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetAllDbs|CouchDB Wiki}\n */\n\nClient.prototype.dbs = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\", \"_all_dbs\");\n};\n\n/**\n * Get UUIDs.\n *\n * @param {Integer} [count=1] Number of UUIDs to get.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetUuids|CouchDB Wiki}\n */\n\nClient.prototype.uuids = function (count /* [query], [headers], [callback] */) {\n var request = this._(arguments, +count == count ? 1 : 0);\n if (count > 1) request.q.count = count;\n return request(\"GET\", \"_uuids\");\n};\n\n/**\n * Get server information.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetRoot|CouchDB Wiki}\n */\n\nClient.prototype.info = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\");\n};\n\n/**\n * Get server stats.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetLog|CouchDB Wiki}\n */\n\nClient.prototype.stats = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\", \"_stats\");\n};\n\n/**\n * Get tail of the server log file.\n *\n * @param {Object} [query] Query parameters.\n * @param {Integer} [query.bytes] Number of bytes to read.\n * @param {Integer} [query.offset] Number of bytes from the end of\n * log file to start reading.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetLog|CouchDB Wiki}\n */\n\nClient.prototype.log = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\", \"_log\");\n};\n\n/**\n * List running tasks.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetActiveTasks|CouchDB Wiki}\n */\n\nClient.prototype.tasks = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\", \"_active_tasks\");\n};\n\n/**\n * Get or set configuration values.\n *\n * @param {String} [key] Configuration section or key.\n * @param {String} [value] Configuration value.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nClient.prototype.config = function (/* [key], [value], [query], [headers], [callback] */) {\n var args = [].slice.call(arguments);\n var key = isString(args[0]) && args.shift() || \"\";\n var value = isString(args[0]) && args.shift();\n var method = isString(value) ? \"PUT\" : \"GET\";\n return this._(args)(method, \"_config/\" + key, { b: value });\n};\n\n/**\n * Replicate databases.\n *\n * @param {Object} options Options.\n * @param {String} options.source Source database URL or local name.\n * @param {String} options.target Target database URL or local name.\n * @param {Boolean} [options.cancel] Set to `true` to cancel replication.\n * @param {Boolean} [options.continuous] Set to `true` for continuous\n * replication.\n * @param {Boolean} [options.create_target] Set to `true` to create the\n * target database.\n * @param {String} [options.filter] Filter name for filtered replication.\n * Example: \"mydesign/myfilter\".\n * @param {Object} [options.query] Query parameters for filter.\n * @param {String[]} [options.doc_ids] Document IDs to replicate.\n * @param {String} [options.proxy] Proxy through which to replicate.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/Replication|CouchDB Wiki}\n */\n\nClient.prototype.replicate = function (options /* [query], [headers], [callback] */) {\n return this._(arguments, 1)(\"POST\", \"_replicate\", { b: options });\n};\n\n/**\n * Methods for CouchDB database.\n *\n * @param {Client} client Clerk client.\n * @param {String} name DB name.\n * @param {String} [auth] Authentication header value.\n * @constructor\n * @return This object for chaining.\n */\n\nfunction DB (client, name, auth) {\n this.client = client;\n this.name = name;\n this.uri = client.uri + \"/\" + encodeURIComponent(name);\n this.auth = auth;\n};\n\nDB.prototype = new Base();\n\n/**\n * Create database.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.create = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"PUT\");\n};\n\n/**\n * Destroy database.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.destroy = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"DELETE\");\n};\n\n/**\n * Get database info.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.info = function (/* [query], [headers], callback */) {\n return this._(arguments)(\"GET\");\n};\n\n/**\n * Check if database exists.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.exists = function (/* [query], [headers], callback */) {\n var request = this._(arguments);\n request._ = function (err, body, status, headers, req) {\n return [err, status === 200, status, headers, req];\n };\n return request(\"HEAD\");\n};\n\n/**\n * Fetch document.\n *\n * Set `rev` in `query`.\n *\n * @param {String} id Document ID.\n * @param {Object} [query] HTTP query options.\n * @param {Boolean} [query.revs] Fetch list of revisions.\n * @param {Boolean} [query.revs_info] Fetch detailed revision information.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#GET|CouchDB Wiki}\n */\n\nDB.prototype.get = function (/* [id], [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\");\n};\n\n/**\n * Get document metadata.\n *\n * @param {String} id Document ID.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#HEAD|CouchDB Wiki}\n */\n\nDB.prototype.head = function (/* [id], [query], [headers], callback */) {\n var self = this;\n var request = self._(arguments);\n request._ = function (err, body, status, headers, res) {\n return [err, err ? null : {\n _id: request.p,\n _rev: headers.etag && JSON.parse(headers.etag),\n contentType: headers[\"content-type\"],\n contentLength: headers[\"content-length\"]\n }, status, headers, res];\n };\n return request(\"HEAD\");\n};\n\n/**\n * Post document(s) to database.\n *\n * If documents have no ID, a document ID will be automatically generated\n * on the server. Attachments are not currently supported.\n *\n * @param {Object|Object[]} doc Document or array of documents.\n * @param {String} [doc._id] Document ID. If set, uses given document ID.\n * @param {String} [doc._rev] Document revision. If set, allows update to\n * existing document.\n * @param {Object} [doc._attachments] Attachments. If given, must be a\n * map of filenames to attachment properties.\n * @param {String} [doc._attachments[filename]] Attachment filename, as\n * hash key.\n * @param {String} [doc._attachments[filename].contentType] Attachment\n * MIME content type.\n * @param {String|Object} [doc._attachments[filename].data] Attachment\n * data. Will be Base64 encoded.\n * @param {Object} [query] HTTP query options.\n * @param {Boolean} [query.batch] Allow server to write document in\n * batch mode. Documents will not be written to disk immediately,\n * increasing the chances of write failure.\n * @param {Boolean} [query.all_or_nothing] For batch updating of\n * documents, use all-or-nothing semantics.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#POST|CouchDB Wiki}\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API|CouchDB Wiki}\n */\n\nDB.prototype.post = function (docs /* [query], [headers], [callback] */) {\n var request = this._(arguments, 1);\n if (isArray(docs)) {\n request.p = \"_bulk_docs\";\n request.b = extend({ docs: docs }, request.q);\n request.q = null\n } else {\n request.b = docs;\n }\n return request(\"POST\");\n};\n\n/**\n * Put document in database.\n *\n * @param {Object} doc Document data. Requires `_id` and `_rev`.\n * @param {String} [options] Options.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#PUT|CouchDB Wiki}\n */\n\nDB.prototype.put = function (/* [id], [doc], [query], [headers], [callback] */) {\n var request = this._(arguments, 0, 1);\n // prevent acidentally creating database\n if (!request.p) request.p = request.b._id || request.b.id;\n if (!request.p) throw new Error(\"missing id\");\n return request(\"PUT\");\n};\n\n/**\n * Delete document(s).\n *\n * @param {Object|Object[]} docs Document or array of documents.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#DELETE|CouchDB Wiki}\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API|CouchDB Wiki}\n */\n\nDB.prototype.del = function (docs /* [query], [headers], [callback] */) {\n if (isArray(docs)) {\n var i = 0, len = docs.length, doc;\n for (; i < len; i++) {\n doc = docs[i], docs[i] = {\n _id: doc._id || doc.id,\n _rev: doc._rev || doc.rev,\n _deleted: true\n };\n }\n return this.post.apply(this, arguments);\n } else {\n var request = this._(arguments, 0, 1);\n // prevent acidentally deleting database\n if (!request.p) throw new Error(\"missing id\");\n return request(\"DELETE\");\n }\n};\n\n/**\n * Copy document.\n *\n * @param {Object} source Source document.\n * @param {String} source.id Source document ID.\n * @param {String} [source.rev] Source document revision.\n * @param {String} [source._id] Source document ID. Alternate key for\n * `source.id`.\n * @param {String} [source._rev] Source document revision. Alternate key\n * for `source.id`.\n * @param {Object} target Target document.\n * @param {String} target.id Target document ID.\n * @param {String} [target.rev] Target document revision.\n * @param {String} [target._id] Target document ID. Alternate key for\n * `target.id`.\n * @param {String} [target._rev] Target document revision. Alternate key\n * for `target.id`.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#COPY|CouchDB Wiki}\n */\n\nDB.prototype.copy = function (source, target /* [query], [headers], [callback] */) {\n var request = this._(arguments, 2);\n var sourcePath = encodeURIComponent(source.id || source._id || source);\n var targetPath = encodeURIComponent(target.id || target._id || target);\n var sourceRev = source.rev || source._rev;\n var targetRev = target.rev || target._rev;\n\n if (sourceRev) request.q.rev = sourceRev;\n if (targetRev) targetPath += \"?rev=\" + encodeURIComponent(targetRev);\n\n request.h.Destination = targetPath;\n\n return request(\"COPY\", sourcePath);\n};\n\n/**\n * Query all documents by ID.\n *\n * @param {Object} [query] HTTP query options.\n * @param {JSON} [query.startkey] Start returning results from this\n * document ID.\n * @param {JSON} [query.endkey] Stop returning results at this document\n * ID.\n * @param {Integer} [query.limit] Limit number of results returned.\n * @param {Boolean} [query.descending=false] Lookup results in reverse\n * order by key, returning documents in descending order by key.\n * @param {Integer} [query.skip] Skip this many records before\n * returning results.\n * @param {Boolean} [query.include_docs=false] Include document source for\n * each result.\n * @param {Boolean} [query.include_end=true] Include `query.endkey`\n * in results.\n * @param {Boolean} [query.update_seq=false] Include sequence value\n * of the database corresponding to the view.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API|CouchDB Wiki}\n */\n\nDB.prototype.all = function (/* [query], [headers], [callback] */) {\n var request = this._(arguments);\n var body = this._viewOptions(request.q);\n return request(body ? \"POST\" : \"GET\", \"_all_docs\", { b: body });\n};\n\n/**\n * Query a view.\n *\n * @param {String|Object} view View name (e.g. mydesign/myview) or\n * temporary view definition. Using a temporary view is strongly not\n * recommended for production use.\n * @param {Object} [query] HTTP query options.\n * @param {JSON} [query.key] Key to lookup.\n * @param {JSON} [query.startkey] Start returning results from this key.\n * @param {String} [query.startkey_docid] Start returning results\n * from this document ID. Allows pagination with duplicate keys.\n * @param {JSON} [query.endkey] Stop returning results at this key.\n * @param {String} [query.endkey_docid] Stop returning results at\n * this document ID. Allows pagination with duplicate keys.\n * @param {Integer} [query.limit] Limit number of results returned.\n * @param {Boolean|String} [query.stale] Do not refresh view even if\n * stale. For CouchDB versions `1.1.0` and up, set to `update_after` to\n * update view after results are returned.\n * @param {Boolean} [query.descending=false] Lookup results in reverse\n * order by key, returning documents in descending order by key.\n * @param {Integer} [query.skip] Skip this many records before\n * returning results.\n * @param {Boolean|Integer} [query.group=false] Use the reduce function\n * to group results by key. Set to an integer specify `group_level`.\n * @param {Boolean|Integer} [query.reduce=true] Use the reduce function.\n * @param {Boolean} [query.fetch=false] Include document source for\n * each result.\n * @param {Boolean} [query.include_end=true] Include `query.endkey`\n * in results.\n * @param {Boolean} [query.update_seq=false] Include sequence value\n * of the database corresponding to the view.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_view_API|CouchDB Wiki}\n */\n\nDB.prototype.find = function (view /* [query], [headers], [callback] */) {\n var request = this._(arguments, 1), path, body;\n\n if (isString(view)) {\n path = view.split(\"/\", 2);\n path = \"_design/\" + encodeURIComponent(path[0]) +\n \"/_view/\" + encodeURIComponent(path[1]);\n } else {\n path = \"_temp_view\";\n body = view;\n }\n\n body = this._viewOptions(request.q, body);\n return request(body ? \"POST\" : \"GET\", path, { b: body });\n};\n\n/**\n * Get database changes.\n *\n * The `feed` option determines how the callback is called:\n *\n * - `normal` calls the callback once.\n * - `longpoll` waits for a response, then calls the callback once.\n * - `continuous` calls the callback each time an update is received.\n * Implemented as the `database#follow()` method.\n *\n * @param {Object} [query] HTTP query options.\n * @param {String} [query.feed=\"normal\"] Type of feed. See comments\n * above.\n * @param {String} [query.filter] Filter updates using this filter.\n * @param {Integer} [query.limit] Maximum number of rows to return.\n * @param {Integer} [query.since=0] Start results from this sequence\n * number.\n * @param {Boolean} [query.include_docs=false] Include documents with\n * results.\n * @param {Integer} [query.timeout=1000] Maximum period in milliseconds\n * to wait for a change before sending a response, even if there are no\n * results.\n * @param {Integer} [query.heartbeat=1000] Period in milliseconds after\n * which an empty line is sent. Applicable only to feed types\n * `longpoll` and `continuous`. Overrides `query.timeout` to keep the\n * feed alive indefinitely.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_database_API#Changes|CouchDB Wiki}\n */\n\nDB.prototype.changes = function (/* [query], [headers], [callback] */) {\n var request = this._(arguments);\n if (request.q.feed != \"longpoll\") delete request.q.feed;\n return this._changes(request);\n};\n\n/**\n * Follow database changes.\n *\n * @see `#changes()`.\n */\n\nDB.prototype.follow = function (/* [query], [headers], callback */) {\n var self = this;\n var request = this._(arguments);\n var fn = request.f;\n\n if (!fn) return this;\n\n request.q.feed = \"longpoll\";\n request.f = function (err, body) {\n var args = [].slice.call(arguments);\n var done, i;\n for (i = 0; i < body.length; i++) {\n args[1] = body[i];\n if (done = fn.apply(self, args) === false || err) break;\n }\n if (!done) self._changes(request);\n };\n\n return this._changes(request);\n};\n\n/**\n * Service a changes request.\n *\n * @private\n */\n\nDB.prototype._changes = function (request) {\n return request(\"GET\", \"_changes\");\n};\n\n/**\n * Update document using server-side handler.\n *\n * @param {String} handler Update handler. Example: mydesign/myhandler\n * @param {String} [id] Document ID.\n * @param {Object} [query] HTTP query options.\n * @param {Object|String} [data] Data.\n * @param {Object} [headers] Headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/Document_Update_Handlers|CouchDB Wiki}\n */\n\nDB.prototype.update = function (handler /* [id], [query], [data], [headers], [callback] */) {\n var request = this._(arguments, 1, 1);\n var path = handler.split(\"/\", 2);\n\n path = \"_design/\" + encodeURIComponent(path[0]) +\n \"/_update/\" + encodeURIComponent(path[1]);\n\n if (request.p) path += \"/\" + request.p;\n\n return request(request.p ? \"PUT\" : \"POST\", path, {\n q: request.b,\n b: request.q\n });\n};\n\n/**\n * Download attachment from document.\n *\n * @param {Object|String} docOrId Document or document ID.\n * @param {String} attachmentName Attachment name.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.attachment = function (doc, attachmentName /* [query], [headers], [callback] */) {\n var request = this._(arguments, 2);\n var path = encodeURIComponent(doc._id || doc.id || doc) + \"/\" +\n encodeURIComponent(attachmentName);\n return request(\"GET\", path, options);\n};\n\n/**\n * Upload attachment to document.\n *\n * Set the `Content-Type` header.\n *\n * @param {Object} [doc] Document. Requires `id`. `rev` can be specified\n * here or in `query`.\n * @param {String} attachmentName Attachment name.\n * @param {Object} data Data.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.attach = function (doc, attachmentName, data /* [query], [headers], [callback] */) {\n var request = this._(arguments, 3);\n request.p = encodeURIComponent(doc._id || doc.id) + \"/\" +\n encodeURIComponent(attachmentName);\n if (!request.q.rev) request.q.rev = doc._rev || doc.rev;\n request.q.body = data;\n return request(\"PUT\", path);\n};\n\n/**\n * Replicate database.\n *\n * This convenience function sets `options.source` and `options.target` to\n * the selected database name. Either `options.source` or `options.target`\n * must be overridden for a successful replication request.\n *\n * @param {Options} options Options. Accepts all options from\n * `Client.replicate()`.\n * @param {String} [options.source=this.name] Source database URL or\n * local name. Defaults to the selected database name if not given.\n * @param {String} [options.target=this.name] Target database URL or\n * local name. Defaults to the selected database name if not given.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.replicate = function (options /* [query], [headers], [callback] */) {\n if (!options.source) options.source = this.name;\n if (!options.target) options.target = this.name;\n return this.client.replicate.apply(this.client, arguments);\n};\n\n/**\n * Ensure recent changes are committed to disk.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.commit = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"POST\", \"_ensure_full_commit\");\n};\n\n/**\n * Purge deleted documents from database.\n *\n * @param {Object} revs Map of document IDs to revisions to be purged.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.purge = function (revs /* [query], [headers], [callback] */) {\n return this._(arguments, 1)(\"POST\", \"_purge\", { b: revs });\n};\n\n/**\n * Compact database or design.\n *\n * @param {String} [design] Design name if compacting design indexes.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/Compaction|CouchDB Wiki}\n */\n\nDB.prototype.compact = function (/* [design], [query], [headers], [callback] */) {\n var request = this._(arguments);\n return request(\"POST\", \"_compact/\" + (request.p || \"\"));\n};\n\n/**\n * Remove unused views.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/Compaction|CouchDB Wiki}\n */\n\nDB.prototype.vacuum = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"POST\", \"_view_cleanup\");\n};\n\n/**\n * Parse view options.\n *\n * @param {Object} query The HTTP query options.\n * @param {Object} body The body payload.\n * @param {handler} [callback] Callback function.\n * @return {Object} The body payload.\n * @private\n */\n\nDB.prototype._viewOptions = function (q, body) {\n if (q) {\n if (q.key) q.key = JSON.stringify(q.key);\n if (q.startkey) q.startkey = JSON.stringify(q.startkey);\n if (q.endkey) q.endkey = JSON.stringify(q.endkey);\n if (q.stale && q.stale != \"update_after\") q.stale = \"ok\";\n if (q.keys) {\n if (!body) body = {};\n body.keys = q.keys;\n delete q.keys;\n }\n }\n return body;\n};\n\n/**\n * Handle a clerk response.\n *\n * @callback handler\n * @param {Error|null} error Error or `null` on success.\n * @param {Object} data Response data.\n * @param {Integer} status Response status code.\n * @param {Object} headers Response headers.\n * @param {superagent.Response} res Superagent response object.\n */\n\nclerk.Base = Base;\nclerk.Client = Client;\nclerk.DB = DB;\n\n/**\n * Export clerk.\n */\n\nmodule.exports = clerk;\n\n\n/***/ },\n/* 1 */\n/***/ function(module, exports, __webpack_require__) {\n\n/**\n * Module dependencies.\n */\n\nvar Emitter = __webpack_require__(2);\nvar reduce = __webpack_require__(3);\n\n/**\n * Root reference for iframes.\n */\n\nvar root = 'undefined' == typeof window\n ? this\n : window;\n\n/**\n * Noop.\n */\n\nfunction noop(){};\n\n/**\n * Check if `obj` is a host object,\n * we don't want to serialize these :)\n *\n * TODO: future proof, move to compoent land\n *\n * @param {Object} obj\n * @return {Boolean}\n * @api private\n */\n\nfunction isHost(obj) {\n var str = {}.toString.call(obj);\n\n switch (str) {\n case '[object File]':\n case '[object Blob]':\n case '[object FormData]':\n return true;\n default:\n return false;\n }\n}\n\n/**\n * Determine XHR.\n */\n\nfunction getXHR() {\n if (root.XMLHttpRequest\n && ('file:' != root.location.protocol || !root.ActiveXObject)) {\n return new XMLHttpRequest;\n } else {\n try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) {}\n }\n return false;\n}\n\n/**\n * Removes leading and trailing whitespace, added to support IE.\n *\n * @param {String} s\n * @return {String}\n * @api private\n */\n\nvar trim = ''.trim\n ? function(s) { return s.trim(); }\n : function(s) { return s.replace(/(^\\s*|\\s*$)/g, ''); };\n\n/**\n * Check if `obj` is an object.\n *\n * @param {Object} obj\n * @return {Boolean}\n * @api private\n */\n\nfunction isObject(obj) {\n return obj === Object(obj);\n}\n\n/**\n * Serialize the given `obj`.\n *\n * @param {Object} obj\n * @return {String}\n * @api private\n */\n\nfunction serialize(obj) {\n if (!isObject(obj)) return obj;\n var pairs = [];\n for (var key in obj) {\n if (null != obj[key]) {\n pairs.push(encodeURIComponent(key)\n + '=' + encodeURIComponent(obj[key]));\n }\n }\n return pairs.join('&');\n}\n\n/**\n * Expose serialization method.\n */\n\n request.serializeObject = serialize;\n\n /**\n * Parse the given x-www-form-urlencoded `str`.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\nfunction parseString(str) {\n var obj = {};\n var pairs = str.split('&');\n var parts;\n var pair;\n\n for (var i = 0, len = pairs.length; i < len; ++i) {\n pair = pairs[i];\n parts = pair.split('=');\n obj[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]);\n }\n\n return obj;\n}\n\n/**\n * Expose parser.\n */\n\nrequest.parseString = parseString;\n\n/**\n * Default MIME type map.\n *\n * superagent.types.xml = 'application/xml';\n *\n */\n\nrequest.types = {\n html: 'text/html',\n json: 'application/json',\n xml: 'application/xml',\n urlencoded: 'application/x-www-form-urlencoded',\n 'form': 'application/x-www-form-urlencoded',\n 'form-data': 'application/x-www-form-urlencoded'\n};\n\n/**\n * Default serialization map.\n *\n * superagent.serialize['application/xml'] = function(obj){\n * return 'generated xml here';\n * };\n *\n */\n\n request.serialize = {\n 'application/x-www-form-urlencoded': serialize,\n 'application/json': JSON.stringify\n };\n\n /**\n * Default parsers.\n *\n * superagent.parse['application/xml'] = function(str){\n * return { object parsed from str };\n * };\n *\n */\n\nrequest.parse = {\n 'application/x-www-form-urlencoded': parseString,\n 'application/json': JSON.parse\n};\n\n/**\n * Parse the given header `str` into\n * an object containing the mapped fields.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\nfunction parseHeader(str) {\n var lines = str.split(/\\r?\\n/);\n var fields = {};\n var index;\n var line;\n var field;\n var val;\n\n lines.pop(); // trailing CRLF\n\n for (var i = 0, len = lines.length; i < len; ++i) {\n line = lines[i];\n index = line.indexOf(':');\n field = line.slice(0, index).toLowerCase();\n val = trim(line.slice(index + 1));\n fields[field] = val;\n }\n\n return fields;\n}\n\n/**\n * Return the mime type for the given `str`.\n *\n * @param {String} str\n * @return {String}\n * @api private\n */\n\nfunction type(str){\n return str.split(/ *; */).shift();\n};\n\n/**\n * Return header field parameters.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\nfunction params(str){\n return reduce(str.split(/ *; */), function(obj, str){\n var parts = str.split(/ *= */)\n , key = parts.shift()\n , val = parts.shift();\n\n if (key && val) obj[key] = val;\n return obj;\n }, {});\n};\n\n/**\n * Initialize a new `Response` with the given `xhr`.\n *\n * - set flags (.ok, .error, etc)\n * - parse header\n *\n * Examples:\n *\n * Aliasing `superagent` as `request` is nice:\n *\n * request = superagent;\n *\n * We can use the promise-like API, or pass callbacks:\n *\n * request.get('/').end(function(res){});\n * request.get('/', function(res){});\n *\n * Sending data can be chained:\n *\n * request\n * .post('/user')\n * .send({ name: 'tj' })\n * .end(function(res){});\n *\n * Or passed to `.send()`:\n *\n * request\n * .post('/user')\n * .send({ name: 'tj' }, function(res){});\n *\n * Or passed to `.post()`:\n *\n * request\n * .post('/user', { name: 'tj' })\n * .end(function(res){});\n *\n * Or further reduced to a single call for simple cases:\n *\n * request\n * .post('/user', { name: 'tj' }, function(res){});\n *\n * @param {XMLHTTPRequest} xhr\n * @param {Object} options\n * @api private\n */\n\nfunction Response(req, options) {\n options = options || {};\n this.req = req;\n this.xhr = this.req.xhr;\n this.text = this.req.method !='HEAD' \n ? this.xhr.responseText \n : null;\n this.setStatusProperties(this.xhr.status);\n this.header = this.headers = parseHeader(this.xhr.getAllResponseHeaders());\n // getAllResponseHeaders sometimes falsely returns \"\" for CORS requests, but\n // getResponseHeader still works. so we get content-type even if getting\n // other headers fails.\n this.header['content-type'] = this.xhr.getResponseHeader('content-type');\n this.setHeaderProperties(this.header);\n this.body = this.req.method != 'HEAD'\n ? this.parseBody(this.text)\n : null;\n}\n\n/**\n * Get case-insensitive `field` value.\n *\n * @param {String} field\n * @return {String}\n * @api public\n */\n\nResponse.prototype.get = function(field){\n return this.header[field.toLowerCase()];\n};\n\n/**\n * Set header related properties:\n *\n * - `.type` the content type without params\n *\n * A response of \"Content-Type: text/plain; charset=utf-8\"\n * will provide you with a `.type` of \"text/plain\".\n *\n * @param {Object} header\n * @api private\n */\n\nResponse.prototype.setHeaderProperties = function(header){\n // content-type\n var ct = this.header['content-type'] || '';\n this.type = type(ct);\n\n // params\n var obj = params(ct);\n for (var key in obj) this[key] = obj[key];\n};\n\n/**\n * Parse the given body `str`.\n *\n * Used for auto-parsing of bodies. Parsers\n * are defined on the `superagent.parse` object.\n *\n * @param {String} str\n * @return {Mixed}\n * @api private\n */\n\nResponse.prototype.parseBody = function(str){\n var parse = request.parse[this.type];\n return parse && str && str.length\n ? parse(str)\n : null;\n};\n\n/**\n * Set flags such as `.ok` based on `status`.\n *\n * For example a 2xx response will give you a `.ok` of __true__\n * whereas 5xx will be __false__ and `.error` will be __true__. The\n * `.clientError` and `.serverError` are also available to be more\n * specific, and `.statusType` is the class of error ranging from 1..5\n * sometimes useful for mapping respond colors etc.\n *\n * \"sugar\" properties are also defined for common cases. Currently providing:\n *\n * - .noContent\n * - .badRequest\n * - .unauthorized\n * - .notAcceptable\n * - .notFound\n *\n * @param {Number} status\n * @api private\n */\n\nResponse.prototype.setStatusProperties = function(status){\n var type = status / 100 | 0;\n\n // status / class\n this.status = status;\n this.statusType = type;\n\n // basics\n this.info = 1 == type;\n this.ok = 2 == type;\n this.clientError = 4 == type;\n this.serverError = 5 == type;\n this.error = (4 == type || 5 == type)\n ? this.toError()\n : false;\n\n // sugar\n this.accepted = 202 == status;\n this.noContent = 204 == status || 1223 == status;\n this.badRequest = 400 == status;\n this.unauthorized = 401 == status;\n this.notAcceptable = 406 == status;\n this.notFound = 404 == status;\n this.forbidden = 403 == status;\n};\n\n/**\n * Return an `Error` representative of this response.\n *\n * @return {Error}\n * @api public\n */\n\nResponse.prototype.toError = function(){\n var req = this.req;\n var method = req.method;\n var url = req.url;\n\n var msg = 'cannot ' + method + ' ' + url + ' (' + this.status + ')';\n var err = new Error(msg);\n err.status = this.status;\n err.method = method;\n err.url = url;\n\n return err;\n};\n\n/**\n * Expose `Response`.\n */\n\nrequest.Response = Response;\n\n/**\n * Initialize a new `Request` with the given `method` and `url`.\n *\n * @param {String} method\n * @param {String} url\n * @api public\n */\n\nfunction Request(method, url) {\n var self = this;\n Emitter.call(this);\n this._query = this._query || [];\n this.method = method;\n this.url = url;\n this.header = {};\n this._header = {};\n this.on('end', function(){\n var err = null;\n var res = null;\n\n try {\n res = new Response(self); \n } catch(e) {\n err = new Error('Parser is unable to parse the response');\n err.parse = true;\n err.original = e;\n }\n\n self.callback(err, res);\n });\n}\n\n/**\n * Mixin `Emitter`.\n */\n\nEmitter(Request.prototype);\n\n/**\n * Allow for extension\n */\n\nRequest.prototype.use = function(fn) {\n fn(this);\n return this;\n}\n\n/**\n * Set timeout to `ms`.\n *\n * @param {Number} ms\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.timeout = function(ms){\n this._timeout = ms;\n return this;\n};\n\n/**\n * Clear previous timeout.\n *\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.clearTimeout = function(){\n this._timeout = 0;\n clearTimeout(this._timer);\n return this;\n};\n\n/**\n * Abort the request, and clear potential timeout.\n *\n * @return {Request}\n * @api public\n */\n\nRequest.prototype.abort = function(){\n if (this.aborted) return;\n this.aborted = true;\n this.xhr.abort();\n this.clearTimeout();\n this.emit('abort');\n return this;\n};\n\n/**\n * Set header `field` to `val`, or multiple fields with one object.\n *\n * Examples:\n *\n * req.get('/')\n * .set('Accept', 'application/json')\n * .set('X-API-Key', 'foobar')\n * .end(callback);\n *\n * req.get('/')\n * .set({ Accept: 'application/json', 'X-API-Key': 'foobar' })\n * .end(callback);\n *\n * @param {String|Object} field\n * @param {String} val\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.set = function(field, val){\n if (isObject(field)) {\n for (var key in field) {\n this.set(key, field[key]);\n }\n return this;\n }\n this._header[field.toLowerCase()] = val;\n this.header[field] = val;\n return this;\n};\n\n/**\n * Remove header `field`.\n *\n * Example:\n *\n * req.get('/')\n * .unset('User-Agent')\n * .end(callback);\n *\n * @param {String} field\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.unset = function(field){\n delete this._header[field.toLowerCase()];\n delete this.header[field];\n return this;\n};\n\n/**\n * Get case-insensitive header `field` value.\n *\n * @param {String} field\n * @return {String}\n * @api private\n */\n\nRequest.prototype.getHeader = function(field){\n return this._header[field.toLowerCase()];\n};\n\n/**\n * Set Content-Type to `type`, mapping values from `request.types`.\n *\n * Examples:\n *\n * superagent.types.xml = 'application/xml';\n *\n * request.post('/')\n * .type('xml')\n * .send(xmlstring)\n * .end(callback);\n *\n * request.post('/')\n * .type('application/xml')\n * .send(xmlstring)\n * .end(callback);\n *\n * @param {String} type\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.type = function(type){\n this.set('Content-Type', request.types[type] || type);\n return this;\n};\n\n/**\n * Set Accept to `type`, mapping values from `request.types`.\n *\n * Examples:\n *\n * superagent.types.json = 'application/json';\n *\n * request.get('/agent')\n * .accept('json')\n * .end(callback);\n *\n * request.get('/agent')\n * .accept('application/json')\n * .end(callback);\n *\n * @param {String} accept\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.accept = function(type){\n this.set('Accept', request.types[type] || type);\n return this;\n};\n\n/**\n * Set Authorization field value with `user` and `pass`.\n *\n * @param {String} user\n * @param {String} pass\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.auth = function(user, pass){\n var str = btoa(user + ':' + pass);\n this.set('Authorization', 'Basic ' + str);\n return this;\n};\n\n/**\n* Add query-string `val`.\n*\n* Examples:\n*\n* request.get('/shoes')\n* .query('size=10')\n* .query({ color: 'blue' })\n*\n* @param {Object|String} val\n* @return {Request} for chaining\n* @api public\n*/\n\nRequest.prototype.query = function(val){\n if ('string' != typeof val) val = serialize(val);\n if (val) this._query.push(val);\n return this;\n};\n\n/**\n * Write the field `name` and `val` for \"multipart/form-data\"\n * request bodies.\n *\n * ``` js\n * request.post('/upload')\n * .field('foo', 'bar')\n * .end(callback);\n * ```\n *\n * @param {String} name\n * @param {String|Blob|File} val\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.field = function(name, val){\n if (!this._formData) this._formData = new FormData();\n this._formData.append(name, val);\n return this;\n};\n\n/**\n * Queue the given `file` as an attachment to the specified `field`,\n * with optional `filename`.\n *\n * ``` js\n * request.post('/upload')\n * .attach(new Blob(['hey!'], { type: \"text/html\"}))\n * .end(callback);\n * ```\n *\n * @param {String} field\n * @param {Blob|File} file\n * @param {String} filename\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.attach = function(field, file, filename){\n if (!this._formData) this._formData = new FormData();\n this._formData.append(field, file, filename);\n return this;\n};\n\n/**\n * Send `data`, defaulting the `.type()` to \"json\" when\n * an object is given.\n *\n * Examples:\n *\n * // querystring\n * request.get('/search')\n * .end(callback)\n *\n * // multiple data \"writes\"\n * request.get('/search')\n * .send({ search: 'query' })\n * .send({ range: '1..5' })\n * .send({ order: 'desc' })\n * .end(callback)\n *\n * // manual json\n * request.post('/user')\n * .type('json')\n * .send('{\"name\":\"tj\"})\n * .end(callback)\n *\n * // auto json\n * request.post('/user')\n * .send({ name: 'tj' })\n * .end(callback)\n *\n * // manual x-www-form-urlencoded\n * request.post('/user')\n * .type('form')\n * .send('name=tj')\n * .end(callback)\n *\n * // auto x-www-form-urlencoded\n * request.post('/user')\n * .type('form')\n * .send({ name: 'tj' })\n * .end(callback)\n *\n * // defaults to x-www-form-urlencoded\n * request.post('/user')\n * .send('name=tobi')\n * .send('species=ferret')\n * .end(callback)\n *\n * @param {String|Object} data\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.send = function(data){\n var obj = isObject(data);\n var type = this.getHeader('Content-Type');\n\n // merge\n if (obj && isObject(this._data)) {\n for (var key in data) {\n this._data[key] = data[key];\n }\n } else if ('string' == typeof data) {\n if (!type) this.type('form');\n type = this.getHeader('Content-Type');\n if ('application/x-www-form-urlencoded' == type) {\n this._data = this._data\n ? this._data + '&' + data\n : data;\n } else {\n this._data = (this._data || '') + data;\n }\n } else {\n this._data = data;\n }\n\n if (!obj) return this;\n if (!type) this.type('json');\n return this;\n};\n\n/**\n * Invoke the callback with `err` and `res`\n * and handle arity check.\n *\n * @param {Error} err\n * @param {Response} res\n * @api private\n */\n\nRequest.prototype.callback = function(err, res){\n var fn = this._callback;\n this.clearTimeout();\n if (2 == fn.length) return fn(err, res);\n if (err) return this.emit('error', err);\n fn(res);\n};\n\n/**\n * Invoke callback with x-domain error.\n *\n * @api private\n */\n\nRequest.prototype.crossDomainError = function(){\n var err = new Error('Origin is not allowed by Access-Control-Allow-Origin');\n err.crossDomain = true;\n this.callback(err);\n};\n\n/**\n * Invoke callback with timeout error.\n *\n * @api private\n */\n\nRequest.prototype.timeoutError = function(){\n var timeout = this._timeout;\n var err = new Error('timeout of ' + timeout + 'ms exceeded');\n err.timeout = timeout;\n this.callback(err);\n};\n\n/**\n * Enable transmission of cookies with x-domain requests.\n *\n * Note that for this to work the origin must not be\n * using \"Access-Control-Allow-Origin\" with a wildcard,\n * and also must set \"Access-Control-Allow-Credentials\"\n * to \"true\".\n *\n * @api public\n */\n\nRequest.prototype.withCredentials = function(){\n this._withCredentials = true;\n return this;\n};\n\n/**\n * Initiate request, invoking callback `fn(res)`\n * with an instanceof `Response`.\n *\n * @param {Function} fn\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.end = function(fn){\n var self = this;\n var xhr = this.xhr = getXHR();\n var query = this._query.join('&');\n var timeout = this._timeout;\n var data = this._formData || this._data;\n\n // store callback\n this._callback = fn || noop;\n\n // state change\n xhr.onreadystatechange = function(){\n if (4 != xhr.readyState) return;\n if (0 == xhr.status) {\n if (self.aborted) return self.timeoutError();\n return self.crossDomainError();\n }\n self.emit('end');\n };\n\n // progress\n if (xhr.upload) {\n xhr.upload.onprogress = function(e){\n e.percent = e.loaded / e.total * 100;\n self.emit('progress', e);\n };\n }\n\n // timeout\n if (timeout && !this._timer) {\n this._timer = setTimeout(function(){\n self.abort();\n }, timeout);\n }\n\n // querystring\n if (query) {\n query = request.serializeObject(query);\n this.url += ~this.url.indexOf('?')\n ? '&' + query\n : '?' + query;\n }\n\n // initiate request\n xhr.open(this.method, this.url, true);\n\n // CORS\n if (this._withCredentials) xhr.withCredentials = true;\n\n // body\n if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !isHost(data)) {\n // serialize stuff\n var serialize = request.serialize[this.getHeader('Content-Type')];\n if (serialize) data = serialize(data);\n }\n\n // set header fields\n for (var field in this.header) {\n if (null == this.header[field]) continue;\n xhr.setRequestHeader(field, this.header[field]);\n }\n\n // send stuff\n this.emit('request', this);\n xhr.send(data);\n return this;\n};\n\n/**\n * Expose `Request`.\n */\n\nrequest.Request = Request;\n\n/**\n * Issue a request:\n *\n * Examples:\n *\n * request('GET', '/users').end(callback)\n * request('/users').end(callback)\n * request('/users', callback)\n *\n * @param {String} method\n * @param {String|Function} url or callback\n * @return {Request}\n * @api public\n */\n\nfunction request(method, url) {\n // callback\n if ('function' == typeof url) {\n return new Request('GET', method).end(url);\n }\n\n // url first\n if (1 == arguments.length) {\n return new Request('GET', method);\n }\n\n return new Request(method, url);\n}\n\n/**\n * GET `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} data or fn\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.get = function(url, data, fn){\n var req = request('GET', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.query(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * HEAD `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} data or fn\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.head = function(url, data, fn){\n var req = request('HEAD', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * DELETE `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.del = function(url, fn){\n var req = request('DELETE', url);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * PATCH `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed} data\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.patch = function(url, data, fn){\n var req = request('PATCH', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * POST `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed} data\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.post = function(url, data, fn){\n var req = request('POST', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * PUT `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} data or fn\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.put = function(url, data, fn){\n var req = request('PUT', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * Expose `request`.\n */\n\nmodule.exports = request;\n\n\n/***/ },\n/* 2 */\n/***/ function(module, exports, __webpack_require__) {\n\n\n/**\n * Expose `Emitter`.\n */\n\nmodule.exports = Emitter;\n\n/**\n * Initialize a new `Emitter`.\n *\n * @api public\n */\n\nfunction Emitter(obj) {\n if (obj) return mixin(obj);\n};\n\n/**\n * Mixin the emitter properties.\n *\n * @param {Object} obj\n * @return {Object}\n * @api private\n */\n\nfunction mixin(obj) {\n for (var key in Emitter.prototype) {\n obj[key] = Emitter.prototype[key];\n }\n return obj;\n}\n\n/**\n * Listen on the given `event` with `fn`.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.on =\nEmitter.prototype.addEventListener = function(event, fn){\n this._callbacks = this._callbacks || {};\n (this._callbacks[event] = this._callbacks[event] || [])\n .push(fn);\n return this;\n};\n\n/**\n * Adds an `event` listener that will be invoked a single\n * time then automatically removed.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.once = function(event, fn){\n var self = this;\n this._callbacks = this._callbacks || {};\n\n function on() {\n self.off(event, on);\n fn.apply(this, arguments);\n }\n\n on.fn = fn;\n this.on(event, on);\n return this;\n};\n\n/**\n * Remove the given callback for `event` or all\n * registered callbacks.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.off =\nEmitter.prototype.removeListener =\nEmitter.prototype.removeAllListeners =\nEmitter.prototype.removeEventListener = function(event, fn){\n this._callbacks = this._callbacks || {};\n\n // all\n if (0 == arguments.length) {\n this._callbacks = {};\n return this;\n }\n\n // specific event\n var callbacks = this._callbacks[event];\n if (!callbacks) return this;\n\n // remove all handlers\n if (1 == arguments.length) {\n delete this._callbacks[event];\n return this;\n }\n\n // remove specific handler\n var cb;\n for (var i = 0; i < callbacks.length; i++) {\n cb = callbacks[i];\n if (cb === fn || cb.fn === fn) {\n callbacks.splice(i, 1);\n break;\n }\n }\n return this;\n};\n\n/**\n * Emit `event` with the given args.\n *\n * @param {String} event\n * @param {Mixed} ...\n * @return {Emitter}\n */\n\nEmitter.prototype.emit = function(event){\n this._callbacks = this._callbacks || {};\n var args = [].slice.call(arguments, 1)\n , callbacks = this._callbacks[event];\n\n if (callbacks) {\n callbacks = callbacks.slice(0);\n for (var i = 0, len = callbacks.length; i < len; ++i) {\n callbacks[i].apply(this, args);\n }\n }\n\n return this;\n};\n\n/**\n * Return array of callbacks for `event`.\n *\n * @param {String} event\n * @return {Array}\n * @api public\n */\n\nEmitter.prototype.listeners = function(event){\n this._callbacks = this._callbacks || {};\n return this._callbacks[event] || [];\n};\n\n/**\n * Check if this emitter has `event` handlers.\n *\n * @param {String} event\n * @return {Boolean}\n * @api public\n */\n\nEmitter.prototype.hasListeners = function(event){\n return !! this.listeners(event).length;\n};\n\n\n/***/ },\n/* 3 */\n/***/ function(module, exports, __webpack_require__) {\n\n\n/**\n * Reduce `arr` with `fn`.\n *\n * @param {Array} arr\n * @param {Function} fn\n * @param {Mixed} initial\n *\n * TODO: combatible error handling?\n */\n\nmodule.exports = function(arr, fn, initial){ \n var idx = 0;\n var len = arr.length;\n var curr = arguments.length == 3\n ? initial\n : arr[idx++];\n\n while (idx < len) {\n curr = fn.call(null, curr, arr[idx], ++idx, arr);\n }\n \n return curr;\n};\n\n/***/ }\n/******/ ])\n\n\n/** WEBPACK FOOTER **\n ** clerk.min.js\n **/"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 56e07271c8805efce757\n **/","\"use strict\";\n\n/*!\n\nclerk - CouchDB client for node and the browser.\nCopyright 2012-2015 Michael Phan-Ba\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n*/\n\n/** @namespace clerk */\n\n/*\n * Module dependencies.\n */\n\nvar request = require(\"superagent\");\n\n/**\n * Copy properties from sources to target.\n *\n * @param {Object} target The target object.\n * @param {...Object} sources The source object.\n * @return {Object} The target object.\n * @private\n */\n\nvar extend = function (target /* ...sources */) {\n var source, key, i = 1;\n while (source = arguments[i++]) {\n for (key in source) target[key] = source[key];\n }\n return target;\n};\n\n/**\n * Stringify value.\n *\n * @param {Object} that That value to stringify.\n * @return {String} The stringifyed value.\n * @private\n */\n\nvar asString = function (that) {\n return Object.prototype.toString.call(that);\n};\n\n/**\n * Check if value is a string.\n *\n * @param {Object} that That value to check.\n * @return {Boolean} `true` if string, `false` otherwise.\n * @private\n */\n\nvar isString = function (that) {\n return asString(that) == \"[object String]\";\n};\n\n/**\n * Check if value is an object.\n *\n * @param {Object} that That value to check.\n * @return {Boolean} `true` if object, `false` otherwise.\n * @private\n */\n\nvar isObject = function (that) {\n return asString(that) == \"[object Object]\";\n};\n\n/**\n * Check if value is an array.\n *\n * @param {Object} that That value to check.\n * @return {Boolean} `true` if array, `false` otherwise.\n * @private\n */\n\nvar isArray = function (that) {\n return asString(that) == \"[object Array]\";\n};\n\n/**\n * Check if value is a function.\n *\n * @param {Object} that That value to check.\n * @return {Boolean} `true` if function, `false` otherwise.\n * @private\n */\n\nvar isFunction = function (that) {\n return asString(that) == \"[object Function]\";\n};\n\n/**\n * Clerk library entry point.\n *\n * @param {String} uri CouchDB server URI.\n * @return {Client|DB} If a URI path is given, returns a `DB`, otherwise\n * returns a `Client`.\n * @see {@link http://docs.couchdb.org|CouchDB Documentation}\n * @see {@link http://guide.couchdb.org/|CouchDB Guide}\n * @see {@link http://wiki.apache.org/couchdb/|CouchDB Wiki}\n */\n\nfunction clerk (uri) {\n return clerk.make(uri);\n};\n\n/**\n * Library version.\n * @type {String}\n */\n\nclerk.version = \"0.7.2\";\n\n/**\n * Default host.\n * @type {String}\n */\n\nclerk.defaultHost = \"http://127.0.0.1:5984\";\n\n/**\n * Create single CouchDB client.\n *\n * @param {String} uri Fully qualified URI.\n * @return {Client|DB} If `uri` has a path, the last segment of the\n * path is used as the database name and a `DB` instance is\n * returned. Otherwise, a `Client` instance is returned.\n */\n\nclerk.make = function (uri) {\n if (!uri) return new Client(this.defaultHost);\n\n uri = clerk._parseURI(uri);\n\n var db = /\\/*([^\\/]+)\\/*$/.exec(uri.path);\n if (db) {\n uri.path = uri.path.substr(0, db.index);\n db = db[1] && decodeURIComponent(db[1]);\n }\n\n // weird way of doing it, but it's more efficient...\n if (uri.auth) uri.auth = 'Basic ' + clerk.btoa(uri.auth);\n\n var client = new clerk.Client(uri.base + uri.path, uri.auth);\n return db ? client.db(db) : client;\n};\n\n/**\n * Base64-encode a string.\n *\n * @param {String} str\n * @return {String}\n */\n\nclerk.btoa = typeof Buffer != \"undefined\" ? function (str) {\n return new Buffer(str).toString(\"base64\");\n} : function (str) {\n return btoa(str);\n};\n\n/**\n * Parse URI.\n *\n * The URI is normalized by removing extra `//` in the path.\n *\n * @param {String} uri Fully qualified URI.\n * @return {String} The normalized URI.\n * @private\n */\n\nclerk._parseURI = function (uri) {\n var match;\n\n if (uri) {\n if (match = /^(https?:\\/\\/)(?:([^\\/@]+)@)?([^\\/]+)(.*)\\/*$/.exec(uri)) {\n return {\n base: match[1] + match[3].replace(/\\/+/g, \"\\/\"),\n path: match[4],\n auth: match[2] && decodeURIComponent(match[2])\n };\n }\n }\n\n return { base: uri || \"\", path: \"\" };\n};\n\n/**\n * Base prototype for `Client` and `DB`.\n * Encapsulates HTTP methods, JSON handling, and response coersion.\n *\n * @constructor\n */\n\nfunction Base () {};\n\n/**\n * Service request and parse JSON response.\n *\n * @param {String} [method=GET] HTTP method.\n * @param {String} [path=this.uri] HTTP URI.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [body] HTTP body.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nBase.prototype.request = function (/* [method], [path], [query], [body], [headers], [callback] */) {\n var args = [].slice.call(arguments);\n var callback = isFunction (args[args.length - 1]) && args.pop();\n\n return this._request({\n method: args[0],\n path: args[1],\n query: args[2],\n data: args[3],\n headers: args[4],\n fn: callback\n });\n};\n\n/**\n * Internal service request and parse JSON response handler.\n *\n * @param {String} options\n * @param {String} method HTTP method.\n * @param {String} path HTTP URI.\n * @param {Object} query HTTP query options.\n * @param {Object} data HTTP body data.\n * @param {Object} headers HTTP headers.\n * @param {handler} [callback] Callback function.\n * @private\n */\n\nBase.prototype._request = function (options) {\n var self = this;\n\n if (options.method == null) options.method = \"GET\";\n if (options.headers == null) options.headers = {};\n if (options.auth == null) options.auth = this.auth;\n\n options.path = options.path ? \"/\" + options.path : \"\";\n\n // set default headers\n if (options.headers[\"Content-Type\"] == null) {\n options.headers[\"Content-Type\"] = \"application/json\";\n }\n if (options.headers[\"Accept\"] == null) {\n options.headers[\"Accept\"] = \"application/json\";\n }\n if (this.auth && options.headers[\"Authorization\"] == null) {\n options.headers[\"Authorization\"] = this.auth;\n }\n\n options.uri = this.uri + options.path;\n options.body = options.data && JSON.stringify(options.data,\n /^\\/_design/.test(options.path) && this._replacer\n ) || \"\";\n\n // create promise if no callback given\n var promise, req;\n if (!options.fn && typeof Promise != \"undefined\") {\n promise = new Promise(function (resolve, reject) {\n options.fn = function (err, data, status, headers, res) {\n if (err) {\n err.body = data;\n err.status = status;\n err.headers = headers;\n err.res = res;\n reject(err);\n } else {\n if (Object.defineProperties) {\n Object.defineProperties(data, {\n _status: { value: status },\n _headers: { value: headers },\n _response: { value: res },\n });\n }\n resolve(data);\n };\n };\n });\n req = send();\n promise.request = req;\n promise.abort = function () {\n req.abort();\n options.fn(new Error(\"abort\"));\n return promise;\n };\n return promise;\n }\n\n send();\n\n function send () {\n // apply response transforms\n var g = options._;\n var fn = options.fn;\n if (fn) {\n options.fn = g ? function () {\n fn.apply(self, g.apply(self, arguments) || arguments);\n } : fn;\n }\n return self._do(options);\n }\n};\n\n/**\n * Provider for servicing requests and parsing JSON responses.\n *\n * @param {String} options\n * @param {String} method HTTP method.\n * @param {String} uri HTTP URI.\n * @param {Object} query HTTP query options.\n * @param {Object} body HTTP body.\n * @param {Object} headers HTTP headers.\n * @param {Object} auth HTTP authentication.\n * @param {handler} [callback] Callback function.\n * @private\n */\n\nBase.prototype._do = function (options) {\n var self = this;\n var key, value;\n\n // create request\n var req = request(options.method, options.uri);\n\n // query string\n if (options.query) {\n // ensure query Array values are JSON encoded\n for (key in options.query) {\n if (typeof(value = options.query[key]) === \"object\") {\n options.query[key] = JSON.stringify(value);\n }\n }\n // set query on request\n req.query(options.query);\n }\n\n // set headers\n if (options.headers) {\n req.set(options.headers);\n // if authenticating\n if (req.withCredentials && options.headers[\"Authorization\"] != null) {\n req.withCredentials();\n }\n }\n\n // send body\n if (options.body) req.send(options.body);\n\n // send request\n var fn = options.fn;\n req.end(function (res) {\n var err = res.error;\n var data;\n\n if (!err) {\n if (!(data = res.body || res.text)) {}\n else if (data.error) err = self._error(data);\n else data = self._response(data);\n }\n\n res.data = data;\n\n fn && fn(err || null, data, res.status, res.header, res);\n });\n\n return req;\n};\n\n/**\n * Coerce response to normalize access to `_id` and `_rev`.\n *\n * @param {Object} json The response JSON.\n * @return The coerced JSON.\n * @private\n */\n\nBase.prototype._response = function (json) {\n var data = json.rows || json.results || json.uuids || isArray(json) && json;\n var meta = this._meta;\n var i = 0, len, item;\n\n if (data) {\n extend(data, json).json = json;\n for (len = data.length; i < len; i++) {\n item = data[i] = meta(data[i]);\n if (item.doc) item.doc = meta(item.doc);\n }\n } else {\n data = meta(json);\n }\n\n return data;\n};\n\n/**\n * Make an error out of the response.\n *\n * @param {Object} json The response JSON.\n * @return An `Error` object.\n * @private\n */\n\nBase.prototype._error = function (json) {\n var err = new Error(json.reason);\n err.code = json.error;\n return extend(err, json);\n};\n\n/**\n * JSON stringify functions. Used for encoding view documents to JSON.\n *\n * @param {String} key The key to stringify.\n * @param {Object} val The value to stringify.\n * @return {Object} The stringified function value or the value.\n * @private\n */\n\nBase.prototype._replacer = function (key, val) {\n return isFunction (val) ? val.toString() : val;\n};\n\n/**\n * Coerce documents with prototypical `_id` and `_rev`\n * values.\n *\n * @param {Object} doc The document to coerce.\n * @return {Object} The coerced document.\n * @private\n */\n\nBase.prototype._meta = function (doc) {\n var hasId = !doc._id && doc.id;\n var hasRev = !doc._rev && doc.rev;\n var proto;\n\n if (hasId || hasRev) {\n proto = function (){};\n doc = extend(new proto(), doc);\n proto = proto.prototype;\n if (hasId) proto._id = doc.id;\n if (hasRev) proto._rev = doc.rev;\n }\n\n return doc;\n};\n\n/**\n * Parse arguments.\n *\n * @param {Array} args The arguments.\n * @param {Integer} start The index from which to start reading arguments.\n * @param {Boolean} withDoc Set to `true` if the doc source is given as a\n * parameter before HTTP query options.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @private\n */\n\nBase.prototype._ = function (args, start, withDoc) {\n var self = this, doc, id, rev;\n\n function request(method, path, options) {\n if (!options) options = {};\n return self._request({\n method: method,\n path: path || request.p,\n query: options.q || request.q,\n data: options.b || request.b,\n headers: options.h || request.h,\n fn: options.f || request.f,\n _: options._ || request._\n });\n }\n\n // [id], [doc], [query], [header], [callback]\n args = [].slice.call(args, start || 0);\n\n request.f = isFunction(args[args.length - 1]) && args.pop();\n request.p = isString(args[0]) && encodeURI(args.shift());\n request.q = args[withDoc ? 1 : 0] || {};\n request.h = args[withDoc ? 2 : 1] || {};\n\n if (withDoc) {\n if (doc = (request.b = args[0])) {\n if (id = request.p || doc._id || doc.id) request.p = id;\n if (rev = request.q.rev || doc._rev || doc.rev) request.q.rev = rev;\n }\n }\n\n return request;\n};\n\n/**\n * Clerk CouchDB client.\n *\n * @param {String} uri Fully qualified URI.\n * @param {String} [auth] Authentication header value.\n * @constructor\n * @see {@link http://wiki.apache.org/couchdb/Complete_HTTP_API_Reference|CouchDB Wiki}\n */\n\nfunction Client (uri, auth) {\n this.uri = uri;\n this._db = {};\n this.auth = auth;\n};\n\nClient.prototype = new Base();\n\n/**\n * Select database to manipulate.\n *\n * @param {String} name DB name.\n * @return {DB} DB object.\n */\n\nClient.prototype.db = function (name) {\n var db = this._db;\n return db[name] || (db[name] = new DB(this, name, this.auth));\n};\n\n/**\n * List all databases.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetAllDbs|CouchDB Wiki}\n */\n\nClient.prototype.dbs = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\", \"_all_dbs\");\n};\n\n/**\n * Get UUIDs.\n *\n * @param {Integer} [count=1] Number of UUIDs to get.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetUuids|CouchDB Wiki}\n */\n\nClient.prototype.uuids = function (count /* [query], [headers], [callback] */) {\n var request = this._(arguments, +count == count ? 1 : 0);\n if (count > 1) request.q.count = count;\n return request(\"GET\", \"_uuids\");\n};\n\n/**\n * Get server information.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetRoot|CouchDB Wiki}\n */\n\nClient.prototype.info = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\");\n};\n\n/**\n * Get server stats.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetLog|CouchDB Wiki}\n */\n\nClient.prototype.stats = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\", \"_stats\");\n};\n\n/**\n * Get tail of the server log file.\n *\n * @param {Object} [query] Query parameters.\n * @param {Integer} [query.bytes] Number of bytes to read.\n * @param {Integer} [query.offset] Number of bytes from the end of\n * log file to start reading.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetLog|CouchDB Wiki}\n */\n\nClient.prototype.log = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\", \"_log\");\n};\n\n/**\n * List running tasks.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetActiveTasks|CouchDB Wiki}\n */\n\nClient.prototype.tasks = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\", \"_active_tasks\");\n};\n\n/**\n * Get or set configuration values.\n *\n * @param {String} [key] Configuration section or key.\n * @param {String} [value] Configuration value.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nClient.prototype.config = function (/* [key], [value], [query], [headers], [callback] */) {\n var args = [].slice.call(arguments);\n var key = isString(args[0]) && args.shift() || \"\";\n var value = isString(args[0]) && args.shift();\n var method = isString(value) ? \"PUT\" : \"GET\";\n return this._(args)(method, \"_config/\" + key, { b: value });\n};\n\n/**\n * Replicate databases.\n *\n * @param {Object} options Options.\n * @param {String} options.source Source database URL or local name.\n * @param {String} options.target Target database URL or local name.\n * @param {Boolean} [options.cancel] Set to `true` to cancel replication.\n * @param {Boolean} [options.continuous] Set to `true` for continuous\n * replication.\n * @param {Boolean} [options.create_target] Set to `true` to create the\n * target database.\n * @param {String} [options.filter] Filter name for filtered replication.\n * Example: \"mydesign/myfilter\".\n * @param {Object} [options.query] Query parameters for filter.\n * @param {String[]} [options.doc_ids] Document IDs to replicate.\n * @param {String} [options.proxy] Proxy through which to replicate.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/Replication|CouchDB Wiki}\n */\n\nClient.prototype.replicate = function (options /* [query], [headers], [callback] */) {\n return this._(arguments, 1)(\"POST\", \"_replicate\", { b: options });\n};\n\n/**\n * Methods for CouchDB database.\n *\n * @param {Client} client Clerk client.\n * @param {String} name DB name.\n * @param {String} [auth] Authentication header value.\n * @constructor\n * @return This object for chaining.\n */\n\nfunction DB (client, name, auth) {\n this.client = client;\n this.name = name;\n this.uri = client.uri + \"/\" + encodeURIComponent(name);\n this.auth = auth;\n};\n\nDB.prototype = new Base();\n\n/**\n * Create database.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.create = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"PUT\");\n};\n\n/**\n * Destroy database.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.destroy = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"DELETE\");\n};\n\n/**\n * Get database info.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.info = function (/* [query], [headers], callback */) {\n return this._(arguments)(\"GET\");\n};\n\n/**\n * Check if database exists.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.exists = function (/* [query], [headers], callback */) {\n var request = this._(arguments);\n request._ = function (err, body, status, headers, req) {\n return [err, status === 200, status, headers, req];\n };\n return request(\"HEAD\");\n};\n\n/**\n * Fetch document.\n *\n * Set `rev` in `query`.\n *\n * @param {String} id Document ID.\n * @param {Object} [query] HTTP query options.\n * @param {Boolean} [query.revs] Fetch list of revisions.\n * @param {Boolean} [query.revs_info] Fetch detailed revision information.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#GET|CouchDB Wiki}\n */\n\nDB.prototype.get = function (/* [id], [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\");\n};\n\n/**\n * Get document metadata.\n *\n * @param {String} id Document ID.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#HEAD|CouchDB Wiki}\n */\n\nDB.prototype.head = function (/* [id], [query], [headers], callback */) {\n var self = this;\n var request = self._(arguments);\n request._ = function (err, body, status, headers, res) {\n return [err, err ? null : {\n _id: request.p,\n _rev: headers.etag && JSON.parse(headers.etag),\n contentType: headers[\"content-type\"],\n contentLength: headers[\"content-length\"]\n }, status, headers, res];\n };\n return request(\"HEAD\");\n};\n\n/**\n * Post document(s) to database.\n *\n * If documents have no ID, a document ID will be automatically generated\n * on the server. Attachments are not currently supported.\n *\n * @param {Object|Object[]} doc Document or array of documents.\n * @param {String} [doc._id] Document ID. If set, uses given document ID.\n * @param {String} [doc._rev] Document revision. If set, allows update to\n * existing document.\n * @param {Object} [doc._attachments] Attachments. If given, must be a\n * map of filenames to attachment properties.\n * @param {String} [doc._attachments[filename]] Attachment filename, as\n * hash key.\n * @param {String} [doc._attachments[filename].contentType] Attachment\n * MIME content type.\n * @param {String|Object} [doc._attachments[filename].data] Attachment\n * data. Will be Base64 encoded.\n * @param {Object} [query] HTTP query options.\n * @param {Boolean} [query.batch] Allow server to write document in\n * batch mode. Documents will not be written to disk immediately,\n * increasing the chances of write failure.\n * @param {Boolean} [query.all_or_nothing] For batch updating of\n * documents, use all-or-nothing semantics.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#POST|CouchDB Wiki}\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API|CouchDB Wiki}\n */\n\nDB.prototype.post = function (docs /* [query], [headers], [callback] */) {\n var request = this._(arguments, 1);\n if (isArray(docs)) {\n request.p = \"_bulk_docs\";\n request.b = extend({ docs: docs }, request.q);\n request.q = null\n } else {\n request.b = docs;\n }\n return request(\"POST\");\n};\n\n/**\n * Put document in database.\n *\n * @param {Object} doc Document data. Requires `_id` and `_rev`.\n * @param {String} [options] Options.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#PUT|CouchDB Wiki}\n */\n\nDB.prototype.put = function (/* [id], [doc], [query], [headers], [callback] */) {\n var request = this._(arguments, 0, 1);\n // prevent acidentally creating database\n if (!request.p) request.p = request.b._id || request.b.id;\n if (!request.p) throw new Error(\"missing id\");\n return request(\"PUT\");\n};\n\n/**\n * Delete document(s).\n *\n * @param {Object|Object[]} docs Document or array of documents.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#DELETE|CouchDB Wiki}\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API|CouchDB Wiki}\n */\n\nDB.prototype.del = function (docs /* [query], [headers], [callback] */) {\n if (isArray(docs)) {\n var i = 0, len = docs.length, doc;\n for (; i < len; i++) {\n doc = docs[i], docs[i] = {\n _id: doc._id || doc.id,\n _rev: doc._rev || doc.rev,\n _deleted: true\n };\n }\n return this.post.apply(this, arguments);\n } else {\n var request = this._(arguments, 0, 1);\n // prevent acidentally deleting database\n if (!request.p) throw new Error(\"missing id\");\n return request(\"DELETE\");\n }\n};\n\n/**\n * Copy document.\n *\n * @param {Object} source Source document.\n * @param {String} source.id Source document ID.\n * @param {String} [source.rev] Source document revision.\n * @param {String} [source._id] Source document ID. Alternate key for\n * `source.id`.\n * @param {String} [source._rev] Source document revision. Alternate key\n * for `source.id`.\n * @param {Object} target Target document.\n * @param {String} target.id Target document ID.\n * @param {String} [target.rev] Target document revision.\n * @param {String} [target._id] Target document ID. Alternate key for\n * `target.id`.\n * @param {String} [target._rev] Target document revision. Alternate key\n * for `target.id`.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#COPY|CouchDB Wiki}\n */\n\nDB.prototype.copy = function (source, target /* [query], [headers], [callback] */) {\n var request = this._(arguments, 2);\n var sourcePath = encodeURIComponent(source.id || source._id || source);\n var targetPath = encodeURIComponent(target.id || target._id || target);\n var sourceRev = source.rev || source._rev;\n var targetRev = target.rev || target._rev;\n\n if (sourceRev) request.q.rev = sourceRev;\n if (targetRev) targetPath += \"?rev=\" + encodeURIComponent(targetRev);\n\n request.h.Destination = targetPath;\n\n return request(\"COPY\", sourcePath);\n};\n\n/**\n * Query all documents by ID.\n *\n * @param {Object} [query] HTTP query options.\n * @param {JSON} [query.startkey] Start returning results from this\n * document ID.\n * @param {JSON} [query.endkey] Stop returning results at this document\n * ID.\n * @param {Integer} [query.limit] Limit number of results returned.\n * @param {Boolean} [query.descending=false] Lookup results in reverse\n * order by key, returning documents in descending order by key.\n * @param {Integer} [query.skip] Skip this many records before\n * returning results.\n * @param {Boolean} [query.include_docs=false] Include document source for\n * each result.\n * @param {Boolean} [query.include_end=true] Include `query.endkey`\n * in results.\n * @param {Boolean} [query.update_seq=false] Include sequence value\n * of the database corresponding to the view.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API|CouchDB Wiki}\n */\n\nDB.prototype.all = function (/* [query], [headers], [callback] */) {\n var request = this._(arguments);\n var body = this._viewOptions(request.q);\n return request(body ? \"POST\" : \"GET\", \"_all_docs\", { b: body });\n};\n\n/**\n * Query a view.\n *\n * @param {String|Object} view View name (e.g. mydesign/myview) or\n * temporary view definition. Using a temporary view is strongly not\n * recommended for production use.\n * @param {Object} [query] HTTP query options.\n * @param {JSON} [query.key] Key to lookup.\n * @param {JSON} [query.startkey] Start returning results from this key.\n * @param {String} [query.startkey_docid] Start returning results\n * from this document ID. Allows pagination with duplicate keys.\n * @param {JSON} [query.endkey] Stop returning results at this key.\n * @param {String} [query.endkey_docid] Stop returning results at\n * this document ID. Allows pagination with duplicate keys.\n * @param {Integer} [query.limit] Limit number of results returned.\n * @param {Boolean|String} [query.stale] Do not refresh view even if\n * stale. For CouchDB versions `1.1.0` and up, set to `update_after` to\n * update view after results are returned.\n * @param {Boolean} [query.descending=false] Lookup results in reverse\n * order by key, returning documents in descending order by key.\n * @param {Integer} [query.skip] Skip this many records before\n * returning results.\n * @param {Boolean|Integer} [query.group=false] Use the reduce function\n * to group results by key. Set to an integer specify `group_level`.\n * @param {Boolean|Integer} [query.reduce=true] Use the reduce function.\n * @param {Boolean} [query.fetch=false] Include document source for\n * each result.\n * @param {Boolean} [query.include_end=true] Include `query.endkey`\n * in results.\n * @param {Boolean} [query.update_seq=false] Include sequence value\n * of the database corresponding to the view.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_view_API|CouchDB Wiki}\n */\n\nDB.prototype.find = function (view /* [query], [headers], [callback] */) {\n var request = this._(arguments, 1), path, body;\n\n if (isString(view)) {\n path = view.split(\"/\", 2);\n path = \"_design/\" + encodeURIComponent(path[0]) +\n \"/_view/\" + encodeURIComponent(path[1]);\n } else {\n path = \"_temp_view\";\n body = view;\n }\n\n body = this._viewOptions(request.q, body);\n return request(body ? \"POST\" : \"GET\", path, { b: body });\n};\n\n/**\n * Get database changes.\n *\n * The `feed` option determines how the callback is called:\n *\n * - `normal` calls the callback once.\n * - `longpoll` waits for a response, then calls the callback once.\n * - `continuous` calls the callback each time an update is received.\n * Implemented as the `database#follow()` method.\n *\n * @param {Object} [query] HTTP query options.\n * @param {String} [query.feed=\"normal\"] Type of feed. See comments\n * above.\n * @param {String} [query.filter] Filter updates using this filter.\n * @param {Integer} [query.limit] Maximum number of rows to return.\n * @param {Integer} [query.since=0] Start results from this sequence\n * number.\n * @param {Boolean} [query.include_docs=false] Include documents with\n * results.\n * @param {Integer} [query.timeout=1000] Maximum period in milliseconds\n * to wait for a change before sending a response, even if there are no\n * results.\n * @param {Integer} [query.heartbeat=1000] Period in milliseconds after\n * which an empty line is sent. Applicable only to feed types\n * `longpoll` and `continuous`. Overrides `query.timeout` to keep the\n * feed alive indefinitely.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_database_API#Changes|CouchDB Wiki}\n */\n\nDB.prototype.changes = function (/* [query], [headers], [callback] */) {\n var request = this._(arguments);\n if (request.q.feed != \"longpoll\") delete request.q.feed;\n return this._changes(request);\n};\n\n/**\n * Follow database changes.\n *\n * @see `#changes()`.\n */\n\nDB.prototype.follow = function (/* [query], [headers], callback */) {\n var self = this;\n var request = this._(arguments);\n var fn = request.f;\n\n if (!fn) return this;\n\n request.q.feed = \"longpoll\";\n request.f = function (err, body) {\n var args = [].slice.call(arguments);\n var done, i;\n for (i = 0; i < body.length; i++) {\n args[1] = body[i];\n if (done = fn.apply(self, args) === false || err) break;\n }\n if (!done) self._changes(request);\n };\n\n return this._changes(request);\n};\n\n/**\n * Service a changes request.\n *\n * @private\n */\n\nDB.prototype._changes = function (request) {\n return request(\"GET\", \"_changes\");\n};\n\n/**\n * Update document using server-side handler.\n *\n * @param {String} handler Update handler. Example: mydesign/myhandler\n * @param {String} [id] Document ID.\n * @param {Object} [query] HTTP query options.\n * @param {Object|String} [data] Data.\n * @param {Object} [headers] Headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/Document_Update_Handlers|CouchDB Wiki}\n */\n\nDB.prototype.update = function (handler /* [id], [query], [data], [headers], [callback] */) {\n var request = this._(arguments, 1, 1);\n var path = handler.split(\"/\", 2);\n\n path = \"_design/\" + encodeURIComponent(path[0]) +\n \"/_update/\" + encodeURIComponent(path[1]);\n\n if (request.p) path += \"/\" + request.p;\n\n return request(request.p ? \"PUT\" : \"POST\", path, {\n q: request.b,\n b: request.q\n });\n};\n\n/**\n * Download attachment from document.\n *\n * @param {Object|String} docOrId Document or document ID.\n * @param {String} attachmentName Attachment name.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.attachment = function (doc, attachmentName /* [query], [headers], [callback] */) {\n var request = this._(arguments, 2);\n var path = encodeURIComponent(doc._id || doc.id || doc) + \"/\" +\n encodeURIComponent(attachmentName);\n return request(\"GET\", path, options);\n};\n\n/**\n * Upload attachment to document.\n *\n * Set the `Content-Type` header.\n *\n * @param {Object} [doc] Document. Requires `id`. `rev` can be specified\n * here or in `query`.\n * @param {String} attachmentName Attachment name.\n * @param {Object} data Data.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.attach = function (doc, attachmentName, data /* [query], [headers], [callback] */) {\n var request = this._(arguments, 3);\n request.p = encodeURIComponent(doc._id || doc.id) + \"/\" +\n encodeURIComponent(attachmentName);\n if (!request.q.rev) request.q.rev = doc._rev || doc.rev;\n request.q.body = data;\n return request(\"PUT\", path);\n};\n\n/**\n * Replicate database.\n *\n * This convenience function sets `options.source` and `options.target` to\n * the selected database name. Either `options.source` or `options.target`\n * must be overridden for a successful replication request.\n *\n * @param {Options} options Options. Accepts all options from\n * `Client.replicate()`.\n * @param {String} [options.source=this.name] Source database URL or\n * local name. Defaults to the selected database name if not given.\n * @param {String} [options.target=this.name] Target database URL or\n * local name. Defaults to the selected database name if not given.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.replicate = function (options /* [query], [headers], [callback] */) {\n if (!options.source) options.source = this.name;\n if (!options.target) options.target = this.name;\n return this.client.replicate.apply(this.client, arguments);\n};\n\n/**\n * Ensure recent changes are committed to disk.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.commit = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"POST\", \"_ensure_full_commit\");\n};\n\n/**\n * Purge deleted documents from database.\n *\n * @param {Object} revs Map of document IDs to revisions to be purged.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.purge = function (revs /* [query], [headers], [callback] */) {\n return this._(arguments, 1)(\"POST\", \"_purge\", { b: revs });\n};\n\n/**\n * Compact database or design.\n *\n * @param {String} [design] Design name if compacting design indexes.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/Compaction|CouchDB Wiki}\n */\n\nDB.prototype.compact = function (/* [design], [query], [headers], [callback] */) {\n var request = this._(arguments);\n return request(\"POST\", \"_compact/\" + (request.p || \"\"));\n};\n\n/**\n * Remove unused views.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/Compaction|CouchDB Wiki}\n */\n\nDB.prototype.vacuum = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"POST\", \"_view_cleanup\");\n};\n\n/**\n * Parse view options.\n *\n * @param {Object} query The HTTP query options.\n * @param {Object} body The body payload.\n * @param {handler} [callback] Callback function.\n * @return {Object} The body payload.\n * @private\n */\n\nDB.prototype._viewOptions = function (q, body) {\n if (q) {\n if (q.key) q.key = JSON.stringify(q.key);\n if (q.startkey) q.startkey = JSON.stringify(q.startkey);\n if (q.endkey) q.endkey = JSON.stringify(q.endkey);\n if (q.stale && q.stale != \"update_after\") q.stale = \"ok\";\n if (q.keys) {\n if (!body) body = {};\n body.keys = q.keys;\n delete q.keys;\n }\n }\n return body;\n};\n\n/**\n * Handle a clerk response.\n *\n * @callback handler\n * @param {Error|null} error Error or `null` on success.\n * @param {Object} data Response data.\n * @param {Integer} status Response status code.\n * @param {Object} headers Response headers.\n * @param {superagent.Response} res Superagent response object.\n */\n\nclerk.Base = Base;\nclerk.Client = Client;\nclerk.DB = DB;\n\n/**\n * Export clerk.\n */\n\nmodule.exports = clerk;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./clerk.js\n ** module id = 0\n ** module chunks = 0\n **/","/**\n * Module dependencies.\n */\n\nvar Emitter = require('emitter');\nvar reduce = require('reduce');\n\n/**\n * Root reference for iframes.\n */\n\nvar root = 'undefined' == typeof window\n ? this\n : window;\n\n/**\n * Noop.\n */\n\nfunction noop(){};\n\n/**\n * Check if `obj` is a host object,\n * we don't want to serialize these :)\n *\n * TODO: future proof, move to compoent land\n *\n * @param {Object} obj\n * @return {Boolean}\n * @api private\n */\n\nfunction isHost(obj) {\n var str = {}.toString.call(obj);\n\n switch (str) {\n case '[object File]':\n case '[object Blob]':\n case '[object FormData]':\n return true;\n default:\n return false;\n }\n}\n\n/**\n * Determine XHR.\n */\n\nfunction getXHR() {\n if (root.XMLHttpRequest\n && ('file:' != root.location.protocol || !root.ActiveXObject)) {\n return new XMLHttpRequest;\n } else {\n try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) {}\n }\n return false;\n}\n\n/**\n * Removes leading and trailing whitespace, added to support IE.\n *\n * @param {String} s\n * @return {String}\n * @api private\n */\n\nvar trim = ''.trim\n ? function(s) { return s.trim(); }\n : function(s) { return s.replace(/(^\\s*|\\s*$)/g, ''); };\n\n/**\n * Check if `obj` is an object.\n *\n * @param {Object} obj\n * @return {Boolean}\n * @api private\n */\n\nfunction isObject(obj) {\n return obj === Object(obj);\n}\n\n/**\n * Serialize the given `obj`.\n *\n * @param {Object} obj\n * @return {String}\n * @api private\n */\n\nfunction serialize(obj) {\n if (!isObject(obj)) return obj;\n var pairs = [];\n for (var key in obj) {\n if (null != obj[key]) {\n pairs.push(encodeURIComponent(key)\n + '=' + encodeURIComponent(obj[key]));\n }\n }\n return pairs.join('&');\n}\n\n/**\n * Expose serialization method.\n */\n\n request.serializeObject = serialize;\n\n /**\n * Parse the given x-www-form-urlencoded `str`.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\nfunction parseString(str) {\n var obj = {};\n var pairs = str.split('&');\n var parts;\n var pair;\n\n for (var i = 0, len = pairs.length; i < len; ++i) {\n pair = pairs[i];\n parts = pair.split('=');\n obj[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]);\n }\n\n return obj;\n}\n\n/**\n * Expose parser.\n */\n\nrequest.parseString = parseString;\n\n/**\n * Default MIME type map.\n *\n * superagent.types.xml = 'application/xml';\n *\n */\n\nrequest.types = {\n html: 'text/html',\n json: 'application/json',\n xml: 'application/xml',\n urlencoded: 'application/x-www-form-urlencoded',\n 'form': 'application/x-www-form-urlencoded',\n 'form-data': 'application/x-www-form-urlencoded'\n};\n\n/**\n * Default serialization map.\n *\n * superagent.serialize['application/xml'] = function(obj){\n * return 'generated xml here';\n * };\n *\n */\n\n request.serialize = {\n 'application/x-www-form-urlencoded': serialize,\n 'application/json': JSON.stringify\n };\n\n /**\n * Default parsers.\n *\n * superagent.parse['application/xml'] = function(str){\n * return { object parsed from str };\n * };\n *\n */\n\nrequest.parse = {\n 'application/x-www-form-urlencoded': parseString,\n 'application/json': JSON.parse\n};\n\n/**\n * Parse the given header `str` into\n * an object containing the mapped fields.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\nfunction parseHeader(str) {\n var lines = str.split(/\\r?\\n/);\n var fields = {};\n var index;\n var line;\n var field;\n var val;\n\n lines.pop(); // trailing CRLF\n\n for (var i = 0, len = lines.length; i < len; ++i) {\n line = lines[i];\n index = line.indexOf(':');\n field = line.slice(0, index).toLowerCase();\n val = trim(line.slice(index + 1));\n fields[field] = val;\n }\n\n return fields;\n}\n\n/**\n * Return the mime type for the given `str`.\n *\n * @param {String} str\n * @return {String}\n * @api private\n */\n\nfunction type(str){\n return str.split(/ *; */).shift();\n};\n\n/**\n * Return header field parameters.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\nfunction params(str){\n return reduce(str.split(/ *; */), function(obj, str){\n var parts = str.split(/ *= */)\n , key = parts.shift()\n , val = parts.shift();\n\n if (key && val) obj[key] = val;\n return obj;\n }, {});\n};\n\n/**\n * Initialize a new `Response` with the given `xhr`.\n *\n * - set flags (.ok, .error, etc)\n * - parse header\n *\n * Examples:\n *\n * Aliasing `superagent` as `request` is nice:\n *\n * request = superagent;\n *\n * We can use the promise-like API, or pass callbacks:\n *\n * request.get('/').end(function(res){});\n * request.get('/', function(res){});\n *\n * Sending data can be chained:\n *\n * request\n * .post('/user')\n * .send({ name: 'tj' })\n * .end(function(res){});\n *\n * Or passed to `.send()`:\n *\n * request\n * .post('/user')\n * .send({ name: 'tj' }, function(res){});\n *\n * Or passed to `.post()`:\n *\n * request\n * .post('/user', { name: 'tj' })\n * .end(function(res){});\n *\n * Or further reduced to a single call for simple cases:\n *\n * request\n * .post('/user', { name: 'tj' }, function(res){});\n *\n * @param {XMLHTTPRequest} xhr\n * @param {Object} options\n * @api private\n */\n\nfunction Response(req, options) {\n options = options || {};\n this.req = req;\n this.xhr = this.req.xhr;\n this.text = this.req.method !='HEAD' \n ? this.xhr.responseText \n : null;\n this.setStatusProperties(this.xhr.status);\n this.header = this.headers = parseHeader(this.xhr.getAllResponseHeaders());\n // getAllResponseHeaders sometimes falsely returns \"\" for CORS requests, but\n // getResponseHeader still works. so we get content-type even if getting\n // other headers fails.\n this.header['content-type'] = this.xhr.getResponseHeader('content-type');\n this.setHeaderProperties(this.header);\n this.body = this.req.method != 'HEAD'\n ? this.parseBody(this.text)\n : null;\n}\n\n/**\n * Get case-insensitive `field` value.\n *\n * @param {String} field\n * @return {String}\n * @api public\n */\n\nResponse.prototype.get = function(field){\n return this.header[field.toLowerCase()];\n};\n\n/**\n * Set header related properties:\n *\n * - `.type` the content type without params\n *\n * A response of \"Content-Type: text/plain; charset=utf-8\"\n * will provide you with a `.type` of \"text/plain\".\n *\n * @param {Object} header\n * @api private\n */\n\nResponse.prototype.setHeaderProperties = function(header){\n // content-type\n var ct = this.header['content-type'] || '';\n this.type = type(ct);\n\n // params\n var obj = params(ct);\n for (var key in obj) this[key] = obj[key];\n};\n\n/**\n * Parse the given body `str`.\n *\n * Used for auto-parsing of bodies. Parsers\n * are defined on the `superagent.parse` object.\n *\n * @param {String} str\n * @return {Mixed}\n * @api private\n */\n\nResponse.prototype.parseBody = function(str){\n var parse = request.parse[this.type];\n return parse && str && str.length\n ? parse(str)\n : null;\n};\n\n/**\n * Set flags such as `.ok` based on `status`.\n *\n * For example a 2xx response will give you a `.ok` of __true__\n * whereas 5xx will be __false__ and `.error` will be __true__. The\n * `.clientError` and `.serverError` are also available to be more\n * specific, and `.statusType` is the class of error ranging from 1..5\n * sometimes useful for mapping respond colors etc.\n *\n * \"sugar\" properties are also defined for common cases. Currently providing:\n *\n * - .noContent\n * - .badRequest\n * - .unauthorized\n * - .notAcceptable\n * - .notFound\n *\n * @param {Number} status\n * @api private\n */\n\nResponse.prototype.setStatusProperties = function(status){\n var type = status / 100 | 0;\n\n // status / class\n this.status = status;\n this.statusType = type;\n\n // basics\n this.info = 1 == type;\n this.ok = 2 == type;\n this.clientError = 4 == type;\n this.serverError = 5 == type;\n this.error = (4 == type || 5 == type)\n ? this.toError()\n : false;\n\n // sugar\n this.accepted = 202 == status;\n this.noContent = 204 == status || 1223 == status;\n this.badRequest = 400 == status;\n this.unauthorized = 401 == status;\n this.notAcceptable = 406 == status;\n this.notFound = 404 == status;\n this.forbidden = 403 == status;\n};\n\n/**\n * Return an `Error` representative of this response.\n *\n * @return {Error}\n * @api public\n */\n\nResponse.prototype.toError = function(){\n var req = this.req;\n var method = req.method;\n var url = req.url;\n\n var msg = 'cannot ' + method + ' ' + url + ' (' + this.status + ')';\n var err = new Error(msg);\n err.status = this.status;\n err.method = method;\n err.url = url;\n\n return err;\n};\n\n/**\n * Expose `Response`.\n */\n\nrequest.Response = Response;\n\n/**\n * Initialize a new `Request` with the given `method` and `url`.\n *\n * @param {String} method\n * @param {String} url\n * @api public\n */\n\nfunction Request(method, url) {\n var self = this;\n Emitter.call(this);\n this._query = this._query || [];\n this.method = method;\n this.url = url;\n this.header = {};\n this._header = {};\n this.on('end', function(){\n var err = null;\n var res = null;\n\n try {\n res = new Response(self); \n } catch(e) {\n err = new Error('Parser is unable to parse the response');\n err.parse = true;\n err.original = e;\n }\n\n self.callback(err, res);\n });\n}\n\n/**\n * Mixin `Emitter`.\n */\n\nEmitter(Request.prototype);\n\n/**\n * Allow for extension\n */\n\nRequest.prototype.use = function(fn) {\n fn(this);\n return this;\n}\n\n/**\n * Set timeout to `ms`.\n *\n * @param {Number} ms\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.timeout = function(ms){\n this._timeout = ms;\n return this;\n};\n\n/**\n * Clear previous timeout.\n *\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.clearTimeout = function(){\n this._timeout = 0;\n clearTimeout(this._timer);\n return this;\n};\n\n/**\n * Abort the request, and clear potential timeout.\n *\n * @return {Request}\n * @api public\n */\n\nRequest.prototype.abort = function(){\n if (this.aborted) return;\n this.aborted = true;\n this.xhr.abort();\n this.clearTimeout();\n this.emit('abort');\n return this;\n};\n\n/**\n * Set header `field` to `val`, or multiple fields with one object.\n *\n * Examples:\n *\n * req.get('/')\n * .set('Accept', 'application/json')\n * .set('X-API-Key', 'foobar')\n * .end(callback);\n *\n * req.get('/')\n * .set({ Accept: 'application/json', 'X-API-Key': 'foobar' })\n * .end(callback);\n *\n * @param {String|Object} field\n * @param {String} val\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.set = function(field, val){\n if (isObject(field)) {\n for (var key in field) {\n this.set(key, field[key]);\n }\n return this;\n }\n this._header[field.toLowerCase()] = val;\n this.header[field] = val;\n return this;\n};\n\n/**\n * Remove header `field`.\n *\n * Example:\n *\n * req.get('/')\n * .unset('User-Agent')\n * .end(callback);\n *\n * @param {String} field\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.unset = function(field){\n delete this._header[field.toLowerCase()];\n delete this.header[field];\n return this;\n};\n\n/**\n * Get case-insensitive header `field` value.\n *\n * @param {String} field\n * @return {String}\n * @api private\n */\n\nRequest.prototype.getHeader = function(field){\n return this._header[field.toLowerCase()];\n};\n\n/**\n * Set Content-Type to `type`, mapping values from `request.types`.\n *\n * Examples:\n *\n * superagent.types.xml = 'application/xml';\n *\n * request.post('/')\n * .type('xml')\n * .send(xmlstring)\n * .end(callback);\n *\n * request.post('/')\n * .type('application/xml')\n * .send(xmlstring)\n * .end(callback);\n *\n * @param {String} type\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.type = function(type){\n this.set('Content-Type', request.types[type] || type);\n return this;\n};\n\n/**\n * Set Accept to `type`, mapping values from `request.types`.\n *\n * Examples:\n *\n * superagent.types.json = 'application/json';\n *\n * request.get('/agent')\n * .accept('json')\n * .end(callback);\n *\n * request.get('/agent')\n * .accept('application/json')\n * .end(callback);\n *\n * @param {String} accept\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.accept = function(type){\n this.set('Accept', request.types[type] || type);\n return this;\n};\n\n/**\n * Set Authorization field value with `user` and `pass`.\n *\n * @param {String} user\n * @param {String} pass\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.auth = function(user, pass){\n var str = btoa(user + ':' + pass);\n this.set('Authorization', 'Basic ' + str);\n return this;\n};\n\n/**\n* Add query-string `val`.\n*\n* Examples:\n*\n* request.get('/shoes')\n* .query('size=10')\n* .query({ color: 'blue' })\n*\n* @param {Object|String} val\n* @return {Request} for chaining\n* @api public\n*/\n\nRequest.prototype.query = function(val){\n if ('string' != typeof val) val = serialize(val);\n if (val) this._query.push(val);\n return this;\n};\n\n/**\n * Write the field `name` and `val` for \"multipart/form-data\"\n * request bodies.\n *\n * ``` js\n * request.post('/upload')\n * .field('foo', 'bar')\n * .end(callback);\n * ```\n *\n * @param {String} name\n * @param {String|Blob|File} val\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.field = function(name, val){\n if (!this._formData) this._formData = new FormData();\n this._formData.append(name, val);\n return this;\n};\n\n/**\n * Queue the given `file` as an attachment to the specified `field`,\n * with optional `filename`.\n *\n * ``` js\n * request.post('/upload')\n * .attach(new Blob(['hey!'], { type: \"text/html\"}))\n * .end(callback);\n * ```\n *\n * @param {String} field\n * @param {Blob|File} file\n * @param {String} filename\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.attach = function(field, file, filename){\n if (!this._formData) this._formData = new FormData();\n this._formData.append(field, file, filename);\n return this;\n};\n\n/**\n * Send `data`, defaulting the `.type()` to \"json\" when\n * an object is given.\n *\n * Examples:\n *\n * // querystring\n * request.get('/search')\n * .end(callback)\n *\n * // multiple data \"writes\"\n * request.get('/search')\n * .send({ search: 'query' })\n * .send({ range: '1..5' })\n * .send({ order: 'desc' })\n * .end(callback)\n *\n * // manual json\n * request.post('/user')\n * .type('json')\n * .send('{\"name\":\"tj\"})\n * .end(callback)\n *\n * // auto json\n * request.post('/user')\n * .send({ name: 'tj' })\n * .end(callback)\n *\n * // manual x-www-form-urlencoded\n * request.post('/user')\n * .type('form')\n * .send('name=tj')\n * .end(callback)\n *\n * // auto x-www-form-urlencoded\n * request.post('/user')\n * .type('form')\n * .send({ name: 'tj' })\n * .end(callback)\n *\n * // defaults to x-www-form-urlencoded\n * request.post('/user')\n * .send('name=tobi')\n * .send('species=ferret')\n * .end(callback)\n *\n * @param {String|Object} data\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.send = function(data){\n var obj = isObject(data);\n var type = this.getHeader('Content-Type');\n\n // merge\n if (obj && isObject(this._data)) {\n for (var key in data) {\n this._data[key] = data[key];\n }\n } else if ('string' == typeof data) {\n if (!type) this.type('form');\n type = this.getHeader('Content-Type');\n if ('application/x-www-form-urlencoded' == type) {\n this._data = this._data\n ? this._data + '&' + data\n : data;\n } else {\n this._data = (this._data || '') + data;\n }\n } else {\n this._data = data;\n }\n\n if (!obj) return this;\n if (!type) this.type('json');\n return this;\n};\n\n/**\n * Invoke the callback with `err` and `res`\n * and handle arity check.\n *\n * @param {Error} err\n * @param {Response} res\n * @api private\n */\n\nRequest.prototype.callback = function(err, res){\n var fn = this._callback;\n this.clearTimeout();\n if (2 == fn.length) return fn(err, res);\n if (err) return this.emit('error', err);\n fn(res);\n};\n\n/**\n * Invoke callback with x-domain error.\n *\n * @api private\n */\n\nRequest.prototype.crossDomainError = function(){\n var err = new Error('Origin is not allowed by Access-Control-Allow-Origin');\n err.crossDomain = true;\n this.callback(err);\n};\n\n/**\n * Invoke callback with timeout error.\n *\n * @api private\n */\n\nRequest.prototype.timeoutError = function(){\n var timeout = this._timeout;\n var err = new Error('timeout of ' + timeout + 'ms exceeded');\n err.timeout = timeout;\n this.callback(err);\n};\n\n/**\n * Enable transmission of cookies with x-domain requests.\n *\n * Note that for this to work the origin must not be\n * using \"Access-Control-Allow-Origin\" with a wildcard,\n * and also must set \"Access-Control-Allow-Credentials\"\n * to \"true\".\n *\n * @api public\n */\n\nRequest.prototype.withCredentials = function(){\n this._withCredentials = true;\n return this;\n};\n\n/**\n * Initiate request, invoking callback `fn(res)`\n * with an instanceof `Response`.\n *\n * @param {Function} fn\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.end = function(fn){\n var self = this;\n var xhr = this.xhr = getXHR();\n var query = this._query.join('&');\n var timeout = this._timeout;\n var data = this._formData || this._data;\n\n // store callback\n this._callback = fn || noop;\n\n // state change\n xhr.onreadystatechange = function(){\n if (4 != xhr.readyState) return;\n if (0 == xhr.status) {\n if (self.aborted) return self.timeoutError();\n return self.crossDomainError();\n }\n self.emit('end');\n };\n\n // progress\n if (xhr.upload) {\n xhr.upload.onprogress = function(e){\n e.percent = e.loaded / e.total * 100;\n self.emit('progress', e);\n };\n }\n\n // timeout\n if (timeout && !this._timer) {\n this._timer = setTimeout(function(){\n self.abort();\n }, timeout);\n }\n\n // querystring\n if (query) {\n query = request.serializeObject(query);\n this.url += ~this.url.indexOf('?')\n ? '&' + query\n : '?' + query;\n }\n\n // initiate request\n xhr.open(this.method, this.url, true);\n\n // CORS\n if (this._withCredentials) xhr.withCredentials = true;\n\n // body\n if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !isHost(data)) {\n // serialize stuff\n var serialize = request.serialize[this.getHeader('Content-Type')];\n if (serialize) data = serialize(data);\n }\n\n // set header fields\n for (var field in this.header) {\n if (null == this.header[field]) continue;\n xhr.setRequestHeader(field, this.header[field]);\n }\n\n // send stuff\n this.emit('request', this);\n xhr.send(data);\n return this;\n};\n\n/**\n * Expose `Request`.\n */\n\nrequest.Request = Request;\n\n/**\n * Issue a request:\n *\n * Examples:\n *\n * request('GET', '/users').end(callback)\n * request('/users').end(callback)\n * request('/users', callback)\n *\n * @param {String} method\n * @param {String|Function} url or callback\n * @return {Request}\n * @api public\n */\n\nfunction request(method, url) {\n // callback\n if ('function' == typeof url) {\n return new Request('GET', method).end(url);\n }\n\n // url first\n if (1 == arguments.length) {\n return new Request('GET', method);\n }\n\n return new Request(method, url);\n}\n\n/**\n * GET `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} data or fn\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.get = function(url, data, fn){\n var req = request('GET', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.query(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * HEAD `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} data or fn\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.head = function(url, data, fn){\n var req = request('HEAD', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * DELETE `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.del = function(url, fn){\n var req = request('DELETE', url);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * PATCH `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed} data\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.patch = function(url, data, fn){\n var req = request('PATCH', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * POST `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed} data\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.post = function(url, data, fn){\n var req = request('POST', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * PUT `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} data or fn\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.put = function(url, data, fn){\n var req = request('PUT', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * Expose `request`.\n */\n\nmodule.exports = request;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/superagent/lib/client.js\n ** module id = 1\n ** module chunks = 0\n **/","\n/**\n * Expose `Emitter`.\n */\n\nmodule.exports = Emitter;\n\n/**\n * Initialize a new `Emitter`.\n *\n * @api public\n */\n\nfunction Emitter(obj) {\n if (obj) return mixin(obj);\n};\n\n/**\n * Mixin the emitter properties.\n *\n * @param {Object} obj\n * @return {Object}\n * @api private\n */\n\nfunction mixin(obj) {\n for (var key in Emitter.prototype) {\n obj[key] = Emitter.prototype[key];\n }\n return obj;\n}\n\n/**\n * Listen on the given `event` with `fn`.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.on =\nEmitter.prototype.addEventListener = function(event, fn){\n this._callbacks = this._callbacks || {};\n (this._callbacks[event] = this._callbacks[event] || [])\n .push(fn);\n return this;\n};\n\n/**\n * Adds an `event` listener that will be invoked a single\n * time then automatically removed.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.once = function(event, fn){\n var self = this;\n this._callbacks = this._callbacks || {};\n\n function on() {\n self.off(event, on);\n fn.apply(this, arguments);\n }\n\n on.fn = fn;\n this.on(event, on);\n return this;\n};\n\n/**\n * Remove the given callback for `event` or all\n * registered callbacks.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.off =\nEmitter.prototype.removeListener =\nEmitter.prototype.removeAllListeners =\nEmitter.prototype.removeEventListener = function(event, fn){\n this._callbacks = this._callbacks || {};\n\n // all\n if (0 == arguments.length) {\n this._callbacks = {};\n return this;\n }\n\n // specific event\n var callbacks = this._callbacks[event];\n if (!callbacks) return this;\n\n // remove all handlers\n if (1 == arguments.length) {\n delete this._callbacks[event];\n return this;\n }\n\n // remove specific handler\n var cb;\n for (var i = 0; i < callbacks.length; i++) {\n cb = callbacks[i];\n if (cb === fn || cb.fn === fn) {\n callbacks.splice(i, 1);\n break;\n }\n }\n return this;\n};\n\n/**\n * Emit `event` with the given args.\n *\n * @param {String} event\n * @param {Mixed} ...\n * @return {Emitter}\n */\n\nEmitter.prototype.emit = function(event){\n this._callbacks = this._callbacks || {};\n var args = [].slice.call(arguments, 1)\n , callbacks = this._callbacks[event];\n\n if (callbacks) {\n callbacks = callbacks.slice(0);\n for (var i = 0, len = callbacks.length; i < len; ++i) {\n callbacks[i].apply(this, args);\n }\n }\n\n return this;\n};\n\n/**\n * Return array of callbacks for `event`.\n *\n * @param {String} event\n * @return {Array}\n * @api public\n */\n\nEmitter.prototype.listeners = function(event){\n this._callbacks = this._callbacks || {};\n return this._callbacks[event] || [];\n};\n\n/**\n * Check if this emitter has `event` handlers.\n *\n * @param {String} event\n * @return {Boolean}\n * @api public\n */\n\nEmitter.prototype.hasListeners = function(event){\n return !! this.listeners(event).length;\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/superagent/~/component-emitter/index.js\n ** module id = 2\n ** module chunks = 0\n **/","\n/**\n * Reduce `arr` with `fn`.\n *\n * @param {Array} arr\n * @param {Function} fn\n * @param {Mixed} initial\n *\n * TODO: combatible error handling?\n */\n\nmodule.exports = function(arr, fn, initial){ \n var idx = 0;\n var len = arr.length;\n var curr = arguments.length == 3\n ? initial\n : arr[idx++];\n\n while (idx < len) {\n curr = fn.call(null, curr, arr[idx], ++idx, arr);\n }\n \n return curr;\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/superagent/~/reduce-component/index.js\n ** module id = 3\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///clerk.min.js","webpack:///webpack/bootstrap 4944304139d62c483cfe","webpack:///./clerk.js","webpack:///./~/superagent/lib/client.js","webpack:///./~/superagent/~/component-emitter/index.js","webpack:///./~/superagent/~/reduce-component/index.js"],"names":["this","modules","__webpack_require__","moduleId","installedModules","exports","module","id","loaded","call","m","c","p","clerk","uri","make","Base","Client","auth","_db","DB","client","name","encodeURIComponent","request","extend","target","source","key","i","arguments","asString","that","Object","prototype","toString","isString","isArray","isFunction","version","defaultHost","_parseURI","db","exec","path","substr","index","decodeURIComponent","btoa","base","Buffer","str","match","replace","args","slice","callback","length","pop","_request","method","query","data","headers","fn","options","send","g","_","apply","self","_do","body","JSON","stringify","test","_replacer","promise","req","Promise","resolve","reject","err","status","res","defineProperties","_status","value","_headers","_response","abort","Error","set","withCredentials","end","error","_error","text","header","json","len","item","rows","results","uuids","meta","_meta","doc","reason","code","val","proto","hasId","_id","hasRev","_rev","rev","start","withDoc","q","b","h","f","encodeURI","shift","dbs","count","info","stats","log","tasks","config","replicate","create","destroy","exists","get","head","etag","parse","contentType","contentLength","post","docs","put","del","_deleted","copy","sourcePath","targetPath","sourceRev","targetRev","Destination","all","_viewOptions","find","view","split","changes","feed","_changes","follow","done","update","handler","attachment","attachmentName","attach","commit","purge","revs","compact","vacuum","startkey","endkey","stale","keys","noop","isHost","obj","getXHR","root","XMLHttpRequest","location","protocol","ActiveXObject","e","isObject","serialize","pairs","push","join","parseString","parts","pair","parseHeader","line","field","lines","fields","indexOf","toLowerCase","trim","type","params","reduce","Response","xhr","responseText","setStatusProperties","getAllResponseHeaders","getResponseHeader","setHeaderProperties","parseBody","Request","url","Emitter","_query","_header","on","original","window","s","serializeObject","types","html","xml","urlencoded","form","form-data","application/x-www-form-urlencoded","application/json","ct","statusType","ok","clientError","serverError","toError","accepted","noContent","badRequest","unauthorized","notAcceptable","notFound","forbidden","msg","use","timeout","ms","_timeout","clearTimeout","_timer","aborted","emit","unset","getHeader","accept","user","pass","_formData","FormData","append","file","filename","_data","_callback","crossDomainError","crossDomain","timeoutError","_withCredentials","onreadystatechange","readyState","upload","onprogress","percent","total","setTimeout","open","setRequestHeader","patch","mixin","addEventListener","event","_callbacks","once","off","removeListener","removeAllListeners","removeEventListener","callbacks","cb","splice","listeners","hasListeners","arr","initial","idx","curr"],"mappings":"AAAAA,KAAY,MACH,SAAUC,GCGnB,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAE,OAGA,IAAAC,GAAAF,EAAAD,IACAE,WACAE,GAAAJ,EACAK,QAAA,EAUA,OANAP,GAAAE,GAAAM,KAAAH,EAAAD,QAAAC,IAAAD,QAAAH,GAGAI,EAAAE,QAAA,EAGAF,EAAAD,QAvBA,GAAAD,KAqCA,OATAF,GAAAQ,EAAAT,EAGAC,EAAAS,EAAAP,EAGAF,EAAAU,EAAA,GAGAV,EAAA,KDOM,SAASI,EAAQD,EAASH,GE7ChC,YAgHA,SAAAW,GAAAC,GACA,MAAAD,GAAAE,KAAAD,GA2FA,QAAAE,MA0TA,QAAAC,GAAAH,EAAAI,GACAlB,KAAAc,MACAd,KAAAmB,OACAnB,KAAAkB,OA4KA,QAAAE,GAAAC,EAAAC,EAAAJ,GACAlB,KAAAqB,SACArB,KAAAsB,OACAtB,KAAAc,IAAAO,EAAAP,IAAA,IAAAS,mBAAAD,GACAtB,KAAAkB;;;;;;;;;;;;;;;;;;AAnqBA,GAAAM,GAAAtB,EAAA,GAWAuB,EAAA,SAAAC,GAEA,IADA,GAAAC,GAAAC,EAAAC,EAAA,EACAF,EAAAG,UAAAD,MACA,IAAAD,IAAAD,GAAAD,EAAAE,GAAAD,EAAAC,EAEA,OAAAF,IAWAK,EAAA,SAAAC,GACA,MAAAC,QAAAC,UAAAC,SAAA1B,KAAAuB,IAWAI,EAAA,SAAAJ,GACA,yBAAAD,EAAAC,IAuBAK,EAAA,SAAAL,GACA,wBAAAD,EAAAC,IAWAM,EAAA,SAAAN,GACA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AD,EACA,KAAAO,EAAA,MAAAjS,KAGA,OAAA8B,UAAA2B,OAEA,aADAzD,MAAA2R,WAAAD,GACA1R,IAKA,QADAkS,GACArQ,EAAA,EAAiBA,EAAAoQ,EAAAxO,OAAsB5B,IAEvC,GADAqQ,EAAAD,EAAApQ,GACAqQ,IAAAlO,GAAAkO,EAAAlO,OAAA,CACAiO,EAAAE,OAAAtQ,EAAA,EACA,OAGA,MAAA7B,OAWAwN,EAAAtL,UAAA2N,KAAA,SAAA6B,GACA1R,KAAA2R,WAAA3R,KAAA2R,cACA,IAAArO,MAAAC,MAAA9C,KAAAqB,UAAA,GACAmQ,EAAAjS,KAAA2R,WAAAD,EAEA,IAAAO,EAAA,CACAA,IAAA1O,MAAA,EACA,QAAA1B,GAAA,EAAAuE,EAAA6L,EAAAxO,OAA2C2C,EAAAvE,IAASA,EACpDoQ,EAAApQ,GAAAwC,MAAArE,KAAAsD,GAIA,MAAAtD,OAWAwN,EAAAtL,UAAAkQ,UAAA,SAAAV,GAEA,MADA1R,MAAA2R,WAAA3R,KAAA2R,eACA3R,KAAA2R,WAAAD,QAWAlE,EAAAtL,UAAAmQ,aAAA,SAAAX,GACA,QAAA1R,KAAAoS,UAAAV,GAAAjO,SJo5EM,SAASnD,GK3iFfA,EAAAD,QAAA,SAAAiS,EAAAtO,EAAAuO,GAOA,IANA,GAAAC,GAAA,EACApM,EAAAkM,EAAA7O,OACAgP,EAAA,GAAA3Q,UAAA2B,OACA8O,EACAD,EAAAE,KAEApM,EAAAoM,GACAC,EAAAzO,EAAAvD,KAAA,KAAAgS,EAAAH,EAAAE,OAAAF,EAGA,OAAAG","file":"clerk.min.js","sourcesContent":["this[\"clerk\"] =\n/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n/*!\n\nclerk - CouchDB client for node and the browser.\nCopyright 2012-2015 Michael Phan-Ba\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n*/\n\n// Module dependencies.\nvar request = __webpack_require__(1);\n\n/**\n * Copy properties from sources to target.\n *\n * @param {Object} target The target object.\n * @param {...Object} sources The source object.\n * @return {Object} The target object.\n * @private\n */\n\nvar extend = function (target /* ...sources */) {\n var source, key, i = 1;\n while (source = arguments[i++]) {\n for (key in source) target[key] = source[key];\n }\n return target;\n};\n\n/**\n * Stringify value.\n *\n * @param {Object} that That value to stringify.\n * @return {String} The stringifyed value.\n * @private\n */\n\nvar asString = function (that) {\n return Object.prototype.toString.call(that);\n};\n\n/**\n * Check if value is a string.\n *\n * @param {Object} that That value to check.\n * @return {Boolean} `true` if string, `false` otherwise.\n * @private\n */\n\nvar isString = function (that) {\n return asString(that) == \"[object String]\";\n};\n\n/**\n * Check if value is an object.\n *\n * @param {Object} that That value to check.\n * @return {Boolean} `true` if object, `false` otherwise.\n * @private\n */\n\nvar isObject = function (that) {\n return asString(that) == \"[object Object]\";\n};\n\n/**\n * Check if value is an array.\n *\n * @param {Object} that That value to check.\n * @return {Boolean} `true` if array, `false` otherwise.\n * @private\n */\n\nvar isArray = function (that) {\n return asString(that) == \"[object Array]\";\n};\n\n/**\n * Check if value is a function.\n *\n * @param {Object} that That value to check.\n * @return {Boolean} `true` if function, `false` otherwise.\n * @private\n */\n\nvar isFunction = function (that) {\n return asString(that) == \"[object Function]\";\n};\n\n/**\n * Clerk library entry point.\n *\n * @param {String} uri CouchDB server URI.\n * @return {Client|DB} If a URI path is given, returns a `DB`, otherwise\n * returns a `Client`.\n * @see {@link http://docs.couchdb.org|CouchDB Documentation}\n * @see {@link http://guide.couchdb.org/|CouchDB Guide}\n * @see {@link http://wiki.apache.org/couchdb/|CouchDB Wiki}\n */\n\nfunction clerk (uri) {\n return clerk.make(uri);\n};\n\n/**\n * Library version.\n * @type {String}\n */\n\nclerk.version = \"0.8.0\";\n\n/**\n * Default host.\n * @type {String}\n */\n\nclerk.defaultHost = \"http://127.0.0.1:5984\";\n\n/**\n * Create single CouchDB client.\n *\n * @param {String} uri Fully qualified URI.\n * @return {Client|DB} If `uri` has a path, the last segment of the\n * path is used as the database name and a `DB` instance is\n * returned. Otherwise, a `Client` instance is returned.\n */\n\nclerk.make = function (uri) {\n if (!uri) return new Client(this.defaultHost);\n\n uri = clerk._parseURI(uri);\n\n var db = /\\/*([^\\/]+)\\/*$/.exec(uri.path);\n if (db) {\n uri.path = uri.path.substr(0, db.index);\n db = db[1] && decodeURIComponent(db[1]);\n }\n\n // weird way of doing it, but it's more efficient...\n if (uri.auth) uri.auth = 'Basic ' + clerk.btoa(uri.auth);\n\n var client = new clerk.Client(uri.base + uri.path, uri.auth);\n return db ? client.db(db) : client;\n};\n\n/**\n * Base64-encode a string.\n *\n * @param {String} str\n * @return {String}\n */\n\nclerk.btoa = typeof Buffer != \"undefined\" ? function (str) {\n return new Buffer(str).toString(\"base64\");\n} : function (str) {\n return btoa(str);\n};\n\n/**\n * Parse URI.\n *\n * The URI is normalized by removing extra `//` in the path.\n *\n * @param {String} uri Fully qualified URI.\n * @return {String} The normalized URI.\n * @private\n */\n\nclerk._parseURI = function (uri) {\n var match;\n\n if (uri) {\n if (match = /^(https?:\\/\\/)(?:([^\\/@]+)@)?([^\\/]+)(.*)\\/*$/.exec(uri)) {\n return {\n base: match[1] + match[3].replace(/\\/+/g, \"\\/\"),\n path: match[4],\n auth: match[2] && decodeURIComponent(match[2])\n };\n }\n }\n\n return { base: uri || \"\", path: \"\" };\n};\n\n/**\n * Base prototype for `Client` and `DB`.\n * Encapsulates HTTP methods, JSON handling, and response coersion.\n *\n * @constructor\n * @memberof clerk\n */\n\nfunction Base () {};\n\n/**\n * Service request and parse JSON response.\n *\n * @param {String} [method=GET] HTTP method.\n * @param {String} [path=this.uri] HTTP URI.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [body] HTTP body.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nBase.prototype.request = function (/* [method], [path], [query], [body], [headers], [callback] */) {\n var args = [].slice.call(arguments);\n var callback = isFunction (args[args.length - 1]) && args.pop();\n\n return this._request({\n method: args[0],\n path: args[1],\n query: args[2],\n data: args[3],\n headers: args[4],\n fn: callback\n });\n};\n\n/**\n * Internal service request and parse JSON response handler.\n *\n * @param {String} options\n * @param {String} method HTTP method.\n * @param {String} path HTTP URI.\n * @param {Object} query HTTP query options.\n * @param {Object} data HTTP body data.\n * @param {Object} headers HTTP headers.\n * @param {handler} [callback] Callback function.\n * @private\n */\n\nBase.prototype._request = function (options) {\n var self = this;\n\n if (options.method == null) options.method = \"GET\";\n if (options.headers == null) options.headers = {};\n if (options.auth == null) options.auth = this.auth;\n\n options.path = options.path ? \"/\" + options.path : \"\";\n\n // set default headers\n if (options.headers[\"Content-Type\"] == null) {\n options.headers[\"Content-Type\"] = \"application/json\";\n }\n if (options.headers[\"Accept\"] == null) {\n options.headers[\"Accept\"] = \"application/json\";\n }\n if (this.auth && options.headers[\"Authorization\"] == null) {\n options.headers[\"Authorization\"] = this.auth;\n }\n\n options.uri = this.uri + options.path;\n options.body = options.data && JSON.stringify(options.data,\n /^\\/_design/.test(options.path) && this._replacer\n ) || \"\";\n\n // create promise if no callback given\n var promise, req;\n if (!options.fn && typeof Promise != \"undefined\") {\n promise = new Promise(function (resolve, reject) {\n options.fn = function (err, data, status, headers, res) {\n if (err) {\n err.body = data;\n err.status = status;\n err.headers = headers;\n err.res = res;\n reject(err);\n } else {\n if (Object.defineProperties) {\n Object.defineProperties(data, {\n _status: { value: status },\n _headers: { value: headers },\n _response: { value: res },\n });\n }\n resolve(data);\n };\n };\n });\n req = send();\n promise.request = req;\n promise.abort = function () {\n req.abort();\n options.fn(new Error(\"abort\"));\n return promise;\n };\n return promise;\n }\n\n send();\n\n function send () {\n // apply response transforms\n var g = options._;\n var fn = options.fn;\n if (fn) {\n options.fn = g ? function () {\n fn.apply(self, g.apply(self, arguments) || arguments);\n } : fn;\n }\n return self._do(options);\n }\n};\n\n/**\n * Provider for servicing requests and parsing JSON responses.\n *\n * @param {String} options\n * @param {String} method HTTP method.\n * @param {String} uri HTTP URI.\n * @param {Object} query HTTP query options.\n * @param {Object} body HTTP body.\n * @param {Object} headers HTTP headers.\n * @param {Object} auth HTTP authentication.\n * @param {handler} [callback] Callback function.\n * @private\n */\n\nBase.prototype._do = function (options) {\n var self = this;\n var key, value;\n\n // create request\n var req = request(options.method, options.uri);\n\n // query string\n if (options.query) {\n // ensure query Array values are JSON encoded\n for (key in options.query) {\n if (typeof(value = options.query[key]) === \"object\") {\n options.query[key] = JSON.stringify(value);\n }\n }\n // set query on request\n req.query(options.query);\n }\n\n // set headers\n if (options.headers) {\n req.set(options.headers);\n // if authenticating\n if (req.withCredentials && options.headers[\"Authorization\"] != null) {\n req.withCredentials();\n }\n }\n\n // send body\n if (options.body) req.send(options.body);\n\n // send request\n var fn = options.fn;\n req.end(function (res) {\n var err = res.error;\n var data;\n\n if (!err) {\n if (!(data = res.body)) { data = res.text; }\n else if (data.error) err = self._error(data);\n else data = self._response(data);\n }\n\n res.data = data;\n\n fn && fn(err || null, data, res.status, res.header, res);\n });\n\n return req;\n};\n\n/**\n * Coerce response to normalize access to `_id` and `_rev`.\n *\n * @param {Object} json The response JSON.\n * @return The coerced JSON.\n * @private\n */\n\nBase.prototype._response = function (json) {\n var data = json.rows || json.results || json.uuids || isArray(json) && json;\n var meta = this._meta;\n var i = 0, len, item;\n\n if (data) {\n extend(data, json).json = json;\n for (len = data.length; i < len; i++) {\n item = data[i] = meta(data[i]);\n if (item.doc) item.doc = meta(item.doc);\n }\n } else {\n data = meta(json);\n }\n\n return data;\n};\n\n/**\n * Make an error out of the response.\n *\n * @param {Object} json The response JSON.\n * @return An `Error` object.\n * @private\n */\n\nBase.prototype._error = function (json) {\n var err = new Error(json.reason);\n err.code = json.error;\n return extend(err, json);\n};\n\n/**\n * JSON stringify functions. Used for encoding view documents to JSON.\n *\n * @param {String} key The key to stringify.\n * @param {Object} val The value to stringify.\n * @return {Object} The stringified function value or the value.\n * @private\n */\n\nBase.prototype._replacer = function (key, val) {\n return isFunction (val) ? val.toString() : val;\n};\n\n/**\n * Coerce documents with prototypical `_id` and `_rev`\n * values.\n *\n * @param {Object} doc The document to coerce.\n * @return {Object} The coerced document.\n * @private\n */\n\nBase.prototype._meta = function (doc) {\n var hasId = !doc._id && doc.id;\n var hasRev = !doc._rev && doc.rev;\n var proto;\n\n if (hasId || hasRev) {\n proto = function (){};\n doc = extend(new proto(), doc);\n proto = proto.prototype;\n if (hasId) proto._id = doc.id;\n if (hasRev) proto._rev = doc.rev;\n }\n\n return doc;\n};\n\n/**\n * Parse arguments.\n *\n * @param {Array} args The arguments.\n * @param {Integer} start The index from which to start reading arguments.\n * @param {Boolean} withDoc Set to `true` if the doc source is given as a\n * parameter before HTTP query options.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @private\n */\n\nBase.prototype._ = function (args, start, withDoc) {\n var self = this, doc, id, rev;\n\n function request(method, path, options) {\n if (!options) options = {};\n return self._request({\n method: method,\n path: path || request.p,\n query: options.q || request.q,\n data: options.b || request.b,\n headers: options.h || request.h,\n fn: options.f || request.f,\n _: options._ || request._\n });\n }\n\n // [id], [doc], [query], [header], [callback]\n args = [].slice.call(args, start || 0);\n\n request.f = isFunction(args[args.length - 1]) && args.pop();\n request.p = isString(args[0]) && encodeURI(args.shift());\n request.q = args[withDoc ? 1 : 0] || {};\n request.h = args[withDoc ? 2 : 1] || {};\n\n if (withDoc) {\n if (doc = (request.b = args[0])) {\n if (id = request.p || doc._id || doc.id) request.p = id;\n if (rev = request.q.rev || doc._rev || doc.rev) request.q.rev = rev;\n }\n }\n\n return request;\n};\n\n/**\n * Clerk CouchDB client.\n *\n * @param {String} uri Fully qualified URI.\n * @param {String} [auth] Authentication header value.\n * @constructor\n * @memberof clerk\n * @see {@link http://wiki.apache.org/couchdb/Complete_HTTP_API_Reference|CouchDB Wiki}\n */\n\nfunction Client (uri, auth) {\n this.uri = uri;\n this._db = {};\n this.auth = auth;\n};\n\nClient.prototype = new Base();\n\n/**\n * Select database to manipulate.\n *\n * @param {String} name DB name.\n * @return {DB} DB object.\n */\n\nClient.prototype.db = function (name) {\n var db = this._db;\n return db[name] || (db[name] = new DB(this, name, this.auth));\n};\n\n/**\n * List all databases.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetAllDbs|CouchDB Wiki}\n */\n\nClient.prototype.dbs = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\", \"_all_dbs\");\n};\n\n/**\n * Get UUIDs.\n *\n * @param {Integer} [count=1] Number of UUIDs to get.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetUuids|CouchDB Wiki}\n */\n\nClient.prototype.uuids = function (count /* [query], [headers], [callback] */) {\n var request = this._(arguments, +count == count ? 1 : 0);\n if (count > 1) request.q.count = count;\n return request(\"GET\", \"_uuids\");\n};\n\n/**\n * Get server information.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetRoot|CouchDB Wiki}\n */\n\nClient.prototype.info = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\");\n};\n\n/**\n * Get server stats.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetLog|CouchDB Wiki}\n */\n\nClient.prototype.stats = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\", \"_stats\");\n};\n\n/**\n * Get tail of the server log file.\n *\n * @param {Object} [query] Query parameters.\n * @param {Integer} [query.bytes] Number of bytes to read.\n * @param {Integer} [query.offset] Number of bytes from the end of\n * log file to start reading.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetLog|CouchDB Wiki}\n */\n\nClient.prototype.log = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\", \"_log\");\n};\n\n/**\n * List running tasks.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetActiveTasks|CouchDB Wiki}\n */\n\nClient.prototype.tasks = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\", \"_active_tasks\");\n};\n\n/**\n * Get or set configuration values.\n *\n * @param {String} [key] Configuration section or key.\n * @param {String} [value] Configuration value.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nClient.prototype.config = function (/* [key], [value], [query], [headers], [callback] */) {\n var args = [].slice.call(arguments);\n var key = isString(args[0]) && args.shift() || \"\";\n var value = isString(args[0]) && args.shift();\n var method = isString(value) ? \"PUT\" : \"GET\";\n return this._(args)(method, \"_config/\" + key, { b: value });\n};\n\n/**\n * Replicate databases.\n *\n * @param {Object} options Options.\n * @param {String} options.source Source database URL or local name.\n * @param {String} options.target Target database URL or local name.\n * @param {Boolean} [options.cancel] Set to `true` to cancel replication.\n * @param {Boolean} [options.continuous] Set to `true` for continuous\n * replication.\n * @param {Boolean} [options.create_target] Set to `true` to create the\n * target database.\n * @param {String} [options.filter] Filter name for filtered replication.\n * Example: \"mydesign/myfilter\".\n * @param {Object} [options.query] Query parameters for filter.\n * @param {String[]} [options.doc_ids] Document IDs to replicate.\n * @param {String} [options.proxy] Proxy through which to replicate.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/Replication|CouchDB Wiki}\n */\n\nClient.prototype.replicate = function (options /* [query], [headers], [callback] */) {\n return this._(arguments, 1)(\"POST\", \"_replicate\", { b: options });\n};\n\n/**\n * Methods for CouchDB database.\n *\n * @param {Client} client Clerk client.\n * @param {String} name DB name.\n * @param {String} [auth] Authentication header value.\n * @constructor\n * @memberof clerk\n * @return This object for chaining.\n */\n\nfunction DB (client, name, auth) {\n this.client = client;\n this.name = name;\n this.uri = client.uri + \"/\" + encodeURIComponent(name);\n this.auth = auth;\n};\n\nDB.prototype = new Base();\n\n/**\n * Create database.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.create = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"PUT\");\n};\n\n/**\n * Destroy database.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.destroy = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"DELETE\");\n};\n\n/**\n * Get database info.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.info = function (/* [query], [headers], callback */) {\n return this._(arguments)(\"GET\");\n};\n\n/**\n * Check if database exists.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.exists = function (/* [query], [headers], callback */) {\n var request = this._(arguments);\n request._ = function (err, body, status, headers, req) {\n return [err, status === 200, status, headers, req];\n };\n return request(\"HEAD\");\n};\n\n/**\n * Fetch document.\n *\n * Set `rev` in `query`.\n *\n * @param {String} id Document ID.\n * @param {Object} [query] HTTP query options.\n * @param {Boolean} [query.revs] Fetch list of revisions.\n * @param {Boolean} [query.revs_info] Fetch detailed revision information.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#GET|CouchDB Wiki}\n */\n\nDB.prototype.get = function (/* [id], [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\");\n};\n\n/**\n * Get document metadata.\n *\n * @param {String} id Document ID.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#HEAD|CouchDB Wiki}\n */\n\nDB.prototype.head = function (/* [id], [query], [headers], callback */) {\n var self = this;\n var request = self._(arguments);\n request._ = function (err, body, status, headers, res) {\n return [err, err ? null : {\n _id: request.p,\n _rev: headers.etag && JSON.parse(headers.etag),\n contentType: headers[\"content-type\"],\n contentLength: headers[\"content-length\"]\n }, status, headers, res];\n };\n return request(\"HEAD\");\n};\n\n/**\n * Post document(s) to database.\n *\n * If documents have no ID, a document ID will be automatically generated\n * on the server. Attachments are not currently supported.\n *\n * @param {Object|Object[]} doc Document or array of documents.\n * @param {String} [doc._id] Document ID. If set, uses given document ID.\n * @param {String} [doc._rev] Document revision. If set, allows update to\n * existing document.\n * @param {Object} [doc._attachments] Attachments. If given, must be a\n * map of filenames to attachment properties.\n * @param {String} [doc._attachments[filename]] Attachment filename, as\n * hash key.\n * @param {String} [doc._attachments[filename].contentType] Attachment\n * MIME content type.\n * @param {String|Object} [doc._attachments[filename].data] Attachment\n * data. Will be Base64 encoded.\n * @param {Object} [query] HTTP query options.\n * @param {Boolean} [query.batch] Allow server to write document in\n * batch mode. Documents will not be written to disk immediately,\n * increasing the chances of write failure.\n * @param {Boolean} [query.all_or_nothing] For batch updating of\n * documents, use all-or-nothing semantics.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#POST|CouchDB Wiki}\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API|CouchDB Wiki}\n */\n\nDB.prototype.post = function (docs /* [query], [headers], [callback] */) {\n var request = this._(arguments, 1);\n if (isArray(docs)) {\n request.p = \"_bulk_docs\";\n request.b = extend({ docs: docs }, request.q);\n request.q = null\n } else {\n request.b = docs;\n }\n return request(\"POST\");\n};\n\n/**\n * Put document in database.\n *\n * @param {Object} doc Document data. Requires `_id` and `_rev`.\n * @param {String} [options] Options.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#PUT|CouchDB Wiki}\n */\n\nDB.prototype.put = function (/* [id], [doc], [query], [headers], [callback] */) {\n var request = this._(arguments, 0, 1);\n // prevent acidentally creating database\n if (!request.p) request.p = request.b._id || request.b.id;\n if (!request.p) throw new Error(\"missing id\");\n return request(\"PUT\");\n};\n\n/**\n * Delete document(s).\n *\n * @param {Object|Object[]} docs Document or array of documents.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#DELETE|CouchDB Wiki}\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API|CouchDB Wiki}\n */\n\nDB.prototype.del = function (docs /* [query], [headers], [callback] */) {\n if (isArray(docs)) {\n var i = 0, len = docs.length, doc;\n for (; i < len; i++) {\n doc = docs[i], docs[i] = {\n _id: doc._id || doc.id,\n _rev: doc._rev || doc.rev,\n _deleted: true\n };\n }\n return this.post.apply(this, arguments);\n } else {\n var request = this._(arguments, 0, 1);\n // prevent acidentally deleting database\n if (!request.p) throw new Error(\"missing id\");\n return request(\"DELETE\");\n }\n};\n\n/**\n * Copy document.\n *\n * @param {Object} source Source document.\n * @param {String} source.id Source document ID.\n * @param {String} [source.rev] Source document revision.\n * @param {String} [source._id] Source document ID. Alternate key for\n * `source.id`.\n * @param {String} [source._rev] Source document revision. Alternate key\n * for `source.id`.\n * @param {Object} target Target document.\n * @param {String} target.id Target document ID.\n * @param {String} [target.rev] Target document revision.\n * @param {String} [target._id] Target document ID. Alternate key for\n * `target.id`.\n * @param {String} [target._rev] Target document revision. Alternate key\n * for `target.id`.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#COPY|CouchDB Wiki}\n */\n\nDB.prototype.copy = function (source, target /* [query], [headers], [callback] */) {\n var request = this._(arguments, 2);\n var sourcePath = encodeURIComponent(source.id || source._id || source);\n var targetPath = encodeURIComponent(target.id || target._id || target);\n var sourceRev = source.rev || source._rev;\n var targetRev = target.rev || target._rev;\n\n if (sourceRev) request.q.rev = sourceRev;\n if (targetRev) targetPath += \"?rev=\" + encodeURIComponent(targetRev);\n\n request.h.Destination = targetPath;\n\n return request(\"COPY\", sourcePath);\n};\n\n/**\n * Query all documents by ID.\n *\n * @param {Object} [query] HTTP query options.\n * @param {JSON} [query.startkey] Start returning results from this\n * document ID.\n * @param {JSON} [query.endkey] Stop returning results at this document\n * ID.\n * @param {Integer} [query.limit] Limit number of results returned.\n * @param {Boolean} [query.descending=false] Lookup results in reverse\n * order by key, returning documents in descending order by key.\n * @param {Integer} [query.skip] Skip this many records before\n * returning results.\n * @param {Boolean} [query.include_docs=false] Include document source for\n * each result.\n * @param {Boolean} [query.include_end=true] Include `query.endkey`\n * in results.\n * @param {Boolean} [query.update_seq=false] Include sequence value\n * of the database corresponding to the view.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API|CouchDB Wiki}\n */\n\nDB.prototype.all = function (/* [query], [headers], [callback] */) {\n var request = this._(arguments);\n var body = this._viewOptions(request.q);\n return request(body ? \"POST\" : \"GET\", \"_all_docs\", { b: body });\n};\n\n/**\n * Query a view.\n *\n * @param {String|Object} view View name (e.g. mydesign/myview) or\n * temporary view definition. Using a temporary view is strongly not\n * recommended for production use.\n * @param {Object} [query] HTTP query options.\n * @param {JSON} [query.key] Key to lookup.\n * @param {JSON} [query.startkey] Start returning results from this key.\n * @param {String} [query.startkey_docid] Start returning results\n * from this document ID. Allows pagination with duplicate keys.\n * @param {JSON} [query.endkey] Stop returning results at this key.\n * @param {String} [query.endkey_docid] Stop returning results at\n * this document ID. Allows pagination with duplicate keys.\n * @param {Integer} [query.limit] Limit number of results returned.\n * @param {Boolean|String} [query.stale] Do not refresh view even if\n * stale. For CouchDB versions `1.1.0` and up, set to `update_after` to\n * update view after results are returned.\n * @param {Boolean} [query.descending=false] Lookup results in reverse\n * order by key, returning documents in descending order by key.\n * @param {Integer} [query.skip] Skip this many records before\n * returning results.\n * @param {Boolean|Integer} [query.group=false] Use the reduce function\n * to group results by key. Set to an integer specify `group_level`.\n * @param {Boolean|Integer} [query.reduce=true] Use the reduce function.\n * @param {Boolean} [query.fetch=false] Include document source for\n * each result.\n * @param {Boolean} [query.include_end=true] Include `query.endkey`\n * in results.\n * @param {Boolean} [query.update_seq=false] Include sequence value\n * of the database corresponding to the view.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_view_API|CouchDB Wiki}\n */\n\nDB.prototype.find = function (view /* [query], [headers], [callback] */) {\n var request = this._(arguments, 1), path, body;\n\n if (isString(view)) {\n path = view.split(\"/\", 2);\n path = \"_design/\" + encodeURIComponent(path[0]) +\n \"/_view/\" + encodeURIComponent(path[1]);\n } else {\n path = \"_temp_view\";\n body = view;\n }\n\n body = this._viewOptions(request.q, body);\n return request(body ? \"POST\" : \"GET\", path, { b: body });\n};\n\n/**\n * Get database changes.\n *\n * The `feed` option determines how the callback is called:\n *\n * - `normal` calls the callback once.\n * - `longpoll` waits for a response, then calls the callback once.\n * - `continuous` calls the callback each time an update is received.\n * Implemented as the `database#follow()` method.\n *\n * @param {Object} [query] HTTP query options.\n * @param {String} [query.feed=\"normal\"] Type of feed. See comments\n * above.\n * @param {String} [query.filter] Filter updates using this filter.\n * @param {Integer} [query.limit] Maximum number of rows to return.\n * @param {Integer} [query.since=0] Start results from this sequence\n * number.\n * @param {Boolean} [query.include_docs=false] Include documents with\n * results.\n * @param {Integer} [query.timeout=1000] Maximum period in milliseconds\n * to wait for a change before sending a response, even if there are no\n * results.\n * @param {Integer} [query.heartbeat=1000] Period in milliseconds after\n * which an empty line is sent. Applicable only to feed types\n * `longpoll` and `continuous`. Overrides `query.timeout` to keep the\n * feed alive indefinitely.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_database_API#Changes|CouchDB Wiki}\n */\n\nDB.prototype.changes = function (/* [query], [headers], [callback] */) {\n var request = this._(arguments);\n if (request.q.feed != \"longpoll\") delete request.q.feed;\n return this._changes(request);\n};\n\n/**\n * Follow database changes.\n *\n * @see `#changes()`.\n */\n\nDB.prototype.follow = function (/* [query], [headers], callback */) {\n var self = this;\n var request = this._(arguments);\n var fn = request.f;\n\n if (!fn) return this;\n\n request.q.feed = \"longpoll\";\n request.f = function (err, body) {\n var args = [].slice.call(arguments);\n var done, i;\n for (i = 0; i < body.length; i++) {\n args[1] = body[i];\n if (done = fn.apply(self, args) === false || err) break;\n }\n if (!done) self._changes(request);\n };\n\n return this._changes(request);\n};\n\n/**\n * Service a changes request.\n *\n * @private\n */\n\nDB.prototype._changes = function (request) {\n return request(\"GET\", \"_changes\");\n};\n\n/**\n * Update document using server-side handler.\n *\n * @param {String} handler Update handler. Example: mydesign/myhandler\n * @param {String} [id] Document ID.\n * @param {Object} [query] HTTP query options.\n * @param {Object|String} [data] Data.\n * @param {Object} [headers] Headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/Document_Update_Handlers|CouchDB Wiki}\n */\n\nDB.prototype.update = function (handler /* [id], [data], [query], [headers], [callback] */) {\n var request = this._(arguments, 1, 1);\n var path = handler.split(\"/\", 2);\n\n path = \"_design/\" + encodeURIComponent(path[0]) +\n \"/_update/\" + encodeURIComponent(path[1]);\n\n if (request.p) path += \"/\" + request.p;\n\n return request(\"POST\", path);\n};\n\n/**\n * Download attachment from document.\n *\n * @param {Object|String} docOrId Document or document ID.\n * @param {String} attachmentName Attachment name.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.attachment = function (doc, attachmentName /* [query], [headers], [callback] */) {\n var request = this._(arguments, 2);\n var path = encodeURIComponent(doc._id || doc.id || doc) + \"/\" +\n encodeURIComponent(attachmentName);\n return request(\"GET\", path, options);\n};\n\n/**\n * Upload attachment to document.\n *\n * Set the `Content-Type` header.\n *\n * @param {Object} [doc] Document. Requires `id`. `rev` can be specified\n * here or in `query`.\n * @param {String} attachmentName Attachment name.\n * @param {Object} data Data.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.attach = function (doc, attachmentName, data /* [query], [headers], [callback] */) {\n var request = this._(arguments, 3);\n request.p = encodeURIComponent(doc._id || doc.id) + \"/\" +\n encodeURIComponent(attachmentName);\n if (!request.q.rev) request.q.rev = doc._rev || doc.rev;\n request.q.body = data;\n return request(\"PUT\", path);\n};\n\n/**\n * Replicate database.\n *\n * This convenience function sets `options.source` and `options.target` to\n * the selected database name. Either `options.source` or `options.target`\n * must be overridden for a successful replication request.\n *\n * @param {Options} options Options. Accepts all options from\n * `Client.replicate()`.\n * @param {String} [options.source=this.name] Source database URL or\n * local name. Defaults to the selected database name if not given.\n * @param {String} [options.target=this.name] Target database URL or\n * local name. Defaults to the selected database name if not given.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.replicate = function (options /* [query], [headers], [callback] */) {\n if (!options.source) options.source = this.name;\n if (!options.target) options.target = this.name;\n return this.client.replicate.apply(this.client, arguments);\n};\n\n/**\n * Ensure recent changes are committed to disk.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.commit = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"POST\", \"_ensure_full_commit\");\n};\n\n/**\n * Purge deleted documents from database.\n *\n * @param {Object} revs Map of document IDs to revisions to be purged.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.purge = function (revs /* [query], [headers], [callback] */) {\n return this._(arguments, 1)(\"POST\", \"_purge\", { b: revs });\n};\n\n/**\n * Compact database or design.\n *\n * @param {String} [design] Design name if compacting design indexes.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/Compaction|CouchDB Wiki}\n */\n\nDB.prototype.compact = function (/* [design], [query], [headers], [callback] */) {\n var request = this._(arguments);\n return request(\"POST\", \"_compact/\" + (request.p || \"\"));\n};\n\n/**\n * Remove unused views.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/Compaction|CouchDB Wiki}\n */\n\nDB.prototype.vacuum = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"POST\", \"_view_cleanup\");\n};\n\n/**\n * Parse view options.\n *\n * @param {Object} query The HTTP query options.\n * @param {Object} body The body payload.\n * @param {handler} [callback] Callback function.\n * @return {Object} The body payload.\n * @private\n */\n\nDB.prototype._viewOptions = function (q, body) {\n if (q) {\n if (q.key) q.key = JSON.stringify(q.key);\n if (q.startkey) q.startkey = JSON.stringify(q.startkey);\n if (q.endkey) q.endkey = JSON.stringify(q.endkey);\n if (q.stale && q.stale != \"update_after\") q.stale = \"ok\";\n if (q.keys) {\n if (!body) body = {};\n body.keys = q.keys;\n delete q.keys;\n }\n }\n return body;\n};\n\n/**\n * Handle a clerk response.\n *\n * @callback handler\n * @param {Error|null} error Error or `null` on success.\n * @param {Object} data Response data.\n * @param {Integer} status Response status code.\n * @param {Object} headers Response headers.\n * @param {superagent.Response} res Superagent response object.\n */\n\nclerk.Base = Base;\nclerk.Client = Client;\nclerk.DB = DB;\n\n// Export clerk.\nmodule.exports = clerk;\n\n\n/***/ },\n/* 1 */\n/***/ function(module, exports, __webpack_require__) {\n\n/**\n * Module dependencies.\n */\n\nvar Emitter = __webpack_require__(2);\nvar reduce = __webpack_require__(3);\n\n/**\n * Root reference for iframes.\n */\n\nvar root = 'undefined' == typeof window\n ? this\n : window;\n\n/**\n * Noop.\n */\n\nfunction noop(){};\n\n/**\n * Check if `obj` is a host object,\n * we don't want to serialize these :)\n *\n * TODO: future proof, move to compoent land\n *\n * @param {Object} obj\n * @return {Boolean}\n * @api private\n */\n\nfunction isHost(obj) {\n var str = {}.toString.call(obj);\n\n switch (str) {\n case '[object File]':\n case '[object Blob]':\n case '[object FormData]':\n return true;\n default:\n return false;\n }\n}\n\n/**\n * Determine XHR.\n */\n\nfunction getXHR() {\n if (root.XMLHttpRequest\n && ('file:' != root.location.protocol || !root.ActiveXObject)) {\n return new XMLHttpRequest;\n } else {\n try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) {}\n }\n return false;\n}\n\n/**\n * Removes leading and trailing whitespace, added to support IE.\n *\n * @param {String} s\n * @return {String}\n * @api private\n */\n\nvar trim = ''.trim\n ? function(s) { return s.trim(); }\n : function(s) { return s.replace(/(^\\s*|\\s*$)/g, ''); };\n\n/**\n * Check if `obj` is an object.\n *\n * @param {Object} obj\n * @return {Boolean}\n * @api private\n */\n\nfunction isObject(obj) {\n return obj === Object(obj);\n}\n\n/**\n * Serialize the given `obj`.\n *\n * @param {Object} obj\n * @return {String}\n * @api private\n */\n\nfunction serialize(obj) {\n if (!isObject(obj)) return obj;\n var pairs = [];\n for (var key in obj) {\n if (null != obj[key]) {\n pairs.push(encodeURIComponent(key)\n + '=' + encodeURIComponent(obj[key]));\n }\n }\n return pairs.join('&');\n}\n\n/**\n * Expose serialization method.\n */\n\n request.serializeObject = serialize;\n\n /**\n * Parse the given x-www-form-urlencoded `str`.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\nfunction parseString(str) {\n var obj = {};\n var pairs = str.split('&');\n var parts;\n var pair;\n\n for (var i = 0, len = pairs.length; i < len; ++i) {\n pair = pairs[i];\n parts = pair.split('=');\n obj[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]);\n }\n\n return obj;\n}\n\n/**\n * Expose parser.\n */\n\nrequest.parseString = parseString;\n\n/**\n * Default MIME type map.\n *\n * superagent.types.xml = 'application/xml';\n *\n */\n\nrequest.types = {\n html: 'text/html',\n json: 'application/json',\n xml: 'application/xml',\n urlencoded: 'application/x-www-form-urlencoded',\n 'form': 'application/x-www-form-urlencoded',\n 'form-data': 'application/x-www-form-urlencoded'\n};\n\n/**\n * Default serialization map.\n *\n * superagent.serialize['application/xml'] = function(obj){\n * return 'generated xml here';\n * };\n *\n */\n\n request.serialize = {\n 'application/x-www-form-urlencoded': serialize,\n 'application/json': JSON.stringify\n };\n\n /**\n * Default parsers.\n *\n * superagent.parse['application/xml'] = function(str){\n * return { object parsed from str };\n * };\n *\n */\n\nrequest.parse = {\n 'application/x-www-form-urlencoded': parseString,\n 'application/json': JSON.parse\n};\n\n/**\n * Parse the given header `str` into\n * an object containing the mapped fields.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\nfunction parseHeader(str) {\n var lines = str.split(/\\r?\\n/);\n var fields = {};\n var index;\n var line;\n var field;\n var val;\n\n lines.pop(); // trailing CRLF\n\n for (var i = 0, len = lines.length; i < len; ++i) {\n line = lines[i];\n index = line.indexOf(':');\n field = line.slice(0, index).toLowerCase();\n val = trim(line.slice(index + 1));\n fields[field] = val;\n }\n\n return fields;\n}\n\n/**\n * Return the mime type for the given `str`.\n *\n * @param {String} str\n * @return {String}\n * @api private\n */\n\nfunction type(str){\n return str.split(/ *; */).shift();\n};\n\n/**\n * Return header field parameters.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\nfunction params(str){\n return reduce(str.split(/ *; */), function(obj, str){\n var parts = str.split(/ *= */)\n , key = parts.shift()\n , val = parts.shift();\n\n if (key && val) obj[key] = val;\n return obj;\n }, {});\n};\n\n/**\n * Initialize a new `Response` with the given `xhr`.\n *\n * - set flags (.ok, .error, etc)\n * - parse header\n *\n * Examples:\n *\n * Aliasing `superagent` as `request` is nice:\n *\n * request = superagent;\n *\n * We can use the promise-like API, or pass callbacks:\n *\n * request.get('/').end(function(res){});\n * request.get('/', function(res){});\n *\n * Sending data can be chained:\n *\n * request\n * .post('/user')\n * .send({ name: 'tj' })\n * .end(function(res){});\n *\n * Or passed to `.send()`:\n *\n * request\n * .post('/user')\n * .send({ name: 'tj' }, function(res){});\n *\n * Or passed to `.post()`:\n *\n * request\n * .post('/user', { name: 'tj' })\n * .end(function(res){});\n *\n * Or further reduced to a single call for simple cases:\n *\n * request\n * .post('/user', { name: 'tj' }, function(res){});\n *\n * @param {XMLHTTPRequest} xhr\n * @param {Object} options\n * @api private\n */\n\nfunction Response(req, options) {\n options = options || {};\n this.req = req;\n this.xhr = this.req.xhr;\n this.text = this.req.method !='HEAD' \n ? this.xhr.responseText \n : null;\n this.setStatusProperties(this.xhr.status);\n this.header = this.headers = parseHeader(this.xhr.getAllResponseHeaders());\n // getAllResponseHeaders sometimes falsely returns \"\" for CORS requests, but\n // getResponseHeader still works. so we get content-type even if getting\n // other headers fails.\n this.header['content-type'] = this.xhr.getResponseHeader('content-type');\n this.setHeaderProperties(this.header);\n this.body = this.req.method != 'HEAD'\n ? this.parseBody(this.text)\n : null;\n}\n\n/**\n * Get case-insensitive `field` value.\n *\n * @param {String} field\n * @return {String}\n * @api public\n */\n\nResponse.prototype.get = function(field){\n return this.header[field.toLowerCase()];\n};\n\n/**\n * Set header related properties:\n *\n * - `.type` the content type without params\n *\n * A response of \"Content-Type: text/plain; charset=utf-8\"\n * will provide you with a `.type` of \"text/plain\".\n *\n * @param {Object} header\n * @api private\n */\n\nResponse.prototype.setHeaderProperties = function(header){\n // content-type\n var ct = this.header['content-type'] || '';\n this.type = type(ct);\n\n // params\n var obj = params(ct);\n for (var key in obj) this[key] = obj[key];\n};\n\n/**\n * Parse the given body `str`.\n *\n * Used for auto-parsing of bodies. Parsers\n * are defined on the `superagent.parse` object.\n *\n * @param {String} str\n * @return {Mixed}\n * @api private\n */\n\nResponse.prototype.parseBody = function(str){\n var parse = request.parse[this.type];\n return parse && str && str.length\n ? parse(str)\n : null;\n};\n\n/**\n * Set flags such as `.ok` based on `status`.\n *\n * For example a 2xx response will give you a `.ok` of __true__\n * whereas 5xx will be __false__ and `.error` will be __true__. The\n * `.clientError` and `.serverError` are also available to be more\n * specific, and `.statusType` is the class of error ranging from 1..5\n * sometimes useful for mapping respond colors etc.\n *\n * \"sugar\" properties are also defined for common cases. Currently providing:\n *\n * - .noContent\n * - .badRequest\n * - .unauthorized\n * - .notAcceptable\n * - .notFound\n *\n * @param {Number} status\n * @api private\n */\n\nResponse.prototype.setStatusProperties = function(status){\n var type = status / 100 | 0;\n\n // status / class\n this.status = status;\n this.statusType = type;\n\n // basics\n this.info = 1 == type;\n this.ok = 2 == type;\n this.clientError = 4 == type;\n this.serverError = 5 == type;\n this.error = (4 == type || 5 == type)\n ? this.toError()\n : false;\n\n // sugar\n this.accepted = 202 == status;\n this.noContent = 204 == status || 1223 == status;\n this.badRequest = 400 == status;\n this.unauthorized = 401 == status;\n this.notAcceptable = 406 == status;\n this.notFound = 404 == status;\n this.forbidden = 403 == status;\n};\n\n/**\n * Return an `Error` representative of this response.\n *\n * @return {Error}\n * @api public\n */\n\nResponse.prototype.toError = function(){\n var req = this.req;\n var method = req.method;\n var url = req.url;\n\n var msg = 'cannot ' + method + ' ' + url + ' (' + this.status + ')';\n var err = new Error(msg);\n err.status = this.status;\n err.method = method;\n err.url = url;\n\n return err;\n};\n\n/**\n * Expose `Response`.\n */\n\nrequest.Response = Response;\n\n/**\n * Initialize a new `Request` with the given `method` and `url`.\n *\n * @param {String} method\n * @param {String} url\n * @api public\n */\n\nfunction Request(method, url) {\n var self = this;\n Emitter.call(this);\n this._query = this._query || [];\n this.method = method;\n this.url = url;\n this.header = {};\n this._header = {};\n this.on('end', function(){\n var err = null;\n var res = null;\n\n try {\n res = new Response(self); \n } catch(e) {\n err = new Error('Parser is unable to parse the response');\n err.parse = true;\n err.original = e;\n }\n\n self.callback(err, res);\n });\n}\n\n/**\n * Mixin `Emitter`.\n */\n\nEmitter(Request.prototype);\n\n/**\n * Allow for extension\n */\n\nRequest.prototype.use = function(fn) {\n fn(this);\n return this;\n}\n\n/**\n * Set timeout to `ms`.\n *\n * @param {Number} ms\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.timeout = function(ms){\n this._timeout = ms;\n return this;\n};\n\n/**\n * Clear previous timeout.\n *\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.clearTimeout = function(){\n this._timeout = 0;\n clearTimeout(this._timer);\n return this;\n};\n\n/**\n * Abort the request, and clear potential timeout.\n *\n * @return {Request}\n * @api public\n */\n\nRequest.prototype.abort = function(){\n if (this.aborted) return;\n this.aborted = true;\n this.xhr.abort();\n this.clearTimeout();\n this.emit('abort');\n return this;\n};\n\n/**\n * Set header `field` to `val`, or multiple fields with one object.\n *\n * Examples:\n *\n * req.get('/')\n * .set('Accept', 'application/json')\n * .set('X-API-Key', 'foobar')\n * .end(callback);\n *\n * req.get('/')\n * .set({ Accept: 'application/json', 'X-API-Key': 'foobar' })\n * .end(callback);\n *\n * @param {String|Object} field\n * @param {String} val\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.set = function(field, val){\n if (isObject(field)) {\n for (var key in field) {\n this.set(key, field[key]);\n }\n return this;\n }\n this._header[field.toLowerCase()] = val;\n this.header[field] = val;\n return this;\n};\n\n/**\n * Remove header `field`.\n *\n * Example:\n *\n * req.get('/')\n * .unset('User-Agent')\n * .end(callback);\n *\n * @param {String} field\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.unset = function(field){\n delete this._header[field.toLowerCase()];\n delete this.header[field];\n return this;\n};\n\n/**\n * Get case-insensitive header `field` value.\n *\n * @param {String} field\n * @return {String}\n * @api private\n */\n\nRequest.prototype.getHeader = function(field){\n return this._header[field.toLowerCase()];\n};\n\n/**\n * Set Content-Type to `type`, mapping values from `request.types`.\n *\n * Examples:\n *\n * superagent.types.xml = 'application/xml';\n *\n * request.post('/')\n * .type('xml')\n * .send(xmlstring)\n * .end(callback);\n *\n * request.post('/')\n * .type('application/xml')\n * .send(xmlstring)\n * .end(callback);\n *\n * @param {String} type\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.type = function(type){\n this.set('Content-Type', request.types[type] || type);\n return this;\n};\n\n/**\n * Set Accept to `type`, mapping values from `request.types`.\n *\n * Examples:\n *\n * superagent.types.json = 'application/json';\n *\n * request.get('/agent')\n * .accept('json')\n * .end(callback);\n *\n * request.get('/agent')\n * .accept('application/json')\n * .end(callback);\n *\n * @param {String} accept\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.accept = function(type){\n this.set('Accept', request.types[type] || type);\n return this;\n};\n\n/**\n * Set Authorization field value with `user` and `pass`.\n *\n * @param {String} user\n * @param {String} pass\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.auth = function(user, pass){\n var str = btoa(user + ':' + pass);\n this.set('Authorization', 'Basic ' + str);\n return this;\n};\n\n/**\n* Add query-string `val`.\n*\n* Examples:\n*\n* request.get('/shoes')\n* .query('size=10')\n* .query({ color: 'blue' })\n*\n* @param {Object|String} val\n* @return {Request} for chaining\n* @api public\n*/\n\nRequest.prototype.query = function(val){\n if ('string' != typeof val) val = serialize(val);\n if (val) this._query.push(val);\n return this;\n};\n\n/**\n * Write the field `name` and `val` for \"multipart/form-data\"\n * request bodies.\n *\n * ``` js\n * request.post('/upload')\n * .field('foo', 'bar')\n * .end(callback);\n * ```\n *\n * @param {String} name\n * @param {String|Blob|File} val\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.field = function(name, val){\n if (!this._formData) this._formData = new FormData();\n this._formData.append(name, val);\n return this;\n};\n\n/**\n * Queue the given `file` as an attachment to the specified `field`,\n * with optional `filename`.\n *\n * ``` js\n * request.post('/upload')\n * .attach(new Blob(['hey!'], { type: \"text/html\"}))\n * .end(callback);\n * ```\n *\n * @param {String} field\n * @param {Blob|File} file\n * @param {String} filename\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.attach = function(field, file, filename){\n if (!this._formData) this._formData = new FormData();\n this._formData.append(field, file, filename);\n return this;\n};\n\n/**\n * Send `data`, defaulting the `.type()` to \"json\" when\n * an object is given.\n *\n * Examples:\n *\n * // querystring\n * request.get('/search')\n * .end(callback)\n *\n * // multiple data \"writes\"\n * request.get('/search')\n * .send({ search: 'query' })\n * .send({ range: '1..5' })\n * .send({ order: 'desc' })\n * .end(callback)\n *\n * // manual json\n * request.post('/user')\n * .type('json')\n * .send('{\"name\":\"tj\"})\n * .end(callback)\n *\n * // auto json\n * request.post('/user')\n * .send({ name: 'tj' })\n * .end(callback)\n *\n * // manual x-www-form-urlencoded\n * request.post('/user')\n * .type('form')\n * .send('name=tj')\n * .end(callback)\n *\n * // auto x-www-form-urlencoded\n * request.post('/user')\n * .type('form')\n * .send({ name: 'tj' })\n * .end(callback)\n *\n * // defaults to x-www-form-urlencoded\n * request.post('/user')\n * .send('name=tobi')\n * .send('species=ferret')\n * .end(callback)\n *\n * @param {String|Object} data\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.send = function(data){\n var obj = isObject(data);\n var type = this.getHeader('Content-Type');\n\n // merge\n if (obj && isObject(this._data)) {\n for (var key in data) {\n this._data[key] = data[key];\n }\n } else if ('string' == typeof data) {\n if (!type) this.type('form');\n type = this.getHeader('Content-Type');\n if ('application/x-www-form-urlencoded' == type) {\n this._data = this._data\n ? this._data + '&' + data\n : data;\n } else {\n this._data = (this._data || '') + data;\n }\n } else {\n this._data = data;\n }\n\n if (!obj) return this;\n if (!type) this.type('json');\n return this;\n};\n\n/**\n * Invoke the callback with `err` and `res`\n * and handle arity check.\n *\n * @param {Error} err\n * @param {Response} res\n * @api private\n */\n\nRequest.prototype.callback = function(err, res){\n var fn = this._callback;\n this.clearTimeout();\n if (2 == fn.length) return fn(err, res);\n if (err) return this.emit('error', err);\n fn(res);\n};\n\n/**\n * Invoke callback with x-domain error.\n *\n * @api private\n */\n\nRequest.prototype.crossDomainError = function(){\n var err = new Error('Origin is not allowed by Access-Control-Allow-Origin');\n err.crossDomain = true;\n this.callback(err);\n};\n\n/**\n * Invoke callback with timeout error.\n *\n * @api private\n */\n\nRequest.prototype.timeoutError = function(){\n var timeout = this._timeout;\n var err = new Error('timeout of ' + timeout + 'ms exceeded');\n err.timeout = timeout;\n this.callback(err);\n};\n\n/**\n * Enable transmission of cookies with x-domain requests.\n *\n * Note that for this to work the origin must not be\n * using \"Access-Control-Allow-Origin\" with a wildcard,\n * and also must set \"Access-Control-Allow-Credentials\"\n * to \"true\".\n *\n * @api public\n */\n\nRequest.prototype.withCredentials = function(){\n this._withCredentials = true;\n return this;\n};\n\n/**\n * Initiate request, invoking callback `fn(res)`\n * with an instanceof `Response`.\n *\n * @param {Function} fn\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.end = function(fn){\n var self = this;\n var xhr = this.xhr = getXHR();\n var query = this._query.join('&');\n var timeout = this._timeout;\n var data = this._formData || this._data;\n\n // store callback\n this._callback = fn || noop;\n\n // state change\n xhr.onreadystatechange = function(){\n if (4 != xhr.readyState) return;\n if (0 == xhr.status) {\n if (self.aborted) return self.timeoutError();\n return self.crossDomainError();\n }\n self.emit('end');\n };\n\n // progress\n if (xhr.upload) {\n xhr.upload.onprogress = function(e){\n e.percent = e.loaded / e.total * 100;\n self.emit('progress', e);\n };\n }\n\n // timeout\n if (timeout && !this._timer) {\n this._timer = setTimeout(function(){\n self.abort();\n }, timeout);\n }\n\n // querystring\n if (query) {\n query = request.serializeObject(query);\n this.url += ~this.url.indexOf('?')\n ? '&' + query\n : '?' + query;\n }\n\n // initiate request\n xhr.open(this.method, this.url, true);\n\n // CORS\n if (this._withCredentials) xhr.withCredentials = true;\n\n // body\n if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !isHost(data)) {\n // serialize stuff\n var serialize = request.serialize[this.getHeader('Content-Type')];\n if (serialize) data = serialize(data);\n }\n\n // set header fields\n for (var field in this.header) {\n if (null == this.header[field]) continue;\n xhr.setRequestHeader(field, this.header[field]);\n }\n\n // send stuff\n this.emit('request', this);\n xhr.send(data);\n return this;\n};\n\n/**\n * Expose `Request`.\n */\n\nrequest.Request = Request;\n\n/**\n * Issue a request:\n *\n * Examples:\n *\n * request('GET', '/users').end(callback)\n * request('/users').end(callback)\n * request('/users', callback)\n *\n * @param {String} method\n * @param {String|Function} url or callback\n * @return {Request}\n * @api public\n */\n\nfunction request(method, url) {\n // callback\n if ('function' == typeof url) {\n return new Request('GET', method).end(url);\n }\n\n // url first\n if (1 == arguments.length) {\n return new Request('GET', method);\n }\n\n return new Request(method, url);\n}\n\n/**\n * GET `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} data or fn\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.get = function(url, data, fn){\n var req = request('GET', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.query(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * HEAD `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} data or fn\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.head = function(url, data, fn){\n var req = request('HEAD', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * DELETE `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.del = function(url, fn){\n var req = request('DELETE', url);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * PATCH `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed} data\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.patch = function(url, data, fn){\n var req = request('PATCH', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * POST `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed} data\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.post = function(url, data, fn){\n var req = request('POST', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * PUT `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} data or fn\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.put = function(url, data, fn){\n var req = request('PUT', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * Expose `request`.\n */\n\nmodule.exports = request;\n\n\n/***/ },\n/* 2 */\n/***/ function(module, exports, __webpack_require__) {\n\n\n/**\n * Expose `Emitter`.\n */\n\nmodule.exports = Emitter;\n\n/**\n * Initialize a new `Emitter`.\n *\n * @api public\n */\n\nfunction Emitter(obj) {\n if (obj) return mixin(obj);\n};\n\n/**\n * Mixin the emitter properties.\n *\n * @param {Object} obj\n * @return {Object}\n * @api private\n */\n\nfunction mixin(obj) {\n for (var key in Emitter.prototype) {\n obj[key] = Emitter.prototype[key];\n }\n return obj;\n}\n\n/**\n * Listen on the given `event` with `fn`.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.on =\nEmitter.prototype.addEventListener = function(event, fn){\n this._callbacks = this._callbacks || {};\n (this._callbacks[event] = this._callbacks[event] || [])\n .push(fn);\n return this;\n};\n\n/**\n * Adds an `event` listener that will be invoked a single\n * time then automatically removed.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.once = function(event, fn){\n var self = this;\n this._callbacks = this._callbacks || {};\n\n function on() {\n self.off(event, on);\n fn.apply(this, arguments);\n }\n\n on.fn = fn;\n this.on(event, on);\n return this;\n};\n\n/**\n * Remove the given callback for `event` or all\n * registered callbacks.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.off =\nEmitter.prototype.removeListener =\nEmitter.prototype.removeAllListeners =\nEmitter.prototype.removeEventListener = function(event, fn){\n this._callbacks = this._callbacks || {};\n\n // all\n if (0 == arguments.length) {\n this._callbacks = {};\n return this;\n }\n\n // specific event\n var callbacks = this._callbacks[event];\n if (!callbacks) return this;\n\n // remove all handlers\n if (1 == arguments.length) {\n delete this._callbacks[event];\n return this;\n }\n\n // remove specific handler\n var cb;\n for (var i = 0; i < callbacks.length; i++) {\n cb = callbacks[i];\n if (cb === fn || cb.fn === fn) {\n callbacks.splice(i, 1);\n break;\n }\n }\n return this;\n};\n\n/**\n * Emit `event` with the given args.\n *\n * @param {String} event\n * @param {Mixed} ...\n * @return {Emitter}\n */\n\nEmitter.prototype.emit = function(event){\n this._callbacks = this._callbacks || {};\n var args = [].slice.call(arguments, 1)\n , callbacks = this._callbacks[event];\n\n if (callbacks) {\n callbacks = callbacks.slice(0);\n for (var i = 0, len = callbacks.length; i < len; ++i) {\n callbacks[i].apply(this, args);\n }\n }\n\n return this;\n};\n\n/**\n * Return array of callbacks for `event`.\n *\n * @param {String} event\n * @return {Array}\n * @api public\n */\n\nEmitter.prototype.listeners = function(event){\n this._callbacks = this._callbacks || {};\n return this._callbacks[event] || [];\n};\n\n/**\n * Check if this emitter has `event` handlers.\n *\n * @param {String} event\n * @return {Boolean}\n * @api public\n */\n\nEmitter.prototype.hasListeners = function(event){\n return !! this.listeners(event).length;\n};\n\n\n/***/ },\n/* 3 */\n/***/ function(module, exports, __webpack_require__) {\n\n\n/**\n * Reduce `arr` with `fn`.\n *\n * @param {Array} arr\n * @param {Function} fn\n * @param {Mixed} initial\n *\n * TODO: combatible error handling?\n */\n\nmodule.exports = function(arr, fn, initial){ \n var idx = 0;\n var len = arr.length;\n var curr = arguments.length == 3\n ? initial\n : arr[idx++];\n\n while (idx < len) {\n curr = fn.call(null, curr, arr[idx], ++idx, arr);\n }\n \n return curr;\n};\n\n/***/ }\n/******/ ])\n\n\n/** WEBPACK FOOTER **\n ** clerk.min.js\n **/"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 4944304139d62c483cfe\n **/","\"use strict\";\n\n/*!\n\nclerk - CouchDB client for node and the browser.\nCopyright 2012-2015 Michael Phan-Ba\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n*/\n\n// Module dependencies.\nvar request = require(\"superagent\");\n\n/**\n * Copy properties from sources to target.\n *\n * @param {Object} target The target object.\n * @param {...Object} sources The source object.\n * @return {Object} The target object.\n * @private\n */\n\nvar extend = function (target /* ...sources */) {\n var source, key, i = 1;\n while (source = arguments[i++]) {\n for (key in source) target[key] = source[key];\n }\n return target;\n};\n\n/**\n * Stringify value.\n *\n * @param {Object} that That value to stringify.\n * @return {String} The stringifyed value.\n * @private\n */\n\nvar asString = function (that) {\n return Object.prototype.toString.call(that);\n};\n\n/**\n * Check if value is a string.\n *\n * @param {Object} that That value to check.\n * @return {Boolean} `true` if string, `false` otherwise.\n * @private\n */\n\nvar isString = function (that) {\n return asString(that) == \"[object String]\";\n};\n\n/**\n * Check if value is an object.\n *\n * @param {Object} that That value to check.\n * @return {Boolean} `true` if object, `false` otherwise.\n * @private\n */\n\nvar isObject = function (that) {\n return asString(that) == \"[object Object]\";\n};\n\n/**\n * Check if value is an array.\n *\n * @param {Object} that That value to check.\n * @return {Boolean} `true` if array, `false` otherwise.\n * @private\n */\n\nvar isArray = function (that) {\n return asString(that) == \"[object Array]\";\n};\n\n/**\n * Check if value is a function.\n *\n * @param {Object} that That value to check.\n * @return {Boolean} `true` if function, `false` otherwise.\n * @private\n */\n\nvar isFunction = function (that) {\n return asString(that) == \"[object Function]\";\n};\n\n/**\n * Clerk library entry point.\n *\n * @param {String} uri CouchDB server URI.\n * @return {Client|DB} If a URI path is given, returns a `DB`, otherwise\n * returns a `Client`.\n * @see {@link http://docs.couchdb.org|CouchDB Documentation}\n * @see {@link http://guide.couchdb.org/|CouchDB Guide}\n * @see {@link http://wiki.apache.org/couchdb/|CouchDB Wiki}\n */\n\nfunction clerk (uri) {\n return clerk.make(uri);\n};\n\n/**\n * Library version.\n * @type {String}\n */\n\nclerk.version = \"0.8.0\";\n\n/**\n * Default host.\n * @type {String}\n */\n\nclerk.defaultHost = \"http://127.0.0.1:5984\";\n\n/**\n * Create single CouchDB client.\n *\n * @param {String} uri Fully qualified URI.\n * @return {Client|DB} If `uri` has a path, the last segment of the\n * path is used as the database name and a `DB` instance is\n * returned. Otherwise, a `Client` instance is returned.\n */\n\nclerk.make = function (uri) {\n if (!uri) return new Client(this.defaultHost);\n\n uri = clerk._parseURI(uri);\n\n var db = /\\/*([^\\/]+)\\/*$/.exec(uri.path);\n if (db) {\n uri.path = uri.path.substr(0, db.index);\n db = db[1] && decodeURIComponent(db[1]);\n }\n\n // weird way of doing it, but it's more efficient...\n if (uri.auth) uri.auth = 'Basic ' + clerk.btoa(uri.auth);\n\n var client = new clerk.Client(uri.base + uri.path, uri.auth);\n return db ? client.db(db) : client;\n};\n\n/**\n * Base64-encode a string.\n *\n * @param {String} str\n * @return {String}\n */\n\nclerk.btoa = typeof Buffer != \"undefined\" ? function (str) {\n return new Buffer(str).toString(\"base64\");\n} : function (str) {\n return btoa(str);\n};\n\n/**\n * Parse URI.\n *\n * The URI is normalized by removing extra `//` in the path.\n *\n * @param {String} uri Fully qualified URI.\n * @return {String} The normalized URI.\n * @private\n */\n\nclerk._parseURI = function (uri) {\n var match;\n\n if (uri) {\n if (match = /^(https?:\\/\\/)(?:([^\\/@]+)@)?([^\\/]+)(.*)\\/*$/.exec(uri)) {\n return {\n base: match[1] + match[3].replace(/\\/+/g, \"\\/\"),\n path: match[4],\n auth: match[2] && decodeURIComponent(match[2])\n };\n }\n }\n\n return { base: uri || \"\", path: \"\" };\n};\n\n/**\n * Base prototype for `Client` and `DB`.\n * Encapsulates HTTP methods, JSON handling, and response coersion.\n *\n * @constructor\n * @memberof clerk\n */\n\nfunction Base () {};\n\n/**\n * Service request and parse JSON response.\n *\n * @param {String} [method=GET] HTTP method.\n * @param {String} [path=this.uri] HTTP URI.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [body] HTTP body.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nBase.prototype.request = function (/* [method], [path], [query], [body], [headers], [callback] */) {\n var args = [].slice.call(arguments);\n var callback = isFunction (args[args.length - 1]) && args.pop();\n\n return this._request({\n method: args[0],\n path: args[1],\n query: args[2],\n data: args[3],\n headers: args[4],\n fn: callback\n });\n};\n\n/**\n * Internal service request and parse JSON response handler.\n *\n * @param {String} options\n * @param {String} method HTTP method.\n * @param {String} path HTTP URI.\n * @param {Object} query HTTP query options.\n * @param {Object} data HTTP body data.\n * @param {Object} headers HTTP headers.\n * @param {handler} [callback] Callback function.\n * @private\n */\n\nBase.prototype._request = function (options) {\n var self = this;\n\n if (options.method == null) options.method = \"GET\";\n if (options.headers == null) options.headers = {};\n if (options.auth == null) options.auth = this.auth;\n\n options.path = options.path ? \"/\" + options.path : \"\";\n\n // set default headers\n if (options.headers[\"Content-Type\"] == null) {\n options.headers[\"Content-Type\"] = \"application/json\";\n }\n if (options.headers[\"Accept\"] == null) {\n options.headers[\"Accept\"] = \"application/json\";\n }\n if (this.auth && options.headers[\"Authorization\"] == null) {\n options.headers[\"Authorization\"] = this.auth;\n }\n\n options.uri = this.uri + options.path;\n options.body = options.data && JSON.stringify(options.data,\n /^\\/_design/.test(options.path) && this._replacer\n ) || \"\";\n\n // create promise if no callback given\n var promise, req;\n if (!options.fn && typeof Promise != \"undefined\") {\n promise = new Promise(function (resolve, reject) {\n options.fn = function (err, data, status, headers, res) {\n if (err) {\n err.body = data;\n err.status = status;\n err.headers = headers;\n err.res = res;\n reject(err);\n } else {\n if (Object.defineProperties) {\n Object.defineProperties(data, {\n _status: { value: status },\n _headers: { value: headers },\n _response: { value: res },\n });\n }\n resolve(data);\n };\n };\n });\n req = send();\n promise.request = req;\n promise.abort = function () {\n req.abort();\n options.fn(new Error(\"abort\"));\n return promise;\n };\n return promise;\n }\n\n send();\n\n function send () {\n // apply response transforms\n var g = options._;\n var fn = options.fn;\n if (fn) {\n options.fn = g ? function () {\n fn.apply(self, g.apply(self, arguments) || arguments);\n } : fn;\n }\n return self._do(options);\n }\n};\n\n/**\n * Provider for servicing requests and parsing JSON responses.\n *\n * @param {String} options\n * @param {String} method HTTP method.\n * @param {String} uri HTTP URI.\n * @param {Object} query HTTP query options.\n * @param {Object} body HTTP body.\n * @param {Object} headers HTTP headers.\n * @param {Object} auth HTTP authentication.\n * @param {handler} [callback] Callback function.\n * @private\n */\n\nBase.prototype._do = function (options) {\n var self = this;\n var key, value;\n\n // create request\n var req = request(options.method, options.uri);\n\n // query string\n if (options.query) {\n // ensure query Array values are JSON encoded\n for (key in options.query) {\n if (typeof(value = options.query[key]) === \"object\") {\n options.query[key] = JSON.stringify(value);\n }\n }\n // set query on request\n req.query(options.query);\n }\n\n // set headers\n if (options.headers) {\n req.set(options.headers);\n // if authenticating\n if (req.withCredentials && options.headers[\"Authorization\"] != null) {\n req.withCredentials();\n }\n }\n\n // send body\n if (options.body) req.send(options.body);\n\n // send request\n var fn = options.fn;\n req.end(function (res) {\n var err = res.error;\n var data;\n\n if (!err) {\n if (!(data = res.body)) { data = res.text; }\n else if (data.error) err = self._error(data);\n else data = self._response(data);\n }\n\n res.data = data;\n\n fn && fn(err || null, data, res.status, res.header, res);\n });\n\n return req;\n};\n\n/**\n * Coerce response to normalize access to `_id` and `_rev`.\n *\n * @param {Object} json The response JSON.\n * @return The coerced JSON.\n * @private\n */\n\nBase.prototype._response = function (json) {\n var data = json.rows || json.results || json.uuids || isArray(json) && json;\n var meta = this._meta;\n var i = 0, len, item;\n\n if (data) {\n extend(data, json).json = json;\n for (len = data.length; i < len; i++) {\n item = data[i] = meta(data[i]);\n if (item.doc) item.doc = meta(item.doc);\n }\n } else {\n data = meta(json);\n }\n\n return data;\n};\n\n/**\n * Make an error out of the response.\n *\n * @param {Object} json The response JSON.\n * @return An `Error` object.\n * @private\n */\n\nBase.prototype._error = function (json) {\n var err = new Error(json.reason);\n err.code = json.error;\n return extend(err, json);\n};\n\n/**\n * JSON stringify functions. Used for encoding view documents to JSON.\n *\n * @param {String} key The key to stringify.\n * @param {Object} val The value to stringify.\n * @return {Object} The stringified function value or the value.\n * @private\n */\n\nBase.prototype._replacer = function (key, val) {\n return isFunction (val) ? val.toString() : val;\n};\n\n/**\n * Coerce documents with prototypical `_id` and `_rev`\n * values.\n *\n * @param {Object} doc The document to coerce.\n * @return {Object} The coerced document.\n * @private\n */\n\nBase.prototype._meta = function (doc) {\n var hasId = !doc._id && doc.id;\n var hasRev = !doc._rev && doc.rev;\n var proto;\n\n if (hasId || hasRev) {\n proto = function (){};\n doc = extend(new proto(), doc);\n proto = proto.prototype;\n if (hasId) proto._id = doc.id;\n if (hasRev) proto._rev = doc.rev;\n }\n\n return doc;\n};\n\n/**\n * Parse arguments.\n *\n * @param {Array} args The arguments.\n * @param {Integer} start The index from which to start reading arguments.\n * @param {Boolean} withDoc Set to `true` if the doc source is given as a\n * parameter before HTTP query options.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @private\n */\n\nBase.prototype._ = function (args, start, withDoc) {\n var self = this, doc, id, rev;\n\n function request(method, path, options) {\n if (!options) options = {};\n return self._request({\n method: method,\n path: path || request.p,\n query: options.q || request.q,\n data: options.b || request.b,\n headers: options.h || request.h,\n fn: options.f || request.f,\n _: options._ || request._\n });\n }\n\n // [id], [doc], [query], [header], [callback]\n args = [].slice.call(args, start || 0);\n\n request.f = isFunction(args[args.length - 1]) && args.pop();\n request.p = isString(args[0]) && encodeURI(args.shift());\n request.q = args[withDoc ? 1 : 0] || {};\n request.h = args[withDoc ? 2 : 1] || {};\n\n if (withDoc) {\n if (doc = (request.b = args[0])) {\n if (id = request.p || doc._id || doc.id) request.p = id;\n if (rev = request.q.rev || doc._rev || doc.rev) request.q.rev = rev;\n }\n }\n\n return request;\n};\n\n/**\n * Clerk CouchDB client.\n *\n * @param {String} uri Fully qualified URI.\n * @param {String} [auth] Authentication header value.\n * @constructor\n * @memberof clerk\n * @see {@link http://wiki.apache.org/couchdb/Complete_HTTP_API_Reference|CouchDB Wiki}\n */\n\nfunction Client (uri, auth) {\n this.uri = uri;\n this._db = {};\n this.auth = auth;\n};\n\nClient.prototype = new Base();\n\n/**\n * Select database to manipulate.\n *\n * @param {String} name DB name.\n * @return {DB} DB object.\n */\n\nClient.prototype.db = function (name) {\n var db = this._db;\n return db[name] || (db[name] = new DB(this, name, this.auth));\n};\n\n/**\n * List all databases.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetAllDbs|CouchDB Wiki}\n */\n\nClient.prototype.dbs = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\", \"_all_dbs\");\n};\n\n/**\n * Get UUIDs.\n *\n * @param {Integer} [count=1] Number of UUIDs to get.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetUuids|CouchDB Wiki}\n */\n\nClient.prototype.uuids = function (count /* [query], [headers], [callback] */) {\n var request = this._(arguments, +count == count ? 1 : 0);\n if (count > 1) request.q.count = count;\n return request(\"GET\", \"_uuids\");\n};\n\n/**\n * Get server information.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetRoot|CouchDB Wiki}\n */\n\nClient.prototype.info = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\");\n};\n\n/**\n * Get server stats.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetLog|CouchDB Wiki}\n */\n\nClient.prototype.stats = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\", \"_stats\");\n};\n\n/**\n * Get tail of the server log file.\n *\n * @param {Object} [query] Query parameters.\n * @param {Integer} [query.bytes] Number of bytes to read.\n * @param {Integer} [query.offset] Number of bytes from the end of\n * log file to start reading.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetLog|CouchDB Wiki}\n */\n\nClient.prototype.log = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\", \"_log\");\n};\n\n/**\n * List running tasks.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HttpGetActiveTasks|CouchDB Wiki}\n */\n\nClient.prototype.tasks = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\", \"_active_tasks\");\n};\n\n/**\n * Get or set configuration values.\n *\n * @param {String} [key] Configuration section or key.\n * @param {String} [value] Configuration value.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nClient.prototype.config = function (/* [key], [value], [query], [headers], [callback] */) {\n var args = [].slice.call(arguments);\n var key = isString(args[0]) && args.shift() || \"\";\n var value = isString(args[0]) && args.shift();\n var method = isString(value) ? \"PUT\" : \"GET\";\n return this._(args)(method, \"_config/\" + key, { b: value });\n};\n\n/**\n * Replicate databases.\n *\n * @param {Object} options Options.\n * @param {String} options.source Source database URL or local name.\n * @param {String} options.target Target database URL or local name.\n * @param {Boolean} [options.cancel] Set to `true` to cancel replication.\n * @param {Boolean} [options.continuous] Set to `true` for continuous\n * replication.\n * @param {Boolean} [options.create_target] Set to `true` to create the\n * target database.\n * @param {String} [options.filter] Filter name for filtered replication.\n * Example: \"mydesign/myfilter\".\n * @param {Object} [options.query] Query parameters for filter.\n * @param {String[]} [options.doc_ids] Document IDs to replicate.\n * @param {String} [options.proxy] Proxy through which to replicate.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/Replication|CouchDB Wiki}\n */\n\nClient.prototype.replicate = function (options /* [query], [headers], [callback] */) {\n return this._(arguments, 1)(\"POST\", \"_replicate\", { b: options });\n};\n\n/**\n * Methods for CouchDB database.\n *\n * @param {Client} client Clerk client.\n * @param {String} name DB name.\n * @param {String} [auth] Authentication header value.\n * @constructor\n * @memberof clerk\n * @return This object for chaining.\n */\n\nfunction DB (client, name, auth) {\n this.client = client;\n this.name = name;\n this.uri = client.uri + \"/\" + encodeURIComponent(name);\n this.auth = auth;\n};\n\nDB.prototype = new Base();\n\n/**\n * Create database.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.create = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"PUT\");\n};\n\n/**\n * Destroy database.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.destroy = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"DELETE\");\n};\n\n/**\n * Get database info.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.info = function (/* [query], [headers], callback */) {\n return this._(arguments)(\"GET\");\n};\n\n/**\n * Check if database exists.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.exists = function (/* [query], [headers], callback */) {\n var request = this._(arguments);\n request._ = function (err, body, status, headers, req) {\n return [err, status === 200, status, headers, req];\n };\n return request(\"HEAD\");\n};\n\n/**\n * Fetch document.\n *\n * Set `rev` in `query`.\n *\n * @param {String} id Document ID.\n * @param {Object} [query] HTTP query options.\n * @param {Boolean} [query.revs] Fetch list of revisions.\n * @param {Boolean} [query.revs_info] Fetch detailed revision information.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#GET|CouchDB Wiki}\n */\n\nDB.prototype.get = function (/* [id], [query], [headers], [callback] */) {\n return this._(arguments)(\"GET\");\n};\n\n/**\n * Get document metadata.\n *\n * @param {String} id Document ID.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#HEAD|CouchDB Wiki}\n */\n\nDB.prototype.head = function (/* [id], [query], [headers], callback */) {\n var self = this;\n var request = self._(arguments);\n request._ = function (err, body, status, headers, res) {\n return [err, err ? null : {\n _id: request.p,\n _rev: headers.etag && JSON.parse(headers.etag),\n contentType: headers[\"content-type\"],\n contentLength: headers[\"content-length\"]\n }, status, headers, res];\n };\n return request(\"HEAD\");\n};\n\n/**\n * Post document(s) to database.\n *\n * If documents have no ID, a document ID will be automatically generated\n * on the server. Attachments are not currently supported.\n *\n * @param {Object|Object[]} doc Document or array of documents.\n * @param {String} [doc._id] Document ID. If set, uses given document ID.\n * @param {String} [doc._rev] Document revision. If set, allows update to\n * existing document.\n * @param {Object} [doc._attachments] Attachments. If given, must be a\n * map of filenames to attachment properties.\n * @param {String} [doc._attachments[filename]] Attachment filename, as\n * hash key.\n * @param {String} [doc._attachments[filename].contentType] Attachment\n * MIME content type.\n * @param {String|Object} [doc._attachments[filename].data] Attachment\n * data. Will be Base64 encoded.\n * @param {Object} [query] HTTP query options.\n * @param {Boolean} [query.batch] Allow server to write document in\n * batch mode. Documents will not be written to disk immediately,\n * increasing the chances of write failure.\n * @param {Boolean} [query.all_or_nothing] For batch updating of\n * documents, use all-or-nothing semantics.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#POST|CouchDB Wiki}\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API|CouchDB Wiki}\n */\n\nDB.prototype.post = function (docs /* [query], [headers], [callback] */) {\n var request = this._(arguments, 1);\n if (isArray(docs)) {\n request.p = \"_bulk_docs\";\n request.b = extend({ docs: docs }, request.q);\n request.q = null\n } else {\n request.b = docs;\n }\n return request(\"POST\");\n};\n\n/**\n * Put document in database.\n *\n * @param {Object} doc Document data. Requires `_id` and `_rev`.\n * @param {String} [options] Options.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#PUT|CouchDB Wiki}\n */\n\nDB.prototype.put = function (/* [id], [doc], [query], [headers], [callback] */) {\n var request = this._(arguments, 0, 1);\n // prevent acidentally creating database\n if (!request.p) request.p = request.b._id || request.b.id;\n if (!request.p) throw new Error(\"missing id\");\n return request(\"PUT\");\n};\n\n/**\n * Delete document(s).\n *\n * @param {Object|Object[]} docs Document or array of documents.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#DELETE|CouchDB Wiki}\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API|CouchDB Wiki}\n */\n\nDB.prototype.del = function (docs /* [query], [headers], [callback] */) {\n if (isArray(docs)) {\n var i = 0, len = docs.length, doc;\n for (; i < len; i++) {\n doc = docs[i], docs[i] = {\n _id: doc._id || doc.id,\n _rev: doc._rev || doc.rev,\n _deleted: true\n };\n }\n return this.post.apply(this, arguments);\n } else {\n var request = this._(arguments, 0, 1);\n // prevent acidentally deleting database\n if (!request.p) throw new Error(\"missing id\");\n return request(\"DELETE\");\n }\n};\n\n/**\n * Copy document.\n *\n * @param {Object} source Source document.\n * @param {String} source.id Source document ID.\n * @param {String} [source.rev] Source document revision.\n * @param {String} [source._id] Source document ID. Alternate key for\n * `source.id`.\n * @param {String} [source._rev] Source document revision. Alternate key\n * for `source.id`.\n * @param {Object} target Target document.\n * @param {String} target.id Target document ID.\n * @param {String} [target.rev] Target document revision.\n * @param {String} [target._id] Target document ID. Alternate key for\n * `target.id`.\n * @param {String} [target._rev] Target document revision. Alternate key\n * for `target.id`.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Document_API#COPY|CouchDB Wiki}\n */\n\nDB.prototype.copy = function (source, target /* [query], [headers], [callback] */) {\n var request = this._(arguments, 2);\n var sourcePath = encodeURIComponent(source.id || source._id || source);\n var targetPath = encodeURIComponent(target.id || target._id || target);\n var sourceRev = source.rev || source._rev;\n var targetRev = target.rev || target._rev;\n\n if (sourceRev) request.q.rev = sourceRev;\n if (targetRev) targetPath += \"?rev=\" + encodeURIComponent(targetRev);\n\n request.h.Destination = targetPath;\n\n return request(\"COPY\", sourcePath);\n};\n\n/**\n * Query all documents by ID.\n *\n * @param {Object} [query] HTTP query options.\n * @param {JSON} [query.startkey] Start returning results from this\n * document ID.\n * @param {JSON} [query.endkey] Stop returning results at this document\n * ID.\n * @param {Integer} [query.limit] Limit number of results returned.\n * @param {Boolean} [query.descending=false] Lookup results in reverse\n * order by key, returning documents in descending order by key.\n * @param {Integer} [query.skip] Skip this many records before\n * returning results.\n * @param {Boolean} [query.include_docs=false] Include document source for\n * each result.\n * @param {Boolean} [query.include_end=true] Include `query.endkey`\n * in results.\n * @param {Boolean} [query.update_seq=false] Include sequence value\n * of the database corresponding to the view.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API|CouchDB Wiki}\n */\n\nDB.prototype.all = function (/* [query], [headers], [callback] */) {\n var request = this._(arguments);\n var body = this._viewOptions(request.q);\n return request(body ? \"POST\" : \"GET\", \"_all_docs\", { b: body });\n};\n\n/**\n * Query a view.\n *\n * @param {String|Object} view View name (e.g. mydesign/myview) or\n * temporary view definition. Using a temporary view is strongly not\n * recommended for production use.\n * @param {Object} [query] HTTP query options.\n * @param {JSON} [query.key] Key to lookup.\n * @param {JSON} [query.startkey] Start returning results from this key.\n * @param {String} [query.startkey_docid] Start returning results\n * from this document ID. Allows pagination with duplicate keys.\n * @param {JSON} [query.endkey] Stop returning results at this key.\n * @param {String} [query.endkey_docid] Stop returning results at\n * this document ID. Allows pagination with duplicate keys.\n * @param {Integer} [query.limit] Limit number of results returned.\n * @param {Boolean|String} [query.stale] Do not refresh view even if\n * stale. For CouchDB versions `1.1.0` and up, set to `update_after` to\n * update view after results are returned.\n * @param {Boolean} [query.descending=false] Lookup results in reverse\n * order by key, returning documents in descending order by key.\n * @param {Integer} [query.skip] Skip this many records before\n * returning results.\n * @param {Boolean|Integer} [query.group=false] Use the reduce function\n * to group results by key. Set to an integer specify `group_level`.\n * @param {Boolean|Integer} [query.reduce=true] Use the reduce function.\n * @param {Boolean} [query.fetch=false] Include document source for\n * each result.\n * @param {Boolean} [query.include_end=true] Include `query.endkey`\n * in results.\n * @param {Boolean} [query.update_seq=false] Include sequence value\n * of the database corresponding to the view.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_view_API|CouchDB Wiki}\n */\n\nDB.prototype.find = function (view /* [query], [headers], [callback] */) {\n var request = this._(arguments, 1), path, body;\n\n if (isString(view)) {\n path = view.split(\"/\", 2);\n path = \"_design/\" + encodeURIComponent(path[0]) +\n \"/_view/\" + encodeURIComponent(path[1]);\n } else {\n path = \"_temp_view\";\n body = view;\n }\n\n body = this._viewOptions(request.q, body);\n return request(body ? \"POST\" : \"GET\", path, { b: body });\n};\n\n/**\n * Get database changes.\n *\n * The `feed` option determines how the callback is called:\n *\n * - `normal` calls the callback once.\n * - `longpoll` waits for a response, then calls the callback once.\n * - `continuous` calls the callback each time an update is received.\n * Implemented as the `database#follow()` method.\n *\n * @param {Object} [query] HTTP query options.\n * @param {String} [query.feed=\"normal\"] Type of feed. See comments\n * above.\n * @param {String} [query.filter] Filter updates using this filter.\n * @param {Integer} [query.limit] Maximum number of rows to return.\n * @param {Integer} [query.since=0] Start results from this sequence\n * number.\n * @param {Boolean} [query.include_docs=false] Include documents with\n * results.\n * @param {Integer} [query.timeout=1000] Maximum period in milliseconds\n * to wait for a change before sending a response, even if there are no\n * results.\n * @param {Integer} [query.heartbeat=1000] Period in milliseconds after\n * which an empty line is sent. Applicable only to feed types\n * `longpoll` and `continuous`. Overrides `query.timeout` to keep the\n * feed alive indefinitely.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/HTTP_database_API#Changes|CouchDB Wiki}\n */\n\nDB.prototype.changes = function (/* [query], [headers], [callback] */) {\n var request = this._(arguments);\n if (request.q.feed != \"longpoll\") delete request.q.feed;\n return this._changes(request);\n};\n\n/**\n * Follow database changes.\n *\n * @see `#changes()`.\n */\n\nDB.prototype.follow = function (/* [query], [headers], callback */) {\n var self = this;\n var request = this._(arguments);\n var fn = request.f;\n\n if (!fn) return this;\n\n request.q.feed = \"longpoll\";\n request.f = function (err, body) {\n var args = [].slice.call(arguments);\n var done, i;\n for (i = 0; i < body.length; i++) {\n args[1] = body[i];\n if (done = fn.apply(self, args) === false || err) break;\n }\n if (!done) self._changes(request);\n };\n\n return this._changes(request);\n};\n\n/**\n * Service a changes request.\n *\n * @private\n */\n\nDB.prototype._changes = function (request) {\n return request(\"GET\", \"_changes\");\n};\n\n/**\n * Update document using server-side handler.\n *\n * @param {String} handler Update handler. Example: mydesign/myhandler\n * @param {String} [id] Document ID.\n * @param {Object} [query] HTTP query options.\n * @param {Object|String} [data] Data.\n * @param {Object} [headers] Headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/Document_Update_Handlers|CouchDB Wiki}\n */\n\nDB.prototype.update = function (handler /* [id], [data], [query], [headers], [callback] */) {\n var request = this._(arguments, 1, 1);\n var path = handler.split(\"/\", 2);\n\n path = \"_design/\" + encodeURIComponent(path[0]) +\n \"/_update/\" + encodeURIComponent(path[1]);\n\n if (request.p) path += \"/\" + request.p;\n\n return request(\"POST\", path);\n};\n\n/**\n * Download attachment from document.\n *\n * @param {Object|String} docOrId Document or document ID.\n * @param {String} attachmentName Attachment name.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.attachment = function (doc, attachmentName /* [query], [headers], [callback] */) {\n var request = this._(arguments, 2);\n var path = encodeURIComponent(doc._id || doc.id || doc) + \"/\" +\n encodeURIComponent(attachmentName);\n return request(\"GET\", path, options);\n};\n\n/**\n * Upload attachment to document.\n *\n * Set the `Content-Type` header.\n *\n * @param {Object} [doc] Document. Requires `id`. `rev` can be specified\n * here or in `query`.\n * @param {String} attachmentName Attachment name.\n * @param {Object} data Data.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.attach = function (doc, attachmentName, data /* [query], [headers], [callback] */) {\n var request = this._(arguments, 3);\n request.p = encodeURIComponent(doc._id || doc.id) + \"/\" +\n encodeURIComponent(attachmentName);\n if (!request.q.rev) request.q.rev = doc._rev || doc.rev;\n request.q.body = data;\n return request(\"PUT\", path);\n};\n\n/**\n * Replicate database.\n *\n * This convenience function sets `options.source` and `options.target` to\n * the selected database name. Either `options.source` or `options.target`\n * must be overridden for a successful replication request.\n *\n * @param {Options} options Options. Accepts all options from\n * `Client.replicate()`.\n * @param {String} [options.source=this.name] Source database URL or\n * local name. Defaults to the selected database name if not given.\n * @param {String} [options.target=this.name] Target database URL or\n * local name. Defaults to the selected database name if not given.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.replicate = function (options /* [query], [headers], [callback] */) {\n if (!options.source) options.source = this.name;\n if (!options.target) options.target = this.name;\n return this.client.replicate.apply(this.client, arguments);\n};\n\n/**\n * Ensure recent changes are committed to disk.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.commit = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"POST\", \"_ensure_full_commit\");\n};\n\n/**\n * Purge deleted documents from database.\n *\n * @param {Object} revs Map of document IDs to revisions to be purged.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n */\n\nDB.prototype.purge = function (revs /* [query], [headers], [callback] */) {\n return this._(arguments, 1)(\"POST\", \"_purge\", { b: revs });\n};\n\n/**\n * Compact database or design.\n *\n * @param {String} [design] Design name if compacting design indexes.\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/Compaction|CouchDB Wiki}\n */\n\nDB.prototype.compact = function (/* [design], [query], [headers], [callback] */) {\n var request = this._(arguments);\n return request(\"POST\", \"_compact/\" + (request.p || \"\"));\n};\n\n/**\n * Remove unused views.\n *\n * @param {Object} [query] HTTP query options.\n * @param {Object} [headers] HTTP headers.\n * @param {handler} [callback] Callback function.\n * @return {Promise} A Promise, if no callback is provided,\n * otherwise `null`.\n * @see {@link http://wiki.apache.org/couchdb/Compaction|CouchDB Wiki}\n */\n\nDB.prototype.vacuum = function (/* [query], [headers], [callback] */) {\n return this._(arguments)(\"POST\", \"_view_cleanup\");\n};\n\n/**\n * Parse view options.\n *\n * @param {Object} query The HTTP query options.\n * @param {Object} body The body payload.\n * @param {handler} [callback] Callback function.\n * @return {Object} The body payload.\n * @private\n */\n\nDB.prototype._viewOptions = function (q, body) {\n if (q) {\n if (q.key) q.key = JSON.stringify(q.key);\n if (q.startkey) q.startkey = JSON.stringify(q.startkey);\n if (q.endkey) q.endkey = JSON.stringify(q.endkey);\n if (q.stale && q.stale != \"update_after\") q.stale = \"ok\";\n if (q.keys) {\n if (!body) body = {};\n body.keys = q.keys;\n delete q.keys;\n }\n }\n return body;\n};\n\n/**\n * Handle a clerk response.\n *\n * @callback handler\n * @param {Error|null} error Error or `null` on success.\n * @param {Object} data Response data.\n * @param {Integer} status Response status code.\n * @param {Object} headers Response headers.\n * @param {superagent.Response} res Superagent response object.\n */\n\nclerk.Base = Base;\nclerk.Client = Client;\nclerk.DB = DB;\n\n// Export clerk.\nmodule.exports = clerk;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./clerk.js\n ** module id = 0\n ** module chunks = 0\n **/","/**\n * Module dependencies.\n */\n\nvar Emitter = require('emitter');\nvar reduce = require('reduce');\n\n/**\n * Root reference for iframes.\n */\n\nvar root = 'undefined' == typeof window\n ? this\n : window;\n\n/**\n * Noop.\n */\n\nfunction noop(){};\n\n/**\n * Check if `obj` is a host object,\n * we don't want to serialize these :)\n *\n * TODO: future proof, move to compoent land\n *\n * @param {Object} obj\n * @return {Boolean}\n * @api private\n */\n\nfunction isHost(obj) {\n var str = {}.toString.call(obj);\n\n switch (str) {\n case '[object File]':\n case '[object Blob]':\n case '[object FormData]':\n return true;\n default:\n return false;\n }\n}\n\n/**\n * Determine XHR.\n */\n\nfunction getXHR() {\n if (root.XMLHttpRequest\n && ('file:' != root.location.protocol || !root.ActiveXObject)) {\n return new XMLHttpRequest;\n } else {\n try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) {}\n }\n return false;\n}\n\n/**\n * Removes leading and trailing whitespace, added to support IE.\n *\n * @param {String} s\n * @return {String}\n * @api private\n */\n\nvar trim = ''.trim\n ? function(s) { return s.trim(); }\n : function(s) { return s.replace(/(^\\s*|\\s*$)/g, ''); };\n\n/**\n * Check if `obj` is an object.\n *\n * @param {Object} obj\n * @return {Boolean}\n * @api private\n */\n\nfunction isObject(obj) {\n return obj === Object(obj);\n}\n\n/**\n * Serialize the given `obj`.\n *\n * @param {Object} obj\n * @return {String}\n * @api private\n */\n\nfunction serialize(obj) {\n if (!isObject(obj)) return obj;\n var pairs = [];\n for (var key in obj) {\n if (null != obj[key]) {\n pairs.push(encodeURIComponent(key)\n + '=' + encodeURIComponent(obj[key]));\n }\n }\n return pairs.join('&');\n}\n\n/**\n * Expose serialization method.\n */\n\n request.serializeObject = serialize;\n\n /**\n * Parse the given x-www-form-urlencoded `str`.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\nfunction parseString(str) {\n var obj = {};\n var pairs = str.split('&');\n var parts;\n var pair;\n\n for (var i = 0, len = pairs.length; i < len; ++i) {\n pair = pairs[i];\n parts = pair.split('=');\n obj[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]);\n }\n\n return obj;\n}\n\n/**\n * Expose parser.\n */\n\nrequest.parseString = parseString;\n\n/**\n * Default MIME type map.\n *\n * superagent.types.xml = 'application/xml';\n *\n */\n\nrequest.types = {\n html: 'text/html',\n json: 'application/json',\n xml: 'application/xml',\n urlencoded: 'application/x-www-form-urlencoded',\n 'form': 'application/x-www-form-urlencoded',\n 'form-data': 'application/x-www-form-urlencoded'\n};\n\n/**\n * Default serialization map.\n *\n * superagent.serialize['application/xml'] = function(obj){\n * return 'generated xml here';\n * };\n *\n */\n\n request.serialize = {\n 'application/x-www-form-urlencoded': serialize,\n 'application/json': JSON.stringify\n };\n\n /**\n * Default parsers.\n *\n * superagent.parse['application/xml'] = function(str){\n * return { object parsed from str };\n * };\n *\n */\n\nrequest.parse = {\n 'application/x-www-form-urlencoded': parseString,\n 'application/json': JSON.parse\n};\n\n/**\n * Parse the given header `str` into\n * an object containing the mapped fields.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\nfunction parseHeader(str) {\n var lines = str.split(/\\r?\\n/);\n var fields = {};\n var index;\n var line;\n var field;\n var val;\n\n lines.pop(); // trailing CRLF\n\n for (var i = 0, len = lines.length; i < len; ++i) {\n line = lines[i];\n index = line.indexOf(':');\n field = line.slice(0, index).toLowerCase();\n val = trim(line.slice(index + 1));\n fields[field] = val;\n }\n\n return fields;\n}\n\n/**\n * Return the mime type for the given `str`.\n *\n * @param {String} str\n * @return {String}\n * @api private\n */\n\nfunction type(str){\n return str.split(/ *; */).shift();\n};\n\n/**\n * Return header field parameters.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\nfunction params(str){\n return reduce(str.split(/ *; */), function(obj, str){\n var parts = str.split(/ *= */)\n , key = parts.shift()\n , val = parts.shift();\n\n if (key && val) obj[key] = val;\n return obj;\n }, {});\n};\n\n/**\n * Initialize a new `Response` with the given `xhr`.\n *\n * - set flags (.ok, .error, etc)\n * - parse header\n *\n * Examples:\n *\n * Aliasing `superagent` as `request` is nice:\n *\n * request = superagent;\n *\n * We can use the promise-like API, or pass callbacks:\n *\n * request.get('/').end(function(res){});\n * request.get('/', function(res){});\n *\n * Sending data can be chained:\n *\n * request\n * .post('/user')\n * .send({ name: 'tj' })\n * .end(function(res){});\n *\n * Or passed to `.send()`:\n *\n * request\n * .post('/user')\n * .send({ name: 'tj' }, function(res){});\n *\n * Or passed to `.post()`:\n *\n * request\n * .post('/user', { name: 'tj' })\n * .end(function(res){});\n *\n * Or further reduced to a single call for simple cases:\n *\n * request\n * .post('/user', { name: 'tj' }, function(res){});\n *\n * @param {XMLHTTPRequest} xhr\n * @param {Object} options\n * @api private\n */\n\nfunction Response(req, options) {\n options = options || {};\n this.req = req;\n this.xhr = this.req.xhr;\n this.text = this.req.method !='HEAD' \n ? this.xhr.responseText \n : null;\n this.setStatusProperties(this.xhr.status);\n this.header = this.headers = parseHeader(this.xhr.getAllResponseHeaders());\n // getAllResponseHeaders sometimes falsely returns \"\" for CORS requests, but\n // getResponseHeader still works. so we get content-type even if getting\n // other headers fails.\n this.header['content-type'] = this.xhr.getResponseHeader('content-type');\n this.setHeaderProperties(this.header);\n this.body = this.req.method != 'HEAD'\n ? this.parseBody(this.text)\n : null;\n}\n\n/**\n * Get case-insensitive `field` value.\n *\n * @param {String} field\n * @return {String}\n * @api public\n */\n\nResponse.prototype.get = function(field){\n return this.header[field.toLowerCase()];\n};\n\n/**\n * Set header related properties:\n *\n * - `.type` the content type without params\n *\n * A response of \"Content-Type: text/plain; charset=utf-8\"\n * will provide you with a `.type` of \"text/plain\".\n *\n * @param {Object} header\n * @api private\n */\n\nResponse.prototype.setHeaderProperties = function(header){\n // content-type\n var ct = this.header['content-type'] || '';\n this.type = type(ct);\n\n // params\n var obj = params(ct);\n for (var key in obj) this[key] = obj[key];\n};\n\n/**\n * Parse the given body `str`.\n *\n * Used for auto-parsing of bodies. Parsers\n * are defined on the `superagent.parse` object.\n *\n * @param {String} str\n * @return {Mixed}\n * @api private\n */\n\nResponse.prototype.parseBody = function(str){\n var parse = request.parse[this.type];\n return parse && str && str.length\n ? parse(str)\n : null;\n};\n\n/**\n * Set flags such as `.ok` based on `status`.\n *\n * For example a 2xx response will give you a `.ok` of __true__\n * whereas 5xx will be __false__ and `.error` will be __true__. The\n * `.clientError` and `.serverError` are also available to be more\n * specific, and `.statusType` is the class of error ranging from 1..5\n * sometimes useful for mapping respond colors etc.\n *\n * \"sugar\" properties are also defined for common cases. Currently providing:\n *\n * - .noContent\n * - .badRequest\n * - .unauthorized\n * - .notAcceptable\n * - .notFound\n *\n * @param {Number} status\n * @api private\n */\n\nResponse.prototype.setStatusProperties = function(status){\n var type = status / 100 | 0;\n\n // status / class\n this.status = status;\n this.statusType = type;\n\n // basics\n this.info = 1 == type;\n this.ok = 2 == type;\n this.clientError = 4 == type;\n this.serverError = 5 == type;\n this.error = (4 == type || 5 == type)\n ? this.toError()\n : false;\n\n // sugar\n this.accepted = 202 == status;\n this.noContent = 204 == status || 1223 == status;\n this.badRequest = 400 == status;\n this.unauthorized = 401 == status;\n this.notAcceptable = 406 == status;\n this.notFound = 404 == status;\n this.forbidden = 403 == status;\n};\n\n/**\n * Return an `Error` representative of this response.\n *\n * @return {Error}\n * @api public\n */\n\nResponse.prototype.toError = function(){\n var req = this.req;\n var method = req.method;\n var url = req.url;\n\n var msg = 'cannot ' + method + ' ' + url + ' (' + this.status + ')';\n var err = new Error(msg);\n err.status = this.status;\n err.method = method;\n err.url = url;\n\n return err;\n};\n\n/**\n * Expose `Response`.\n */\n\nrequest.Response = Response;\n\n/**\n * Initialize a new `Request` with the given `method` and `url`.\n *\n * @param {String} method\n * @param {String} url\n * @api public\n */\n\nfunction Request(method, url) {\n var self = this;\n Emitter.call(this);\n this._query = this._query || [];\n this.method = method;\n this.url = url;\n this.header = {};\n this._header = {};\n this.on('end', function(){\n var err = null;\n var res = null;\n\n try {\n res = new Response(self); \n } catch(e) {\n err = new Error('Parser is unable to parse the response');\n err.parse = true;\n err.original = e;\n }\n\n self.callback(err, res);\n });\n}\n\n/**\n * Mixin `Emitter`.\n */\n\nEmitter(Request.prototype);\n\n/**\n * Allow for extension\n */\n\nRequest.prototype.use = function(fn) {\n fn(this);\n return this;\n}\n\n/**\n * Set timeout to `ms`.\n *\n * @param {Number} ms\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.timeout = function(ms){\n this._timeout = ms;\n return this;\n};\n\n/**\n * Clear previous timeout.\n *\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.clearTimeout = function(){\n this._timeout = 0;\n clearTimeout(this._timer);\n return this;\n};\n\n/**\n * Abort the request, and clear potential timeout.\n *\n * @return {Request}\n * @api public\n */\n\nRequest.prototype.abort = function(){\n if (this.aborted) return;\n this.aborted = true;\n this.xhr.abort();\n this.clearTimeout();\n this.emit('abort');\n return this;\n};\n\n/**\n * Set header `field` to `val`, or multiple fields with one object.\n *\n * Examples:\n *\n * req.get('/')\n * .set('Accept', 'application/json')\n * .set('X-API-Key', 'foobar')\n * .end(callback);\n *\n * req.get('/')\n * .set({ Accept: 'application/json', 'X-API-Key': 'foobar' })\n * .end(callback);\n *\n * @param {String|Object} field\n * @param {String} val\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.set = function(field, val){\n if (isObject(field)) {\n for (var key in field) {\n this.set(key, field[key]);\n }\n return this;\n }\n this._header[field.toLowerCase()] = val;\n this.header[field] = val;\n return this;\n};\n\n/**\n * Remove header `field`.\n *\n * Example:\n *\n * req.get('/')\n * .unset('User-Agent')\n * .end(callback);\n *\n * @param {String} field\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.unset = function(field){\n delete this._header[field.toLowerCase()];\n delete this.header[field];\n return this;\n};\n\n/**\n * Get case-insensitive header `field` value.\n *\n * @param {String} field\n * @return {String}\n * @api private\n */\n\nRequest.prototype.getHeader = function(field){\n return this._header[field.toLowerCase()];\n};\n\n/**\n * Set Content-Type to `type`, mapping values from `request.types`.\n *\n * Examples:\n *\n * superagent.types.xml = 'application/xml';\n *\n * request.post('/')\n * .type('xml')\n * .send(xmlstring)\n * .end(callback);\n *\n * request.post('/')\n * .type('application/xml')\n * .send(xmlstring)\n * .end(callback);\n *\n * @param {String} type\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.type = function(type){\n this.set('Content-Type', request.types[type] || type);\n return this;\n};\n\n/**\n * Set Accept to `type`, mapping values from `request.types`.\n *\n * Examples:\n *\n * superagent.types.json = 'application/json';\n *\n * request.get('/agent')\n * .accept('json')\n * .end(callback);\n *\n * request.get('/agent')\n * .accept('application/json')\n * .end(callback);\n *\n * @param {String} accept\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.accept = function(type){\n this.set('Accept', request.types[type] || type);\n return this;\n};\n\n/**\n * Set Authorization field value with `user` and `pass`.\n *\n * @param {String} user\n * @param {String} pass\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.auth = function(user, pass){\n var str = btoa(user + ':' + pass);\n this.set('Authorization', 'Basic ' + str);\n return this;\n};\n\n/**\n* Add query-string `val`.\n*\n* Examples:\n*\n* request.get('/shoes')\n* .query('size=10')\n* .query({ color: 'blue' })\n*\n* @param {Object|String} val\n* @return {Request} for chaining\n* @api public\n*/\n\nRequest.prototype.query = function(val){\n if ('string' != typeof val) val = serialize(val);\n if (val) this._query.push(val);\n return this;\n};\n\n/**\n * Write the field `name` and `val` for \"multipart/form-data\"\n * request bodies.\n *\n * ``` js\n * request.post('/upload')\n * .field('foo', 'bar')\n * .end(callback);\n * ```\n *\n * @param {String} name\n * @param {String|Blob|File} val\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.field = function(name, val){\n if (!this._formData) this._formData = new FormData();\n this._formData.append(name, val);\n return this;\n};\n\n/**\n * Queue the given `file` as an attachment to the specified `field`,\n * with optional `filename`.\n *\n * ``` js\n * request.post('/upload')\n * .attach(new Blob(['hey!'], { type: \"text/html\"}))\n * .end(callback);\n * ```\n *\n * @param {String} field\n * @param {Blob|File} file\n * @param {String} filename\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.attach = function(field, file, filename){\n if (!this._formData) this._formData = new FormData();\n this._formData.append(field, file, filename);\n return this;\n};\n\n/**\n * Send `data`, defaulting the `.type()` to \"json\" when\n * an object is given.\n *\n * Examples:\n *\n * // querystring\n * request.get('/search')\n * .end(callback)\n *\n * // multiple data \"writes\"\n * request.get('/search')\n * .send({ search: 'query' })\n * .send({ range: '1..5' })\n * .send({ order: 'desc' })\n * .end(callback)\n *\n * // manual json\n * request.post('/user')\n * .type('json')\n * .send('{\"name\":\"tj\"})\n * .end(callback)\n *\n * // auto json\n * request.post('/user')\n * .send({ name: 'tj' })\n * .end(callback)\n *\n * // manual x-www-form-urlencoded\n * request.post('/user')\n * .type('form')\n * .send('name=tj')\n * .end(callback)\n *\n * // auto x-www-form-urlencoded\n * request.post('/user')\n * .type('form')\n * .send({ name: 'tj' })\n * .end(callback)\n *\n * // defaults to x-www-form-urlencoded\n * request.post('/user')\n * .send('name=tobi')\n * .send('species=ferret')\n * .end(callback)\n *\n * @param {String|Object} data\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.send = function(data){\n var obj = isObject(data);\n var type = this.getHeader('Content-Type');\n\n // merge\n if (obj && isObject(this._data)) {\n for (var key in data) {\n this._data[key] = data[key];\n }\n } else if ('string' == typeof data) {\n if (!type) this.type('form');\n type = this.getHeader('Content-Type');\n if ('application/x-www-form-urlencoded' == type) {\n this._data = this._data\n ? this._data + '&' + data\n : data;\n } else {\n this._data = (this._data || '') + data;\n }\n } else {\n this._data = data;\n }\n\n if (!obj) return this;\n if (!type) this.type('json');\n return this;\n};\n\n/**\n * Invoke the callback with `err` and `res`\n * and handle arity check.\n *\n * @param {Error} err\n * @param {Response} res\n * @api private\n */\n\nRequest.prototype.callback = function(err, res){\n var fn = this._callback;\n this.clearTimeout();\n if (2 == fn.length) return fn(err, res);\n if (err) return this.emit('error', err);\n fn(res);\n};\n\n/**\n * Invoke callback with x-domain error.\n *\n * @api private\n */\n\nRequest.prototype.crossDomainError = function(){\n var err = new Error('Origin is not allowed by Access-Control-Allow-Origin');\n err.crossDomain = true;\n this.callback(err);\n};\n\n/**\n * Invoke callback with timeout error.\n *\n * @api private\n */\n\nRequest.prototype.timeoutError = function(){\n var timeout = this._timeout;\n var err = new Error('timeout of ' + timeout + 'ms exceeded');\n err.timeout = timeout;\n this.callback(err);\n};\n\n/**\n * Enable transmission of cookies with x-domain requests.\n *\n * Note that for this to work the origin must not be\n * using \"Access-Control-Allow-Origin\" with a wildcard,\n * and also must set \"Access-Control-Allow-Credentials\"\n * to \"true\".\n *\n * @api public\n */\n\nRequest.prototype.withCredentials = function(){\n this._withCredentials = true;\n return this;\n};\n\n/**\n * Initiate request, invoking callback `fn(res)`\n * with an instanceof `Response`.\n *\n * @param {Function} fn\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.end = function(fn){\n var self = this;\n var xhr = this.xhr = getXHR();\n var query = this._query.join('&');\n var timeout = this._timeout;\n var data = this._formData || this._data;\n\n // store callback\n this._callback = fn || noop;\n\n // state change\n xhr.onreadystatechange = function(){\n if (4 != xhr.readyState) return;\n if (0 == xhr.status) {\n if (self.aborted) return self.timeoutError();\n return self.crossDomainError();\n }\n self.emit('end');\n };\n\n // progress\n if (xhr.upload) {\n xhr.upload.onprogress = function(e){\n e.percent = e.loaded / e.total * 100;\n self.emit('progress', e);\n };\n }\n\n // timeout\n if (timeout && !this._timer) {\n this._timer = setTimeout(function(){\n self.abort();\n }, timeout);\n }\n\n // querystring\n if (query) {\n query = request.serializeObject(query);\n this.url += ~this.url.indexOf('?')\n ? '&' + query\n : '?' + query;\n }\n\n // initiate request\n xhr.open(this.method, this.url, true);\n\n // CORS\n if (this._withCredentials) xhr.withCredentials = true;\n\n // body\n if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !isHost(data)) {\n // serialize stuff\n var serialize = request.serialize[this.getHeader('Content-Type')];\n if (serialize) data = serialize(data);\n }\n\n // set header fields\n for (var field in this.header) {\n if (null == this.header[field]) continue;\n xhr.setRequestHeader(field, this.header[field]);\n }\n\n // send stuff\n this.emit('request', this);\n xhr.send(data);\n return this;\n};\n\n/**\n * Expose `Request`.\n */\n\nrequest.Request = Request;\n\n/**\n * Issue a request:\n *\n * Examples:\n *\n * request('GET', '/users').end(callback)\n * request('/users').end(callback)\n * request('/users', callback)\n *\n * @param {String} method\n * @param {String|Function} url or callback\n * @return {Request}\n * @api public\n */\n\nfunction request(method, url) {\n // callback\n if ('function' == typeof url) {\n return new Request('GET', method).end(url);\n }\n\n // url first\n if (1 == arguments.length) {\n return new Request('GET', method);\n }\n\n return new Request(method, url);\n}\n\n/**\n * GET `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} data or fn\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.get = function(url, data, fn){\n var req = request('GET', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.query(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * HEAD `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} data or fn\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.head = function(url, data, fn){\n var req = request('HEAD', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * DELETE `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.del = function(url, fn){\n var req = request('DELETE', url);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * PATCH `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed} data\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.patch = function(url, data, fn){\n var req = request('PATCH', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * POST `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed} data\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.post = function(url, data, fn){\n var req = request('POST', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * PUT `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} data or fn\n * @param {Function} fn\n * @return {Request}\n * @api public\n */\n\nrequest.put = function(url, data, fn){\n var req = request('PUT', url);\n if ('function' == typeof data) fn = data, data = null;\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n/**\n * Expose `request`.\n */\n\nmodule.exports = request;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/superagent/lib/client.js\n ** module id = 1\n ** module chunks = 0\n **/","\n/**\n * Expose `Emitter`.\n */\n\nmodule.exports = Emitter;\n\n/**\n * Initialize a new `Emitter`.\n *\n * @api public\n */\n\nfunction Emitter(obj) {\n if (obj) return mixin(obj);\n};\n\n/**\n * Mixin the emitter properties.\n *\n * @param {Object} obj\n * @return {Object}\n * @api private\n */\n\nfunction mixin(obj) {\n for (var key in Emitter.prototype) {\n obj[key] = Emitter.prototype[key];\n }\n return obj;\n}\n\n/**\n * Listen on the given `event` with `fn`.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.on =\nEmitter.prototype.addEventListener = function(event, fn){\n this._callbacks = this._callbacks || {};\n (this._callbacks[event] = this._callbacks[event] || [])\n .push(fn);\n return this;\n};\n\n/**\n * Adds an `event` listener that will be invoked a single\n * time then automatically removed.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.once = function(event, fn){\n var self = this;\n this._callbacks = this._callbacks || {};\n\n function on() {\n self.off(event, on);\n fn.apply(this, arguments);\n }\n\n on.fn = fn;\n this.on(event, on);\n return this;\n};\n\n/**\n * Remove the given callback for `event` or all\n * registered callbacks.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.off =\nEmitter.prototype.removeListener =\nEmitter.prototype.removeAllListeners =\nEmitter.prototype.removeEventListener = function(event, fn){\n this._callbacks = this._callbacks || {};\n\n // all\n if (0 == arguments.length) {\n this._callbacks = {};\n return this;\n }\n\n // specific event\n var callbacks = this._callbacks[event];\n if (!callbacks) return this;\n\n // remove all handlers\n if (1 == arguments.length) {\n delete this._callbacks[event];\n return this;\n }\n\n // remove specific handler\n var cb;\n for (var i = 0; i < callbacks.length; i++) {\n cb = callbacks[i];\n if (cb === fn || cb.fn === fn) {\n callbacks.splice(i, 1);\n break;\n }\n }\n return this;\n};\n\n/**\n * Emit `event` with the given args.\n *\n * @param {String} event\n * @param {Mixed} ...\n * @return {Emitter}\n */\n\nEmitter.prototype.emit = function(event){\n this._callbacks = this._callbacks || {};\n var args = [].slice.call(arguments, 1)\n , callbacks = this._callbacks[event];\n\n if (callbacks) {\n callbacks = callbacks.slice(0);\n for (var i = 0, len = callbacks.length; i < len; ++i) {\n callbacks[i].apply(this, args);\n }\n }\n\n return this;\n};\n\n/**\n * Return array of callbacks for `event`.\n *\n * @param {String} event\n * @return {Array}\n * @api public\n */\n\nEmitter.prototype.listeners = function(event){\n this._callbacks = this._callbacks || {};\n return this._callbacks[event] || [];\n};\n\n/**\n * Check if this emitter has `event` handlers.\n *\n * @param {String} event\n * @return {Boolean}\n * @api public\n */\n\nEmitter.prototype.hasListeners = function(event){\n return !! this.listeners(event).length;\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/superagent/~/component-emitter/index.js\n ** module id = 2\n ** module chunks = 0\n **/","\n/**\n * Reduce `arr` with `fn`.\n *\n * @param {Array} arr\n * @param {Function} fn\n * @param {Mixed} initial\n *\n * TODO: combatible error handling?\n */\n\nmodule.exports = function(arr, fn, initial){ \n var idx = 0;\n var len = arr.length;\n var curr = arguments.length == 3\n ? initial\n : arr[idx++];\n\n while (idx < len) {\n curr = fn.call(null, curr, arr[idx], ++idx, arr);\n }\n \n return curr;\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/superagent/~/reduce-component/index.js\n ** module id = 3\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file diff --git a/package.json b/package.json index bbac208..cf06f2a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "clerk", "description": "CouchDB library for Node and the browser", - "version": "0.7.2", + "version": "0.8.0", "author": "Michael Phan-Ba ", "homepage": "https://github.com/mikepb/clerk", "repository": {