idb-kv-store
Advanced tools
Comparing version 2.2.1 to 2.2.2
@@ -1,1 +0,1 @@ | ||
(function(e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define([],e)}else{var r;if(typeof window!=="undefined"){r=window}else if(typeof global!=="undefined"){r=global}else if(typeof self!=="undefined"){r=self}else{r=this}r.IdbKvStore=e()}})(function(){var e,r,n;return function e(r,n,t){function o(i,c){if(!n[i]){if(!r[i]){var s=typeof require=="function"&&require;if(!c&&s)return s(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var f=n[i]={exports:{}};r[i][0].call(f.exports,function(e){var n=r[i][1][e];return o(n?n:e)},f,f.exports,e,r,n,t)}return n[i].exports}var u=typeof require=="function"&&require;for(var i=0;i<t.length;i++)o(t[i]);return o}({"/":[function(e,r,n){r.exports=o;var t=window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB;function o(e,r){var n=this;if(typeof e!=="string")throw new Error("A name must be supplied of type string");if(!(this instanceof o))return new o(e,r);if(!r)r={};n._db=null;n._queue=[];var u=t.open(e);u.onerror=function(e){i(e,r.onerror)};u.onsuccess=function(e){n._db=e.target.result;n._drainQueue();if(r.onready)r.onready()};u.onupgradeneeded=function(e){var r=e.target.result;r.createObjectStore("kv")}}o.prototype.get=function(e,r){var n=this;var t=u(r);if(!n._db){n._queue.push({type:"get",key:e,cb:t.cb})}else if(Array.isArray(e)){var o=[];var c=false;var s=0;e.forEach(function(r,u){n.get(e[u],function(r,n){if(c)return;if(r){c=true;t.cb(r)}o[u]=n;s++;if(s===e.length)t.cb(null,o)})})}else{var a=n._db.transaction("kv","readonly");var f=a.objectStore("kv").get(e);f.onsuccess=function(e){t.cb(null,e.target.result)};a.onerror=function(e){i(e,t.cb)}}return t.promise};o.prototype.set=function(e,r,n){var t=this;var o=u(n);if(!t._db){t._queue.push({type:"set",key:e,value:r,cb:o.cb})}else{var c=t._db.transaction("kv","readwrite");var s=c.objectStore("kv").put(r,e);s.onsuccess=function(){o.cb(null)};c.onerror=function(e){i(e,o.cb)}}return o.promise};o.prototype.json=function(e){var r=this;var n=u(e);if(!r._db){r._queue.push({type:"json",cb:n.cb})}else{var t=r._db.transaction("kv","readonly");var o=t.objectStore("kv").openCursor();var c={};o.onsuccess=function(e){var r=e.target.result;if(r){c[r.key]=r.value;r.continue()}else{n.cb(null,c)}};t.onerror=function(e){i(e,n.cb)}}return n.promise};o.prototype.keys=function(e){var r=this;var n=u(e);if(!r._db){r._queue.push({type:"keys",cb:n.cb})}else{var t=r._db.transaction("kv","readonly");var o=t.objectStore("kv").openCursor();var c=[];o.onsuccess=function(e){var r=e.target.result;if(r){c.push(r.key);r.continue()}else{n.cb(null,c)}};t.onerror=function(e){i(e,n.cb)}}return n.promise};o.prototype.remove=function(e,r){var n=this;var t=u(r);if(!n._db){n._queue.push({type:"remove",key:e,cb:t.cb})}else{var o=n._db.transaction("kv","readwrite");var c=o.objectStore("kv").delete(e);c.onsuccess=function(e){t.cb(null)};o.onerror=function(e){i(e,t.cb)}}return t.promise};o.prototype.clear=function(e){var r=this;var n=u(e);if(!r._db){r._queue.push({type:"clear",cb:n.cb})}else{var t=r._db.transaction("kv","readwrite");var o=t.objectStore("kv").clear();o.onsuccess=function(e){n.cb(null)};t.onerror=function(e){i(e,n.cb)}}return n.promise};o.prototype.count=function(e){var r=this;var n=u(e);if(!r._db){r._queue.push({type:"count",cb:n.cb})}else{var t=r._db.transaction("kv","readonly");var o=t.objectStore("kv").count();o.onsuccess=function(e){n.cb(null,e.target.result)};t.onerror=function(e){i(e,n.cb)}}return n.promise};o.prototype.add=function(e,r,n){var t=this;var o=u(n);if(!t._db){t._queue.push({type:"add",key:e,value:r,cb:o.cb})}else{var c=t._db.transaction("kv","readwrite");var s=c.objectStore("kv").add(r,e);s.onsuccess=function(e){o.cb(null)};c.onerror=function(e){i(e,o.cb)}}return o.promise};o.prototype._drainQueue=function(){var e=this;for(var r=0;r<e._queue.length;r++){var n=e._queue[r];if(n.type==="get"){e.get(n.key,n.cb)}else if(n.type==="set"){e.set(n.key,n.value,n.cb)}else if(n.type==="json"){e.json(n.cb)}else if(n.type==="keys"){e.keys(n.cb)}else if(n.type==="remove"){e.remove(n.key,n.cb)}else if(n.type==="clear"){e.clear(n.cb)}else if(n.type==="count"){e.count(n.cb)}else if(n.type==="add"){e.add(n.key,n.value,n.cb)}}e._queue=null};function u(e){var r={cb:e};if(typeof Promise==="function"&&e==null){r.promise=new Promise(function(e,n){r.cb=function(r,t){if(r)return n(r);else return e(t)}})}if(!r.cb)r.cb=function e(){};return r}function i(e,r){var n=new Error("IDB error");n.event=e;if(r){r(n)}else{throw n}}},{}]},{},[])("/")}); | ||
(function(e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define([],e)}else{var r;if(typeof window!=="undefined"){r=window}else if(typeof global!=="undefined"){r=global}else if(typeof self!=="undefined"){r=self}else{r=this}r.IdbKvStore=e()}})(function(){var e,r,n;return function e(r,n,t){function o(i,c){if(!n[i]){if(!r[i]){var s=typeof require=="function"&&require;if(!c&&s)return s(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var f=n[i]={exports:{}};r[i][0].call(f.exports,function(e){var n=r[i][1][e];return o(n?n:e)},f,f.exports,e,r,n,t)}return n[i].exports}var u=typeof require=="function"&&require;for(var i=0;i<t.length;i++)o(t[i]);return o}({"/":[function(e,r,n){r.exports=u;var t=typeof window==="undefined"?self:window;var o=t.indexedDB||t.mozIndexedDB||t.webkitIndexedDB||t.msIndexedDB;function u(e,r){var n=this;if(typeof e!=="string")throw new Error("A name must be supplied of type string");if(!(this instanceof u))return new u(e,r);if(!r)r={};n._db=null;n._queue=[];var t=o.open(e);t.onerror=function(e){c(e,r.onerror)};t.onsuccess=function(e){n._db=e.target.result;n._drainQueue();if(r.onready)r.onready()};t.onupgradeneeded=function(e){var r=e.target.result;r.createObjectStore("kv")}}u.prototype.get=function(e,r){var n=this;var t=i(r);if(!n._db){n._queue.push({type:"get",key:e,cb:t.cb})}else if(Array.isArray(e)){var o=[];var u=false;var s=0;e.forEach(function(r,i){n.get(e[i],function(r,n){if(u)return;if(r){u=true;t.cb(r)}o[i]=n;s++;if(s===e.length)t.cb(null,o)})})}else{var a=n._db.transaction("kv","readonly");var f=a.objectStore("kv").get(e);f.onsuccess=function(e){t.cb(null,e.target.result)};a.onerror=function(e){c(e,t.cb)}}return t.promise};u.prototype.set=function(e,r,n){var t=this;var o=i(n);if(!t._db){t._queue.push({type:"set",key:e,value:r,cb:o.cb})}else{var u=t._db.transaction("kv","readwrite");var s=u.objectStore("kv").put(r,e);s.onsuccess=function(){o.cb(null)};u.onerror=function(e){c(e,o.cb)}}return o.promise};u.prototype.json=function(e){var r=this;var n=i(e);if(!r._db){r._queue.push({type:"json",cb:n.cb})}else{var t=r._db.transaction("kv","readonly");var o=t.objectStore("kv").openCursor();var u={};o.onsuccess=function(e){var r=e.target.result;if(r){u[r.key]=r.value;r.continue()}else{n.cb(null,u)}};t.onerror=function(e){c(e,n.cb)}}return n.promise};u.prototype.keys=function(e){var r=this;var n=i(e);if(!r._db){r._queue.push({type:"keys",cb:n.cb})}else{var t=r._db.transaction("kv","readonly");var o=t.objectStore("kv").openCursor();var u=[];o.onsuccess=function(e){var r=e.target.result;if(r){u.push(r.key);r.continue()}else{n.cb(null,u)}};t.onerror=function(e){c(e,n.cb)}}return n.promise};u.prototype.remove=function(e,r){var n=this;var t=i(r);if(!n._db){n._queue.push({type:"remove",key:e,cb:t.cb})}else{var o=n._db.transaction("kv","readwrite");var u=o.objectStore("kv").delete(e);u.onsuccess=function(e){t.cb(null)};o.onerror=function(e){c(e,t.cb)}}return t.promise};u.prototype.clear=function(e){var r=this;var n=i(e);if(!r._db){r._queue.push({type:"clear",cb:n.cb})}else{var t=r._db.transaction("kv","readwrite");var o=t.objectStore("kv").clear();o.onsuccess=function(e){n.cb(null)};t.onerror=function(e){c(e,n.cb)}}return n.promise};u.prototype.count=function(e){var r=this;var n=i(e);if(!r._db){r._queue.push({type:"count",cb:n.cb})}else{var t=r._db.transaction("kv","readonly");var o=t.objectStore("kv").count();o.onsuccess=function(e){n.cb(null,e.target.result)};t.onerror=function(e){c(e,n.cb)}}return n.promise};u.prototype.add=function(e,r,n){var t=this;var o=i(n);if(!t._db){t._queue.push({type:"add",key:e,value:r,cb:o.cb})}else{var u=t._db.transaction("kv","readwrite");var s=u.objectStore("kv").add(r,e);s.onsuccess=function(e){o.cb(null)};u.onerror=function(e){c(e,o.cb)}}return o.promise};u.prototype._drainQueue=function(){var e=this;for(var r=0;r<e._queue.length;r++){var n=e._queue[r];if(n.type==="get"){e.get(n.key,n.cb)}else if(n.type==="set"){e.set(n.key,n.value,n.cb)}else if(n.type==="json"){e.json(n.cb)}else if(n.type==="keys"){e.keys(n.cb)}else if(n.type==="remove"){e.remove(n.key,n.cb)}else if(n.type==="clear"){e.clear(n.cb)}else if(n.type==="count"){e.count(n.cb)}else if(n.type==="add"){e.add(n.key,n.value,n.cb)}}e._queue=null};function i(e){var r={cb:e};if(typeof Promise==="function"&&e==null){r.promise=new Promise(function(e,n){r.cb=function(r,t){if(r)return n(r);else return e(t)}})}if(!r.cb)r.cb=function e(){};return r}function c(e,r){var n=new Error("IDB error");n.event=e;if(r){r(n)}else{throw n}}},{}]},{},[])("/")}); |
module.exports = IdbKeyStore | ||
var IDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB | ||
var scope = typeof window === 'undefined' ? self : window // eslint-disable-line | ||
var IDB = scope.indexedDB || scope.mozIndexedDB || scope.webkitIndexedDB || scope.msIndexedDB | ||
@@ -5,0 +6,0 @@ function IdbKeyStore (name, opts) { |
{ | ||
"name": "idb-kv-store", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"description": "Persistent key-value store for web browsers backed by IndexDB", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
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
17671
284