-
Notifications
You must be signed in to change notification settings - Fork 1
/
angular-pouchdb.min.js
1 lines (1 loc) · 1.6 KB
/
angular-pouchdb.min.js
1
"undefined"!=typeof module&&"undefined"!=typeof exports&&module.exports===exports&&(module.exports="pouchdb"),function(e,t,n){"use strict";t.module("pouchdb",[]).constant("POUCHDB_METHODS",{destroy:"qify",put:"qify",post:"qify",get:"qify",remove:"qify",bulkDocs:"qify",bulkGet:"qify",allDocs:"qify",putAttachment:"qify",getAttachment:"qify",removeAttachment:"qify",query:"qify",viewCleanup:"qify",info:"qify",compact:"qify",revsDiff:"qify",changes:"eventEmitter",sync:"eventEmitter",replicate:"replicate"}).service("pouchDBDecorators",["$q",function(e){var t=this;this.qify=function(t){return function(){return e.when(t.apply(this,arguments))}},this.eventEmitter=function(t){return function(){var n=e.defer(),r=t.apply(this,arguments).on("change",function(e){return n.notify({change:e})}).on("paused",function(e){return n.notify({paused:e})}).on("active",function(e){return n.notify({active:e})}).on("denied",function(e){return n.notify({denied:e})}).on("complete",function(e){return n.resolve(e)}).on("error",function(e){return n.reject(e)});return r.$promise=n.promise,r}},this.replicate=function(e,n){var r=Object.keys(e).reduce(function(e,r){return e[r]=t.eventEmitter(n.replicate[r]),e},{});Object.defineProperty(n,"replicate",{get:function(){return r}})}}]).provider("pouchDB",["POUCHDB_METHODS",function(e){var n=this;n.methods=e,n.$get=["$window","pouchDBDecorators",function(e,r){function i(e,n,o){for(var u in n){var c,f=n[u];t.isString(f)?(f=r[f],o?(c=f(e[o][u]),c&&(e[o][u]=c)):(c=f(e[u],e),c&&(e[u]=c))):i(e,f,u)}return e}return function(t,r){var o=new e.PouchDB(t,r);return i(o,n.methods)}}]}])}(window,window.angular);