pouchdb-all-dbs
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "pouchdb-all-dbs", | ||
"version": "1.0.1", | ||
"description": "allDbs() plugin for PouchDB", | ||
"main": "dist/pouchdb.all-dbs.js", | ||
"version": "1.0.0", | ||
"homepage": "https://github.com/nolanlawson/pouchdb-all-dbs", | ||
@@ -9,3 +10,2 @@ "authors": [ | ||
], | ||
"description": "allDbs() plugin for PouchDB", | ||
"moduleType": [ | ||
@@ -12,0 +12,0 @@ "node" |
@@ -7,2 +7,16 @@ ;(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
var PREFIX = "db_"; | ||
function prefixed(dbName) { | ||
//A database name starting with an underscore is valid, but a document | ||
//id starting with an underscore is not in most cases. Because of | ||
//that, they're prefixed in the all dbs database. See issue #7 for | ||
//more info. | ||
return PREFIX + dbName; | ||
} | ||
function unprefixed(dbName) { | ||
return dbName.slice(PREFIX.length); | ||
} | ||
module.exports = function (Pouch) { | ||
@@ -12,2 +26,3 @@ | ||
var pouch; | ||
var cache; | ||
var queue = new TaskQueue(); | ||
@@ -40,8 +55,17 @@ | ||
function canIgnore(dbName) { | ||
return (dbName === ALL_DBS_NAME) || | ||
// TODO: get rid of this when we have a real 'onDependentDbRegistered' | ||
// event (pouchdb/pouchdb#2438) | ||
(dbName.indexOf('-mrview-') !== -1) || | ||
// TODO: might be a better way to detect remote DBs | ||
(/^https?:\/\//.test(dbName)); | ||
} | ||
Pouch.on('created', function (dbName) { | ||
dbName = normalize(dbName); | ||
if (dbName === ALL_DBS_NAME) { | ||
if (canIgnore(dbName)) { | ||
return; | ||
} | ||
dbName = prefixed(dbName); | ||
init(); | ||
@@ -57,2 +81,5 @@ queue.add(function (callback) { | ||
}).then(function () { | ||
if (cache) { | ||
cache[dbName] = true; | ||
} | ||
callback(); | ||
@@ -65,5 +92,6 @@ }, callback); | ||
dbName = normalize(dbName); | ||
if (dbName === ALL_DBS_NAME) { | ||
if (canIgnore(dbName)) { | ||
return; | ||
} | ||
dbName = prefixed(dbName); | ||
init(); | ||
@@ -79,2 +107,5 @@ queue.add(function (callback) { | ||
}).then(function () { | ||
if (cache) { | ||
delete cache[dbName]; | ||
} | ||
callback(); | ||
@@ -88,5 +119,15 @@ }, callback); | ||
queue.add(function (callback) { | ||
pouch.allDocs().then(function (res) { | ||
var dbs = res.rows.map(function (row) { | ||
return row.key; | ||
if (cache) { | ||
return callback(null, Object.keys(cache).map(unprefixed)); | ||
} | ||
// older versions of this module didn't have prefixes, so check here | ||
var opts = {startkey: PREFIX, endkey: (PREFIX + '\uffff')}; | ||
pouch.allDocs(opts).then(function (res) { | ||
cache = {}; | ||
var dbs = []; | ||
res.rows.forEach(function (row) { | ||
dbs.push(unprefixed(row.key)); | ||
cache[row.key] = true; | ||
}); | ||
@@ -105,2 +146,3 @@ callback(null, dbs); | ||
pouch = null; | ||
cache = null; | ||
callback(); | ||
@@ -120,3 +162,3 @@ })["catch"](function (err) { | ||
},{"./pouch-utils":24,"./taskqueue":25}],2:[function(require,module,exports){ | ||
},{"./pouch-utils":25,"./taskqueue":26}],2:[function(require,module,exports){ | ||
'use strict'; | ||
@@ -236,9 +278,10 @@ | ||
var handlers = require('./handlers'); | ||
var noArray = reject(new TypeError('must be an array')); | ||
module.exports = function all(iterable) { | ||
module.exports = all; | ||
function all(iterable) { | ||
if (Object.prototype.toString.call(iterable) !== '[object Array]') { | ||
return noArray; | ||
return reject(new TypeError('must be an array')); | ||
} | ||
var len = iterable.length; | ||
var called = false; | ||
if (!len) { | ||
@@ -259,7 +302,11 @@ return resolve([]); | ||
resolve(value).then(resolveFromAll, function (error) { | ||
handlers.reject(promise, error); | ||
if (!called) { | ||
called = true; | ||
handlers.reject(promise, error); | ||
} | ||
}); | ||
function resolveFromAll(outValue) { | ||
values[i] = outValue; | ||
if (++resolved === len) { | ||
if (++resolved === len & !called) { | ||
called = true; | ||
handlers.resolve(promise, values); | ||
@@ -269,4 +316,4 @@ } | ||
} | ||
}; | ||
},{"./INTERNAL":6,"./handlers":8,"./promise":10,"./reject":12,"./resolve":13}],8:[function(require,module,exports){ | ||
} | ||
},{"./INTERNAL":6,"./handlers":8,"./promise":10,"./reject":13,"./resolve":14}],8:[function(require,module,exports){ | ||
'use strict'; | ||
@@ -317,3 +364,3 @@ var tryCatch = require('./tryCatch'); | ||
} | ||
},{"./resolveThenable":14,"./states":15,"./tryCatch":16}],9:[function(require,module,exports){ | ||
},{"./resolveThenable":15,"./states":16,"./tryCatch":17}],9:[function(require,module,exports){ | ||
module.exports = exports = require('./promise'); | ||
@@ -324,3 +371,4 @@ | ||
exports.all = require('./all'); | ||
},{"./all":7,"./promise":10,"./reject":12,"./resolve":13}],10:[function(require,module,exports){ | ||
exports.race = require('./race'); | ||
},{"./all":7,"./promise":10,"./race":12,"./reject":13,"./resolve":14}],10:[function(require,module,exports){ | ||
'use strict'; | ||
@@ -371,3 +419,3 @@ | ||
},{"./INTERNAL":6,"./queueItem":11,"./resolveThenable":14,"./states":15,"./unwrap":17}],11:[function(require,module,exports){ | ||
},{"./INTERNAL":6,"./queueItem":11,"./resolveThenable":15,"./states":16,"./unwrap":18}],11:[function(require,module,exports){ | ||
'use strict'; | ||
@@ -401,5 +449,46 @@ var handlers = require('./handlers'); | ||
}; | ||
},{"./handlers":8,"./unwrap":17}],12:[function(require,module,exports){ | ||
},{"./handlers":8,"./unwrap":18}],12:[function(require,module,exports){ | ||
'use strict'; | ||
var Promise = require('./promise'); | ||
var reject = require('./reject'); | ||
var resolve = require('./resolve'); | ||
var INTERNAL = require('./INTERNAL'); | ||
var handlers = require('./handlers'); | ||
module.exports = race; | ||
function race(iterable) { | ||
if (Object.prototype.toString.call(iterable) !== '[object Array]') { | ||
return reject(new TypeError('must be an array')); | ||
} | ||
var len = iterable.length; | ||
var called = false; | ||
if (!len) { | ||
return resolve([]); | ||
} | ||
var resolved = 0; | ||
var i = -1; | ||
var promise = new Promise(INTERNAL); | ||
while (++i < len) { | ||
resolver(iterable[i]); | ||
} | ||
return promise; | ||
function resolver(value) { | ||
resolve(value).then(function (response) { | ||
if (!called) { | ||
called = true; | ||
handlers.resolve(promise, response); | ||
} | ||
}, function (error) { | ||
if (!called) { | ||
called = true; | ||
handlers.reject(promise, error); | ||
} | ||
}); | ||
} | ||
} | ||
},{"./INTERNAL":6,"./handlers":8,"./promise":10,"./reject":13,"./resolve":14}],13:[function(require,module,exports){ | ||
'use strict'; | ||
var Promise = require('./promise'); | ||
@@ -414,3 +503,3 @@ var INTERNAL = require('./INTERNAL'); | ||
} | ||
},{"./INTERNAL":6,"./handlers":8,"./promise":10}],13:[function(require,module,exports){ | ||
},{"./INTERNAL":6,"./handlers":8,"./promise":10}],14:[function(require,module,exports){ | ||
'use strict'; | ||
@@ -450,3 +539,3 @@ | ||
} | ||
},{"./INTERNAL":6,"./handlers":8,"./promise":10}],14:[function(require,module,exports){ | ||
},{"./INTERNAL":6,"./handlers":8,"./promise":10}],15:[function(require,module,exports){ | ||
'use strict'; | ||
@@ -484,3 +573,3 @@ var handlers = require('./handlers'); | ||
exports.safely = safelyResolveThenable; | ||
},{"./handlers":8,"./tryCatch":16}],15:[function(require,module,exports){ | ||
},{"./handlers":8,"./tryCatch":17}],16:[function(require,module,exports){ | ||
// Lazy man's symbols for states | ||
@@ -491,3 +580,3 @@ | ||
exports.PENDING = ['PENDING']; | ||
},{}],16:[function(require,module,exports){ | ||
},{}],17:[function(require,module,exports){ | ||
'use strict'; | ||
@@ -508,3 +597,3 @@ | ||
} | ||
},{}],17:[function(require,module,exports){ | ||
},{}],18:[function(require,module,exports){ | ||
'use strict'; | ||
@@ -531,3 +620,3 @@ | ||
} | ||
},{"./handlers":8,"immediate":18}],18:[function(require,module,exports){ | ||
},{"./handlers":8,"immediate":19}],19:[function(require,module,exports){ | ||
'use strict'; | ||
@@ -543,3 +632,4 @@ var types = [ | ||
var queue = []; | ||
function drainQueue() { | ||
//named nextTick for less confusing stack traces | ||
function nextTick() { | ||
draining = true; | ||
@@ -564,3 +654,3 @@ var i, oldQueue; | ||
if (types[i] && types[i].test && types[i].test()) { | ||
scheduleDrain = types[i].install(drainQueue); | ||
scheduleDrain = types[i].install(nextTick); | ||
break; | ||
@@ -575,3 +665,3 @@ } | ||
} | ||
},{"./messageChannel":19,"./mutation.js":20,"./nextTick":3,"./stateChange":21,"./timeout":22}],19:[function(require,module,exports){ | ||
},{"./messageChannel":20,"./mutation.js":21,"./nextTick":3,"./stateChange":22,"./timeout":23}],20:[function(require,module,exports){ | ||
var global=typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};'use strict'; | ||
@@ -595,3 +685,3 @@ | ||
}; | ||
},{}],20:[function(require,module,exports){ | ||
},{}],21:[function(require,module,exports){ | ||
var global=typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};'use strict'; | ||
@@ -619,3 +709,3 @@ //based off rsvp https://github.com/tildeio/rsvp.js | ||
}; | ||
},{}],21:[function(require,module,exports){ | ||
},{}],22:[function(require,module,exports){ | ||
var global=typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};'use strict'; | ||
@@ -645,3 +735,3 @@ | ||
}; | ||
},{}],22:[function(require,module,exports){ | ||
},{}],23:[function(require,module,exports){ | ||
'use strict'; | ||
@@ -657,3 +747,3 @@ exports.test = function () { | ||
}; | ||
},{}],23:[function(require,module,exports){ | ||
},{}],24:[function(require,module,exports){ | ||
'use strict'; | ||
@@ -708,3 +798,3 @@ | ||
},{}],24:[function(require,module,exports){ | ||
},{}],25:[function(require,module,exports){ | ||
var process=require("__browserify_process"),global=typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};'use strict'; | ||
@@ -793,3 +883,3 @@ | ||
},{"__browserify_process":4,"inherits":5,"lie":9}],25:[function(require,module,exports){ | ||
},{"__browserify_process":4,"inherits":5,"lie":9}],26:[function(require,module,exports){ | ||
var process=require("__browserify_process"),global=typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};'use strict'; | ||
@@ -833,3 +923,3 @@ | ||
},{"__browserify_process":4,"argsarray":2,"tiny-queue":23}]},{},[1]) | ||
},{"__browserify_process":4,"argsarray":2,"tiny-queue":24}]},{},[1]) | ||
; |
@@ -1,1 +0,1 @@ | ||
!function e(t,n,r){function o(u,s){if(!n[u]){if(!t[u]){var c="function"==typeof require&&require;if(!s&&c)return c(u,!0);if(i)return i(u,!0);throw new Error("Cannot find module '"+u+"'")}var f=n[u]={exports:{}};t[u][0].call(f.exports,function(e){var n=t[u][1][e];return o(n?n:e)},f,f.exports,e,t,n,r)}return n[u].exports}for(var i="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({1:[function(e,t){"use strict";var n=e("./pouch-utils"),r=e("./taskqueue");t.exports=function(e){function t(e){e&&console.error(e)}function o(){c.add(function(t){return u?t():void new e(s).then(function(e){u=e,t()})["catch"](function(e){console.error(e),t(e)})})}function i(e){return e.replace(/^_pouch_/,"")}var u,s="pouch__all_dbs__",c=new r;e.on("created",function(e){e=i(e),e!==s&&(o(),c.add(function(t){u.get(e).then(function(){})["catch"](function(t){if("not_found"!==t.name)throw t;return u.put({_id:e})}).then(function(){t()},t)},t))}),e.on("destroyed",function(e){e=i(e),e!==s&&(o(),c.add(function(t){u.get(e).then(function(e){return u.remove(e)})["catch"](function(e){if("not_found"!==e.name)throw e}).then(function(){t()},t)},t))}),e.allDbs=n.toPromise(function(e){o(),c.add(function(e){u.allDocs().then(function(t){var n=t.rows.map(function(e){return e.key});e(null,n)})["catch"](function(t){console.error(t),e(t)})},e)}),e.resetAllDbs=n.toPromise(function(e){c.add(function(e){u.destroy().then(function(){u=null,e()})["catch"](function(t){console.error(t),e(t)})},e)})},"undefined"!=typeof window&&window.PouchDB&&t.exports(window.PouchDB)},{"./pouch-utils":24,"./taskqueue":25}],2:[function(e,t){"use strict";function n(e){return function(){var t=arguments.length;if(t){for(var n=[],r=-1;++r<t;)n[r]=arguments[r];return e.call(this,n)}return e.call(this,[])}}t.exports=n},{}],3:[function(){},{}],4:[function(e,t){var n=t.exports={};n.nextTick=function(){var e="undefined"!=typeof window&&window.setImmediate,t="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(e)return function(e){return window.setImmediate(e)};if(t){var n=[];return window.addEventListener("message",function(e){var t=e.source;if((t===window||null===t)&&"process-tick"===e.data&&(e.stopPropagation(),n.length>0)){var r=n.shift();r()}},!0),function(e){n.push(e),window.postMessage("process-tick","*")}}return function(e){setTimeout(e,0)}}(),n.title="browser",n.browser=!0,n.env={},n.argv=[],n.binding=function(){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(){throw new Error("process.chdir is not supported")}},{}],5:[function(e,t){t.exports="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],6:[function(e,t){"use strict";function n(){}t.exports=n},{}],7:[function(e,t){"use strict";var n=e("./promise"),r=e("./reject"),o=e("./resolve"),i=e("./INTERNAL"),u=e("./handlers"),s=r(new TypeError("must be an array"));t.exports=function(e){function t(e,t){function n(e){c[t]=e,++f===r&&u.resolve(l,c)}o(e).then(n,function(e){u.reject(l,e)})}if("[object Array]"!==Object.prototype.toString.call(e))return s;var r=e.length;if(!r)return o([]);for(var c=new Array(r),f=0,a=-1,l=new n(i);++a<r;)t(e[a],a);return l}},{"./INTERNAL":6,"./handlers":8,"./promise":10,"./reject":12,"./resolve":13}],8:[function(e,t,n){"use strict";function r(e){var t=e&&e.then;return e&&"object"==typeof e&&"function"==typeof t?function(){t.apply(e,arguments)}:void 0}var o=e("./tryCatch"),i=e("./resolveThenable"),u=e("./states");n.resolve=function(e,t){var s=o(r,t);if("error"===s.status)return n.reject(e,s.value);var c=s.value;if(c)i.safely(e,c);else{e.state=u.FULFILLED,e.outcome=t;for(var f=-1,a=e.queue.length;++f<a;)e.queue[f].callFulfilled(t)}return e},n.reject=function(e,t){e.state=u.REJECTED,e.outcome=t;for(var n=-1,r=e.queue.length;++n<r;)e.queue[n].callRejected(t);return e}},{"./resolveThenable":14,"./states":15,"./tryCatch":16}],9:[function(e,t,n){t.exports=n=e("./promise"),n.resolve=e("./resolve"),n.reject=e("./reject"),n.all=e("./all")},{"./all":7,"./promise":10,"./reject":12,"./resolve":13}],10:[function(e,t){"use strict";function n(e){if(!(this instanceof n))return new n(e);if("function"!=typeof e)throw new TypeError("reslover must be a function");this.state=u.PENDING,this.queue=[],this.outcome=void 0,e!==o&&i.safely(this,e)}var r=e("./unwrap"),o=e("./INTERNAL"),i=e("./resolveThenable"),u=e("./states"),s=e("./queueItem");t.exports=n,n.prototype["catch"]=function(e){return this.then(null,e)},n.prototype.then=function(e,t){if("function"!=typeof e&&this.state===u.FULFILLED||"function"!=typeof t&&this.state===u.REJECTED)return this;var i=new n(o);if(this.state!==u.PENDING){var c=this.state===u.FULFILLED?e:t;r(i,c,this.outcome)}else this.queue.push(new s(i,e,t));return i}},{"./INTERNAL":6,"./queueItem":11,"./resolveThenable":14,"./states":15,"./unwrap":17}],11:[function(e,t){"use strict";function n(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}var r=e("./handlers"),o=e("./unwrap");t.exports=n,n.prototype.callFulfilled=function(e){r.resolve(this.promise,e)},n.prototype.otherCallFulfilled=function(e){o(this.promise,this.onFulfilled,e)},n.prototype.callRejected=function(e){r.reject(this.promise,e)},n.prototype.otherCallRejected=function(e){o(this.promise,this.onRejected,e)}},{"./handlers":8,"./unwrap":17}],12:[function(e,t){"use strict";function n(e){var t=new r(o);return i.reject(t,e)}var r=e("./promise"),o=e("./INTERNAL"),i=e("./handlers");t.exports=n},{"./INTERNAL":6,"./handlers":8,"./promise":10}],13:[function(e,t){"use strict";function n(e){if(e)return e instanceof r?e:i.resolve(new r(o),e);var t=typeof e;switch(t){case"boolean":return u;case"undefined":return c;case"object":return s;case"number":return f;case"string":return a}}var r=e("./promise"),o=e("./INTERNAL"),i=e("./handlers");t.exports=n;var u=i.resolve(new r(o),!1),s=i.resolve(new r(o),null),c=i.resolve(new r(o),void 0),f=i.resolve(new r(o),0),a=i.resolve(new r(o),"")},{"./INTERNAL":6,"./handlers":8,"./promise":10}],14:[function(e,t,n){"use strict";function r(e,t){function n(t){s||(s=!0,o.reject(e,t))}function r(t){s||(s=!0,o.resolve(e,t))}function u(){t(r,n)}var s=!1,c=i(u);"error"===c.status&&n(c.value)}var o=e("./handlers"),i=e("./tryCatch");n.safely=r},{"./handlers":8,"./tryCatch":16}],15:[function(e,t,n){n.REJECTED=["REJECTED"],n.FULFILLED=["FULFILLED"],n.PENDING=["PENDING"]},{}],16:[function(e,t){"use strict";function n(e,t){var n={};try{n.value=e(t),n.status="success"}catch(r){n.status="error",n.value=r}return n}t.exports=n},{}],17:[function(e,t){"use strict";function n(e,t,n){r(function(){var r;try{r=t(n)}catch(i){return o.reject(e,i)}r===e?o.reject(e,new TypeError("Cannot resolve promise with itself")):o.resolve(e,r)})}var r=e("immediate"),o=e("./handlers");t.exports=n},{"./handlers":8,immediate:18}],18:[function(e,t){"use strict";function n(){o=!0;for(var e,t,n=s.length;n;){for(t=s,s=[],e=-1;++e<n;)t[e]();n=s.length}o=!1}function r(e){1!==s.push(e)||o||i()}for(var o,i,u=[e("./nextTick"),e("./mutation.js"),e("./messageChannel"),e("./stateChange"),e("./timeout")],s=[],c=-1,f=u.length;++c<f;)if(u[c]&&u[c].test&&u[c].test()){i=u[c].install(n);break}t.exports=r},{"./messageChannel":19,"./mutation.js":20,"./nextTick":3,"./stateChange":21,"./timeout":22}],19:[function(e,t,n){var r="undefined"!=typeof self?self:"undefined"!=typeof window?window:{};n.test=function(){return r.setImmediate?!1:"undefined"!=typeof r.MessageChannel},n.install=function(e){var t=new r.MessageChannel;return t.port1.onmessage=e,function(){t.port2.postMessage(0)}}},{}],20:[function(e,t,n){var r="undefined"!=typeof self?self:"undefined"!=typeof window?window:{},o=r.MutationObserver||r.WebKitMutationObserver;n.test=function(){return o},n.install=function(e){var t=0,n=new o(e),i=r.document.createTextNode("");return n.observe(i,{characterData:!0}),function(){i.data=t=++t%2}}},{}],21:[function(e,t,n){var r="undefined"!=typeof self?self:"undefined"!=typeof window?window:{};n.test=function(){return"document"in r&&"onreadystatechange"in r.document.createElement("script")},n.install=function(e){return function(){var t=r.document.createElement("script");return t.onreadystatechange=function(){e(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},r.document.documentElement.appendChild(t),e}}},{}],22:[function(e,t,n){"use strict";n.test=function(){return!0},n.install=function(e){return function(){setTimeout(e,0)}}},{}],23:[function(e,t){"use strict";function n(){this.length=0}n.prototype.push=function(e){var t={item:e};this.last=this.last?this.last.next=t:this.first=t,this.length++},n.prototype.shift=function(){var e=this.first;return e?(this.first=e.next,--this.length||(this.last=void 0),e.item):void 0},n.prototype.slice=function(e,t){e="undefined"==typeof e?0:e,t="undefined"==typeof t?1/0:t;for(var n=[],r=0,o=this.first;o&&!(--t<0);o=o.next)++r>e&&n.push(o.item);return n},t.exports=n},{}],24:[function(e,t,n){var r,o=e("__browserify_process"),i="undefined"!=typeof self?self:"undefined"!=typeof window?window:{};r="undefined"!=typeof window&&window.PouchDB?window.PouchDB.utils.Promise:"function"==typeof i.Promise?i.Promise:e("lie"),n.once=function(e){var t=!1;return n.getArguments(function(n){if(t)throw console.trace(),new Error("once called more than once");t=!0,e.apply(this,n)})},n.getArguments=function(e){return function(){for(var t=arguments.length,n=new Array(t),r=-1;++r<t;)n[r]=arguments[r];return e.call(this,n)}},n.toPromise=function(e){return n.getArguments(function(t){var i,u=this,s="function"==typeof t[t.length-1]?t.pop():!1;s&&(i=function(e,t){o.nextTick(function(){s(e,t)})});var c=new r(function(r,o){try{var i=n.once(function(e,t){e?o(e):r(t)});t.push(i),e.apply(u,t)}catch(s){o(s)}});return i&&c.then(function(e){i(null,e)},i),c.cancel=function(){return this},c})},n.inherits=e("inherits")},{__browserify_process:4,inherits:5,lie:9}],25:[function(e,t){function n(){this.queue=new u,this.running=!1}var r=e("__browserify_process"),o="undefined"!=typeof self?self:"undefined"!=typeof window?window:{},i=e("argsarray"),u=e("tiny-queue"),s=o.setImmediate||r.nextTick;n.prototype.add=function(e,t){t=t||function(){},this.queue.push({fun:e,callback:t}),this.processNext()},n.prototype.processNext=function(){var e=this;if(!e.running&&e.queue.length){e.running=!0;var t=e.queue.shift();s(function(){t.fun(i(function(n){t.callback.apply(null,n),e.running=!1,e.processNext()}))})}},t.exports=n},{__browserify_process:4,argsarray:2,"tiny-queue":23}]},{},[1]); | ||
!function e(t,n,r){function o(u,s){if(!n[u]){if(!t[u]){var c="function"==typeof require&&require;if(!s&&c)return c(u,!0);if(i)return i(u,!0);throw new Error("Cannot find module '"+u+"'")}var f=n[u]={exports:{}};t[u][0].call(f.exports,function(e){var n=t[u][1][e];return o(n?n:e)},f,f.exports,e,t,n,r)}return n[u].exports}for(var i="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({1:[function(e,t){"use strict";function n(e){return u+e}function r(e){return e.slice(u.length)}var o=e("./pouch-utils"),i=e("./taskqueue"),u="db_";t.exports=function(e){function t(e){e&&console.error(e)}function s(){h.add(function(t){return a?t():void new e(p).then(function(e){a=e,t()})["catch"](function(e){console.error(e),t(e)})})}function c(e){return e.replace(/^_pouch_/,"")}function f(e){return e===p||-1!==e.indexOf("-mrview-")||/^https?:\/\//.test(e)}var a,l,p="pouch__all_dbs__",h=new i;e.on("created",function(e){e=c(e),f(e)||(e=n(e),s(),h.add(function(t){a.get(e).then(function(){})["catch"](function(t){if("not_found"!==t.name)throw t;return a.put({_id:e})}).then(function(){l&&(l[e]=!0),t()},t)},t))}),e.on("destroyed",function(e){e=c(e),f(e)||(e=n(e),s(),h.add(function(t){a.get(e).then(function(e){return a.remove(e)})["catch"](function(e){if("not_found"!==e.name)throw e}).then(function(){l&&delete l[e],t()},t)},t))}),e.allDbs=o.toPromise(function(e){s(),h.add(function(e){if(l)return e(null,Object.keys(l).map(r));var t={startkey:u,endkey:u+""};a.allDocs(t).then(function(t){l={};var n=[];t.rows.forEach(function(e){n.push(r(e.key)),l[e.key]=!0}),e(null,n)})["catch"](function(t){console.error(t),e(t)})},e)}),e.resetAllDbs=o.toPromise(function(e){h.add(function(e){a.destroy().then(function(){a=null,l=null,e()})["catch"](function(t){console.error(t),e(t)})},e)})},"undefined"!=typeof window&&window.PouchDB&&t.exports(window.PouchDB)},{"./pouch-utils":25,"./taskqueue":26}],2:[function(e,t){"use strict";function n(e){return function(){var t=arguments.length;if(t){for(var n=[],r=-1;++r<t;)n[r]=arguments[r];return e.call(this,n)}return e.call(this,[])}}t.exports=n},{}],3:[function(){},{}],4:[function(e,t){var n=t.exports={};n.nextTick=function(){var e="undefined"!=typeof window&&window.setImmediate,t="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(e)return function(e){return window.setImmediate(e)};if(t){var n=[];return window.addEventListener("message",function(e){var t=e.source;if((t===window||null===t)&&"process-tick"===e.data&&(e.stopPropagation(),n.length>0)){var r=n.shift();r()}},!0),function(e){n.push(e),window.postMessage("process-tick","*")}}return function(e){setTimeout(e,0)}}(),n.title="browser",n.browser=!0,n.env={},n.argv=[],n.binding=function(){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(){throw new Error("process.chdir is not supported")}},{}],5:[function(e,t){t.exports="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],6:[function(e,t){"use strict";function n(){}t.exports=n},{}],7:[function(e,t){"use strict";function n(e){function t(e,t){function r(e){f[t]=e,++a===n&!c&&(c=!0,s.resolve(p,f))}i(e).then(r,function(e){c||(c=!0,s.reject(p,e))})}if("[object Array]"!==Object.prototype.toString.call(e))return o(new TypeError("must be an array"));var n=e.length,c=!1;if(!n)return i([]);for(var f=new Array(n),a=0,l=-1,p=new r(u);++l<n;)t(e[l],l);return p}var r=e("./promise"),o=e("./reject"),i=e("./resolve"),u=e("./INTERNAL"),s=e("./handlers");t.exports=n},{"./INTERNAL":6,"./handlers":8,"./promise":10,"./reject":13,"./resolve":14}],8:[function(e,t,n){"use strict";function r(e){var t=e&&e.then;return e&&"object"==typeof e&&"function"==typeof t?function(){t.apply(e,arguments)}:void 0}var o=e("./tryCatch"),i=e("./resolveThenable"),u=e("./states");n.resolve=function(e,t){var s=o(r,t);if("error"===s.status)return n.reject(e,s.value);var c=s.value;if(c)i.safely(e,c);else{e.state=u.FULFILLED,e.outcome=t;for(var f=-1,a=e.queue.length;++f<a;)e.queue[f].callFulfilled(t)}return e},n.reject=function(e,t){e.state=u.REJECTED,e.outcome=t;for(var n=-1,r=e.queue.length;++n<r;)e.queue[n].callRejected(t);return e}},{"./resolveThenable":15,"./states":16,"./tryCatch":17}],9:[function(e,t,n){t.exports=n=e("./promise"),n.resolve=e("./resolve"),n.reject=e("./reject"),n.all=e("./all"),n.race=e("./race")},{"./all":7,"./promise":10,"./race":12,"./reject":13,"./resolve":14}],10:[function(e,t){"use strict";function n(e){if(!(this instanceof n))return new n(e);if("function"!=typeof e)throw new TypeError("reslover must be a function");this.state=u.PENDING,this.queue=[],this.outcome=void 0,e!==o&&i.safely(this,e)}var r=e("./unwrap"),o=e("./INTERNAL"),i=e("./resolveThenable"),u=e("./states"),s=e("./queueItem");t.exports=n,n.prototype["catch"]=function(e){return this.then(null,e)},n.prototype.then=function(e,t){if("function"!=typeof e&&this.state===u.FULFILLED||"function"!=typeof t&&this.state===u.REJECTED)return this;var i=new n(o);if(this.state!==u.PENDING){var c=this.state===u.FULFILLED?e:t;r(i,c,this.outcome)}else this.queue.push(new s(i,e,t));return i}},{"./INTERNAL":6,"./queueItem":11,"./resolveThenable":15,"./states":16,"./unwrap":18}],11:[function(e,t){"use strict";function n(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}var r=e("./handlers"),o=e("./unwrap");t.exports=n,n.prototype.callFulfilled=function(e){r.resolve(this.promise,e)},n.prototype.otherCallFulfilled=function(e){o(this.promise,this.onFulfilled,e)},n.prototype.callRejected=function(e){r.reject(this.promise,e)},n.prototype.otherCallRejected=function(e){o(this.promise,this.onRejected,e)}},{"./handlers":8,"./unwrap":18}],12:[function(e,t){"use strict";function n(e){function t(e){i(e).then(function(e){c||(c=!0,s.resolve(a,e))},function(e){c||(c=!0,s.reject(a,e))})}if("[object Array]"!==Object.prototype.toString.call(e))return o(new TypeError("must be an array"));var n=e.length,c=!1;if(!n)return i([]);for(var f=-1,a=new r(u);++f<n;)t(e[f]);return a}var r=e("./promise"),o=e("./reject"),i=e("./resolve"),u=e("./INTERNAL"),s=e("./handlers");t.exports=n},{"./INTERNAL":6,"./handlers":8,"./promise":10,"./reject":13,"./resolve":14}],13:[function(e,t){"use strict";function n(e){var t=new r(o);return i.reject(t,e)}var r=e("./promise"),o=e("./INTERNAL"),i=e("./handlers");t.exports=n},{"./INTERNAL":6,"./handlers":8,"./promise":10}],14:[function(e,t){"use strict";function n(e){if(e)return e instanceof r?e:i.resolve(new r(o),e);var t=typeof e;switch(t){case"boolean":return u;case"undefined":return c;case"object":return s;case"number":return f;case"string":return a}}var r=e("./promise"),o=e("./INTERNAL"),i=e("./handlers");t.exports=n;var u=i.resolve(new r(o),!1),s=i.resolve(new r(o),null),c=i.resolve(new r(o),void 0),f=i.resolve(new r(o),0),a=i.resolve(new r(o),"")},{"./INTERNAL":6,"./handlers":8,"./promise":10}],15:[function(e,t,n){"use strict";function r(e,t){function n(t){s||(s=!0,o.reject(e,t))}function r(t){s||(s=!0,o.resolve(e,t))}function u(){t(r,n)}var s=!1,c=i(u);"error"===c.status&&n(c.value)}var o=e("./handlers"),i=e("./tryCatch");n.safely=r},{"./handlers":8,"./tryCatch":17}],16:[function(e,t,n){n.REJECTED=["REJECTED"],n.FULFILLED=["FULFILLED"],n.PENDING=["PENDING"]},{}],17:[function(e,t){"use strict";function n(e,t){var n={};try{n.value=e(t),n.status="success"}catch(r){n.status="error",n.value=r}return n}t.exports=n},{}],18:[function(e,t){"use strict";function n(e,t,n){r(function(){var r;try{r=t(n)}catch(i){return o.reject(e,i)}r===e?o.reject(e,new TypeError("Cannot resolve promise with itself")):o.resolve(e,r)})}var r=e("immediate"),o=e("./handlers");t.exports=n},{"./handlers":8,immediate:19}],19:[function(e,t){"use strict";function n(){o=!0;for(var e,t,n=s.length;n;){for(t=s,s=[],e=-1;++e<n;)t[e]();n=s.length}o=!1}function r(e){1!==s.push(e)||o||i()}for(var o,i,u=[e("./nextTick"),e("./mutation.js"),e("./messageChannel"),e("./stateChange"),e("./timeout")],s=[],c=-1,f=u.length;++c<f;)if(u[c]&&u[c].test&&u[c].test()){i=u[c].install(n);break}t.exports=r},{"./messageChannel":20,"./mutation.js":21,"./nextTick":3,"./stateChange":22,"./timeout":23}],20:[function(e,t,n){var r="undefined"!=typeof self?self:"undefined"!=typeof window?window:{};n.test=function(){return r.setImmediate?!1:"undefined"!=typeof r.MessageChannel},n.install=function(e){var t=new r.MessageChannel;return t.port1.onmessage=e,function(){t.port2.postMessage(0)}}},{}],21:[function(e,t,n){var r="undefined"!=typeof self?self:"undefined"!=typeof window?window:{},o=r.MutationObserver||r.WebKitMutationObserver;n.test=function(){return o},n.install=function(e){var t=0,n=new o(e),i=r.document.createTextNode("");return n.observe(i,{characterData:!0}),function(){i.data=t=++t%2}}},{}],22:[function(e,t,n){var r="undefined"!=typeof self?self:"undefined"!=typeof window?window:{};n.test=function(){return"document"in r&&"onreadystatechange"in r.document.createElement("script")},n.install=function(e){return function(){var t=r.document.createElement("script");return t.onreadystatechange=function(){e(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},r.document.documentElement.appendChild(t),e}}},{}],23:[function(e,t,n){"use strict";n.test=function(){return!0},n.install=function(e){return function(){setTimeout(e,0)}}},{}],24:[function(e,t){"use strict";function n(){this.length=0}n.prototype.push=function(e){var t={item:e};this.last=this.last?this.last.next=t:this.first=t,this.length++},n.prototype.shift=function(){var e=this.first;return e?(this.first=e.next,--this.length||(this.last=void 0),e.item):void 0},n.prototype.slice=function(e,t){e="undefined"==typeof e?0:e,t="undefined"==typeof t?1/0:t;for(var n=[],r=0,o=this.first;o&&!(--t<0);o=o.next)++r>e&&n.push(o.item);return n},t.exports=n},{}],25:[function(e,t,n){var r,o=e("__browserify_process"),i="undefined"!=typeof self?self:"undefined"!=typeof window?window:{};r="undefined"!=typeof window&&window.PouchDB?window.PouchDB.utils.Promise:"function"==typeof i.Promise?i.Promise:e("lie"),n.once=function(e){var t=!1;return n.getArguments(function(n){if(t)throw console.trace(),new Error("once called more than once");t=!0,e.apply(this,n)})},n.getArguments=function(e){return function(){for(var t=arguments.length,n=new Array(t),r=-1;++r<t;)n[r]=arguments[r];return e.call(this,n)}},n.toPromise=function(e){return n.getArguments(function(t){var i,u=this,s="function"==typeof t[t.length-1]?t.pop():!1;s&&(i=function(e,t){o.nextTick(function(){s(e,t)})});var c=new r(function(r,o){try{var i=n.once(function(e,t){e?o(e):r(t)});t.push(i),e.apply(u,t)}catch(s){o(s)}});return i&&c.then(function(e){i(null,e)},i),c.cancel=function(){return this},c})},n.inherits=e("inherits")},{__browserify_process:4,inherits:5,lie:9}],26:[function(e,t){function n(){this.queue=new u,this.running=!1}var r=e("__browserify_process"),o="undefined"!=typeof self?self:"undefined"!=typeof window?window:{},i=e("argsarray"),u=e("tiny-queue"),s=o.setImmediate||r.nextTick;n.prototype.add=function(e,t){t=t||function(){},this.queue.push({fun:e,callback:t}),this.processNext()},n.prototype.processNext=function(){var e=this;if(!e.running&&e.queue.length){e.running=!0;var t=e.queue.shift();s(function(){t.fun(i(function(n){t.callback.apply(null,n),e.running=!1,e.processNext()}))})}},t.exports=n},{__browserify_process:4,argsarray:2,"tiny-queue":24}]},{},[1]); |
{ | ||
"name": "pouchdb-all-dbs", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "PouchDB allDbs plugin", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -6,6 +6,6 @@ PouchDB allDbs() plugin | ||
`allDbs()` was deprecated in PouchDB 2.0.0, but that doesn't mean it can't live on as a plugin! | ||
This plugin exposes the `PouchDB.allDbs()` function, which you can use to list all local databases. It works by listening for `PouchDB.on('created')` and `PouchDB.on('destroyed')` events, and maintaining a separate database to store the names of those databases. | ||
*Note*: `allDbs()` used to be part of PouchDB core, enabled using `PouchDB.enableAllDbs = true`. It was deprecated in PouchDB 2.0.0, and now lives on as a plugin. | ||
Usage | ||
@@ -12,0 +12,0 @@ ----- |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
21
3
68786
18
1704