idb-kv-store
Advanced tools
Comparing version 4.3.0 to 4.3.1
@@ -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 t;if(typeof window!=="undefined"){t=window}else if(typeof global!=="undefined"){t=global}else if(typeof self!=="undefined"){t=self}else{t=this}t.IdbKvStore=e()}})(function(){var e,t,r;return function e(t,r,n){function i(s,u){if(!r[s]){if(!t[s]){var a=typeof require=="function"&&require;if(!u&&a)return a(s,!0);if(o)return o(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var f=r[s]={exports:{}};t[s][0].call(f.exports,function(e){var r=t[s][1][e];return i(r?r:e)},f,f.exports,e,t,r,n)}return r[s].exports}var o=typeof require=="function"&&require;for(var s=0;s<n.length;s++)i(n[s]);return i}({1:[function(e,t,r){function n(){this._events=this._events||{};this._maxListeners=this._maxListeners||undefined}t.exports=n;n.EventEmitter=n;n.prototype._events=undefined;n.prototype._maxListeners=undefined;n.defaultMaxListeners=10;n.prototype.setMaxListeners=function(e){if(!o(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");this._maxListeners=e;return this};n.prototype.emit=function(e){var t,r,n,o,a,l;if(!this._events)this._events={};if(e==="error"){if(!this._events.error||s(this._events.error)&&!this._events.error.length){t=arguments[1];if(t instanceof Error){throw t}else{var f=new Error('Uncaught, unspecified "error" event. ('+t+")");f.context=t;throw f}}}r=this._events[e];if(u(r))return false;if(i(r)){switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:o=Array.prototype.slice.call(arguments,1);r.apply(this,o)}}else if(s(r)){o=Array.prototype.slice.call(arguments,1);l=r.slice();n=l.length;for(a=0;a<n;a++)l[a].apply(this,o)}return true};n.prototype.addListener=function(e,t){var r;if(!i(t))throw TypeError("listener must be a function");if(!this._events)this._events={};if(this._events.newListener)this.emit("newListener",e,i(t.listener)?t.listener:t);if(!this._events[e])this._events[e]=t;else if(s(this._events[e]))this._events[e].push(t);else this._events[e]=[this._events[e],t];if(s(this._events[e])&&!this._events[e].warned){if(!u(this._maxListeners)){r=this._maxListeners}else{r=n.defaultMaxListeners}if(r&&r>0&&this._events[e].length>r){this._events[e].warned=true;console.error("(node) warning: possible EventEmitter memory "+"leak detected. %d listeners added. "+"Use emitter.setMaxListeners() to increase limit.",this._events[e].length);if(typeof console.trace==="function"){console.trace()}}}return this};n.prototype.on=n.prototype.addListener;n.prototype.once=function(e,t){if(!i(t))throw TypeError("listener must be a function");var r=false;function n(){this.removeListener(e,n);if(!r){r=true;t.apply(this,arguments)}}n.listener=t;this.on(e,n);return this};n.prototype.removeListener=function(e,t){var r,n,o,u;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;r=this._events[e];o=r.length;n=-1;if(r===t||i(r.listener)&&r.listener===t){delete this._events[e];if(this._events.removeListener)this.emit("removeListener",e,t)}else if(s(r)){for(u=o;u-- >0;){if(r[u]===t||r[u].listener&&r[u].listener===t){n=u;break}}if(n<0)return this;if(r.length===1){r.length=0;delete this._events[e]}else{r.splice(n,1)}if(this._events.removeListener)this.emit("removeListener",e,t)}return this};n.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener){if(arguments.length===0)this._events={};else if(this._events[e])delete this._events[e];return this}if(arguments.length===0){for(t in this._events){if(t==="removeListener")continue;this.removeAllListeners(t)}this.removeAllListeners("removeListener");this._events={};return this}r=this._events[e];if(i(r)){this.removeListener(e,r)}else if(r){while(r.length)this.removeListener(e,r[r.length-1])}delete this._events[e];return this};n.prototype.listeners=function(e){var t;if(!this._events||!this._events[e])t=[];else if(i(this._events[e]))t=[this._events[e]];else t=this._events[e].slice();return t};n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;else if(t)return t.length}return 0};n.listenerCount=function(e,t){return e.listenerCount(t)};function i(e){return typeof e==="function"}function o(e){return typeof e==="number"}function s(e){return typeof e==="object"&&e!==null}function u(e){return e===void 0}},{}],2:[function(e,t,r){if(typeof Object.create==="function"){t.exports=function e(t,r){t.super_=r;t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:false,writable:true,configurable:true}})}}else{t.exports=function e(t,r){t.super_=r;var n=function(){};n.prototype=r.prototype;t.prototype=new n;t.prototype.constructor=t}}},{}],"/":[function(e,t,r){t.exports=u;var n=e("events").EventEmitter;var i=e("inherits");var o=typeof window==="undefined"?self:window;var s=o.indexedDB||o.mozIndexedDB||o.webkitIndexedDB||o.msIndexedDB;u.INDEXEDDB_SUPPORT=s!=null;u.BROADCAST_SUPPORT=o.BroadcastChannel!=null;i(u,n);function u(e,t,r){var i=this;if(typeof e!=="string")throw new Error("A name must be supplied of type string");if(!s)throw new Error("IndexedDB not supported");if(typeof t==="function")return new u(e,null,t);if(!(i instanceof u))return new u(e,t,r);if(!t)t={};n.call(i);i._db=null;i._closed=false;i._channel=null;i._waiters=[];var a=t.channel||o.BroadcastChannel;if(a){i._channel=new a(e);i._channel.onmessage=y}var f=s.open(e);f.onerror=c;f.onsuccess=p;f.onupgradeneeded=d;i.on("newListener",_);function c(e){l(e);i._close(e.target.error);if(r)r(e.target.error)}function h(e){l(e);i._close(e.target.error)}function p(e){if(i._closed){e.target.result.close()}else{i._db=e.target.result;i._db.onclose=v;i._db.onerror=h;for(var t in i._waiters)i._waiters[t]._init(null);i._waiters=null;if(r)r(null);i.emit("open")}}function d(e){var t=e.target.result;t.createObjectStore("kv",{autoIncrement:true})}function v(){i._close()}function _(e){if(e!=="add"&&e!=="set"&&e!=="remove")return;if(!i._channel)return i.emit("error",new Error("No BroadcastChannel support"))}function y(e){if(e.data.method==="add")i.emit("add",e.data);else if(e.data.method==="set")i.emit("set",e.data);else if(e.data.method==="remove")i.emit("remove",e.data)}}u.prototype.get=function(e,t){return this.transaction("readonly").get(e,t)};u.prototype.set=function(e,t,r){return this.transaction("readwrite").set(e,t,r)};u.prototype.json=function(e,t){return this.transaction("readonly").json(e,t)};u.prototype.keys=function(e,t){return this.transaction("readonly").keys(e,t)};u.prototype.values=function(e,t){return this.transaction("readonly").values(e,t)};u.prototype.remove=function(e,t){return this.transaction("readwrite").remove(e,t)};u.prototype.clear=function(e){return this.transaction("readwrite").clear(e)};u.prototype.count=function(e){return this.transaction("readonly").count(e)};u.prototype.add=function(e,t,r){return this.transaction("readwrite").add(e,t,r)};u.prototype.iterator=function(e,t){return this.transaction("readonly").iterator(e,t)};u.prototype.transaction=function(e){if(this._closed)throw new Error("Database is closed");var t=new a(this,e);if(this._db)t._init(null);else this._waiters.push(t);return t};u.prototype.close=function(){this._close()};u.prototype._close=function(e){if(this._closed)return;this._closed=true;if(this._db)this._db.close();if(this._channel)this._channel.close();this._db=null;this._channel=null;if(e)this.emit("error",e);this.emit("close");for(var t in this._waiters)this._waiters[t]._init(e||new Error("Database is closed"));this._waiters=null;this.removeAllListeners()};function a(e,t){this._kvStore=e;this._mode=t||"readwrite";this._objectStore=null;this._waiters=null;this.finished=false;this.onfinish=null;if(this._mode!=="readonly"&&this._mode!=="readwrite"){throw new Error('mode must be either "readonly" or "readwrite"')}}a.prototype._init=function(e){var t=this;if(t.finished)return;if(e)return t._close(e);var r=t._kvStore._db.transaction("kv",t._mode);r.oncomplete=i;r.onerror=o;t._objectStore=r.objectStore("kv");for(var n in t._waiters)t._waiters[n](null,t._objectStore);t._waiters=null;function i(){t._close(null)}function o(e){l(e);t._close(e.target.error)}};a.prototype._getObjectStore=function(e){if(this.finished)throw new Error("Transaction is finished");if(this._objectStore)return e(null,this._objectStore);this._waiters=this._waiters||[];this._waiters.push(e)};a.prototype.set=function(e,t,r){var n=this;if(e==null||t==null)throw new Error("A key and value must be given");r=f(r);n._getObjectStore(function(i,o){if(i)return r(i);try{var s=o.put(t,e)}catch(e){return r(e)}s.onerror=l.bind(this,r);s.onsuccess=function(){if(n._kvStore._channel){n._kvStore._channel.postMessage({method:"set",key:e,value:t})}r(null)}});return r.promise};a.prototype.add=function(e,t,r){var n=this;if(t==null&&e!=null)return n.add(undefined,e,r);if(typeof t==="function"||t==null&&r==null)return n.add(undefined,e,t);if(t==null)throw new Error("A value must be provided as an argument");r=f(r);n._getObjectStore(function(i,o){if(i)return r(i);try{var s=e==null?o.add(t):o.add(t,e)}catch(e){return r(e)}s.onerror=l.bind(this,r);s.onsuccess=function(){if(n._kvStore._channel){n._kvStore._channel.postMessage({method:"add",key:e,value:t})}r(null)}});return r.promise};a.prototype.get=function(e,t){var r=this;if(e==null)throw new Error("A key must be given as an argument");t=f(t);r._getObjectStore(function(r,n){if(r)return t(r);try{var i=n.get(e)}catch(e){return t(e)}i.onerror=l.bind(this,t);i.onsuccess=function(e){t(null,e.target.result)}});return t.promise};a.prototype.json=function(e,t){var r=this;if(typeof e==="function")return r.json(null,e);t=f(t);var n={};r.iterator(e,function(e,r){if(e)return t(e);if(r){n[r.key]=r.value;r.continue()}else{t(null,n)}});return t.promise};a.prototype.keys=function(e,t){var r=this;if(typeof e==="function")return r.keys(null,e);t=f(t);var n=[];r.iterator(e,function(e,r){if(e)return t(e);if(r){n.push(r.key);r.continue()}else{t(null,n)}});return t.promise};a.prototype.values=function(e,t){var r=this;if(typeof e==="function")return r.values(null,e);t=f(t);var n=[];r.iterator(e,function(e,r){if(e)return t(e);if(r){n.push(r.value);r.continue()}else{t(null,n)}});return t.promise};a.prototype.remove=function(e,t){var r=this;if(e==null)throw new Error("A key must be given as an argument");t=f(t);r._getObjectStore(function(n,i){if(n)return t(n);try{var o=i.delete(e)}catch(e){return t(e)}o.onerror=l.bind(this,t);o.onsuccess=function(){if(r._kvStore._channel){r._kvStore._channel.postMessage({method:"remove",key:e})}t(null)}});return t.promise};a.prototype.clear=function(e){var t=this;e=f(e);t._getObjectStore(function(t,r){if(t)return e(t);try{var n=r.clear()}catch(t){return e(t)}n.onerror=l.bind(this,e);n.onsuccess=function(){e(null)}});return e.promise};a.prototype.count=function(e){var t=this;e=f(e);t._getObjectStore(function(t,r){if(t)return e(t);try{var n=r.count()}catch(t){return e(t)}n.onerror=l.bind(this,e);n.onsuccess=function(t){e(null,t.target.result)}});return e.promise};a.prototype.iterator=function(e,t){var r=this;if(typeof e==="function")return r.iterator(null,e);if(typeof t!=="function")throw new Error("A function must be given");r._getObjectStore(function(r,n){if(r)return t(r);try{var i=e==null?n.openCursor():n.openCursor(e)}catch(e){return t(e)}i.onerror=l.bind(this,t);i.onsuccess=function(e){var r=e.target.result;t(null,r)}})};a.prototype.abort=function(){if(this.finished)throw new Error("Transaction is finished");if(this._objectStore)this._objectStore.transaction.abort();this._close(new Error("Transaction aborted"))};a.prototype._close=function(e){if(this.finished)return;this.finished=true;this._kvStore=null;this._objectStore=null;for(var t in this._waiters)this._waiters[t](e||new Error("Transaction is finished"));if(this.onfinish)this.onfinish(e);this.onfinish=null;this._waiters=null};function l(e,t){if(t==null)return l(null,e);t.preventDefault();t.stopPropagation();if(e)e(t.target.error)}function f(e){var t;var r;var n;if(e!=null&&typeof e!=="function")throw new Error("cb must be a function");if(e==null&&typeof Promise!=="undefined"){t=new Promise(function(e,t){r=e;n=t})}function i(i,o){if(t){if(i)n(i);else r(o)}else{if(e)e(i,o);else if(i)throw i}}i.promise=t;return i}},{events:1,inherits:2}]},{},[])("/")}); | ||
(function(e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define([],e)}else{var t;if(typeof window!=="undefined"){t=window}else if(typeof global!=="undefined"){t=global}else if(typeof self!=="undefined"){t=self}else{t=this}t.IdbKvStore=e()}})(function(){var e,t,n;return function e(t,n,r){function i(s,u){if(!n[s]){if(!t[s]){var a=typeof require=="function"&&require;if(!u&&a)return a(s,!0);if(o)return o(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var f=n[s]={exports:{}};t[s][0].call(f.exports,function(e){var n=t[s][1][e];return i(n?n:e)},f,f.exports,e,t,n,r)}return n[s].exports}var o=typeof require=="function"&&require;for(var s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,t,n){function r(){this._events=this._events||{};this._maxListeners=this._maxListeners||undefined}t.exports=r;r.EventEmitter=r;r.prototype._events=undefined;r.prototype._maxListeners=undefined;r.defaultMaxListeners=10;r.prototype.setMaxListeners=function(e){if(!o(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");this._maxListeners=e;return this};r.prototype.emit=function(e){var t,n,r,o,a,l;if(!this._events)this._events={};if(e==="error"){if(!this._events.error||s(this._events.error)&&!this._events.error.length){t=arguments[1];if(t instanceof Error){throw t}else{var f=new Error('Uncaught, unspecified "error" event. ('+t+")");f.context=t;throw f}}}n=this._events[e];if(u(n))return false;if(i(n)){switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:o=Array.prototype.slice.call(arguments,1);n.apply(this,o)}}else if(s(n)){o=Array.prototype.slice.call(arguments,1);l=n.slice();r=l.length;for(a=0;a<r;a++)l[a].apply(this,o)}return true};r.prototype.addListener=function(e,t){var n;if(!i(t))throw TypeError("listener must be a function");if(!this._events)this._events={};if(this._events.newListener)this.emit("newListener",e,i(t.listener)?t.listener:t);if(!this._events[e])this._events[e]=t;else if(s(this._events[e]))this._events[e].push(t);else this._events[e]=[this._events[e],t];if(s(this._events[e])&&!this._events[e].warned){if(!u(this._maxListeners)){n=this._maxListeners}else{n=r.defaultMaxListeners}if(n&&n>0&&this._events[e].length>n){this._events[e].warned=true;console.error("(node) warning: possible EventEmitter memory "+"leak detected. %d listeners added. "+"Use emitter.setMaxListeners() to increase limit.",this._events[e].length);if(typeof console.trace==="function"){console.trace()}}}return this};r.prototype.on=r.prototype.addListener;r.prototype.once=function(e,t){if(!i(t))throw TypeError("listener must be a function");var n=false;function r(){this.removeListener(e,r);if(!n){n=true;t.apply(this,arguments)}}r.listener=t;this.on(e,r);return this};r.prototype.removeListener=function(e,t){var n,r,o,u;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;n=this._events[e];o=n.length;r=-1;if(n===t||i(n.listener)&&n.listener===t){delete this._events[e];if(this._events.removeListener)this.emit("removeListener",e,t)}else if(s(n)){for(u=o;u-- >0;){if(n[u]===t||n[u].listener&&n[u].listener===t){r=u;break}}if(r<0)return this;if(n.length===1){n.length=0;delete this._events[e]}else{n.splice(r,1)}if(this._events.removeListener)this.emit("removeListener",e,t)}return this};r.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener){if(arguments.length===0)this._events={};else if(this._events[e])delete this._events[e];return this}if(arguments.length===0){for(t in this._events){if(t==="removeListener")continue;this.removeAllListeners(t)}this.removeAllListeners("removeListener");this._events={};return this}n=this._events[e];if(i(n)){this.removeListener(e,n)}else if(n){while(n.length)this.removeListener(e,n[n.length-1])}delete this._events[e];return this};r.prototype.listeners=function(e){var t;if(!this._events||!this._events[e])t=[];else if(i(this._events[e]))t=[this._events[e]];else t=this._events[e].slice();return t};r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;else if(t)return t.length}return 0};r.listenerCount=function(e,t){return e.listenerCount(t)};function i(e){return typeof e==="function"}function o(e){return typeof e==="number"}function s(e){return typeof e==="object"&&e!==null}function u(e){return e===void 0}},{}],2:[function(e,t,n){if(typeof Object.create==="function"){t.exports=function e(t,n){t.super_=n;t.prototype=Object.create(n.prototype,{constructor:{value:t,enumerable:false,writable:true,configurable:true}})}}else{t.exports=function e(t,n){t.super_=n;var r=function(){};r.prototype=n.prototype;t.prototype=new r;t.prototype.constructor=t}}},{}],3:[function(e,t,n){t.exports=r;function r(e){var t;var n;var r;if(e!=null&&typeof e!=="function")throw new Error("cb must be a function");if(e==null&&typeof Promise!=="undefined"){t=new Promise(function(e,t){n=e;r=t})}function i(i,o){if(t){if(i)r(i);else n(o)}else{if(e)e(i,o);else if(i)throw i}}i.promise=t;return i}},{}],"/":[function(e,t,n){t.exports=a;var r=e("events").EventEmitter;var i=e("inherits");var o=e("promisize");var s=typeof window==="undefined"?self:window;var u=s.indexedDB||s.mozIndexedDB||s.webkitIndexedDB||s.msIndexedDB;a.INDEXEDDB_SUPPORT=u!=null;a.BROADCAST_SUPPORT=s.BroadcastChannel!=null;i(a,r);function a(e,t,n){var i=this;if(typeof e!=="string")throw new Error("A name must be supplied of type string");if(!u)throw new Error("IndexedDB not supported");if(typeof t==="function")return new a(e,null,t);if(!(i instanceof a))return new a(e,t,n);if(!t)t={};r.call(i);i._db=null;i._closed=false;i._channel=null;i._waiters=[];var o=t.channel||s.BroadcastChannel;if(o){i._channel=new o(e);i._channel.onmessage=y}var l=u.open(e);l.onerror=c;l.onsuccess=p;l.onupgradeneeded=d;i.on("newListener",_);function c(e){f(e);i._close(e.target.error);if(n)n(e.target.error)}function h(e){f(e);i._close(e.target.error)}function p(e){if(i._closed){e.target.result.close()}else{i._db=e.target.result;i._db.onclose=v;i._db.onerror=h;for(var t in i._waiters)i._waiters[t]._init(null);i._waiters=null;if(n)n(null);i.emit("open")}}function d(e){var t=e.target.result;t.createObjectStore("kv",{autoIncrement:true})}function v(){i._close()}function _(e){if(e!=="add"&&e!=="set"&&e!=="remove")return;if(!i._channel)return i.emit("error",new Error("No BroadcastChannel support"))}function y(e){if(e.data.method==="add")i.emit("add",e.data);else if(e.data.method==="set")i.emit("set",e.data);else if(e.data.method==="remove")i.emit("remove",e.data)}}a.prototype.get=function(e,t){return this.transaction("readonly").get(e,t)};a.prototype.set=function(e,t,n){return this.transaction("readwrite").set(e,t,n)};a.prototype.json=function(e,t){return this.transaction("readonly").json(e,t)};a.prototype.keys=function(e,t){return this.transaction("readonly").keys(e,t)};a.prototype.values=function(e,t){return this.transaction("readonly").values(e,t)};a.prototype.remove=function(e,t){return this.transaction("readwrite").remove(e,t)};a.prototype.clear=function(e){return this.transaction("readwrite").clear(e)};a.prototype.count=function(e,t){return this.transaction("readonly").count(e,t)};a.prototype.add=function(e,t,n){return this.transaction("readwrite").add(e,t,n)};a.prototype.iterator=function(e,t){return this.transaction("readonly").iterator(e,t)};a.prototype.transaction=function(e){if(this._closed)throw new Error("Database is closed");var t=new l(this,e);if(this._db)t._init(null);else this._waiters.push(t);return t};a.prototype.close=function(){this._close()};a.prototype._close=function(e){if(this._closed)return;this._closed=true;if(this._db)this._db.close();if(this._channel)this._channel.close();this._db=null;this._channel=null;if(e)this.emit("error",e);this.emit("close");for(var t in this._waiters)this._waiters[t]._init(e||new Error("Database is closed"));this._waiters=null;this.removeAllListeners()};function l(e,t){this._kvStore=e;this._mode=t||"readwrite";this._objectStore=null;this._waiters=null;this.finished=false;this.onfinish=null;if(this._mode!=="readonly"&&this._mode!=="readwrite"){throw new Error('mode must be either "readonly" or "readwrite"')}}l.prototype._init=function(e){var t=this;if(t.finished)return;if(e)return t._close(e);var n=t._kvStore._db.transaction("kv",t._mode);n.oncomplete=i;n.onerror=o;t._objectStore=n.objectStore("kv");for(var r in t._waiters)t._waiters[r](null,t._objectStore);t._waiters=null;function i(){t._close(null)}function o(e){f(e);t._close(e.target.error)}};l.prototype._getObjectStore=function(e){if(this.finished)throw new Error("Transaction is finished");if(this._objectStore)return e(null,this._objectStore);this._waiters=this._waiters||[];this._waiters.push(e)};l.prototype.set=function(e,t,n){var r=this;if(e==null||t==null)throw new Error("A key and value must be given");n=o(n);r._getObjectStore(function(i,o){if(i)return n(i);try{var s=o.put(t,e)}catch(e){return n(e)}s.onerror=f.bind(this,n);s.onsuccess=function(){if(r._kvStore._channel){r._kvStore._channel.postMessage({method:"set",key:e,value:t})}n(null)}});return n.promise};l.prototype.add=function(e,t,n){var r=this;if(t==null&&e!=null)return r.add(undefined,e,n);if(typeof t==="function"||t==null&&n==null)return r.add(undefined,e,t);if(t==null)throw new Error("A value must be provided as an argument");n=o(n);r._getObjectStore(function(i,o){if(i)return n(i);try{var s=e==null?o.add(t):o.add(t,e)}catch(e){return n(e)}s.onerror=f.bind(this,n);s.onsuccess=function(){if(r._kvStore._channel){r._kvStore._channel.postMessage({method:"add",key:e,value:t})}n(null)}});return n.promise};l.prototype.get=function(e,t){var n=this;if(e==null)throw new Error("A key must be given as an argument");t=o(t);n._getObjectStore(function(n,r){if(n)return t(n);try{var i=r.get(e)}catch(e){return t(e)}i.onerror=f.bind(this,t);i.onsuccess=function(e){t(null,e.target.result)}});return t.promise};l.prototype.json=function(e,t){var n=this;if(typeof e==="function")return n.json(null,e);t=o(t);var r={};n.iterator(e,function(e,n){if(e)return t(e);if(n){r[n.key]=n.value;n.continue()}else{t(null,r)}});return t.promise};l.prototype.keys=function(e,t){var n=this;if(typeof e==="function")return n.keys(null,e);t=o(t);var r=[];n.iterator(e,function(e,n){if(e)return t(e);if(n){r.push(n.key);n.continue()}else{t(null,r)}});return t.promise};l.prototype.values=function(e,t){var n=this;if(typeof e==="function")return n.values(null,e);t=o(t);var r=[];n.iterator(e,function(e,n){if(e)return t(e);if(n){r.push(n.value);n.continue()}else{t(null,r)}});return t.promise};l.prototype.remove=function(e,t){var n=this;if(e==null)throw new Error("A key must be given as an argument");t=o(t);n._getObjectStore(function(r,i){if(r)return t(r);try{var o=i.delete(e)}catch(e){return t(e)}o.onerror=f.bind(this,t);o.onsuccess=function(){if(n._kvStore._channel){n._kvStore._channel.postMessage({method:"remove",key:e})}t(null)}});return t.promise};l.prototype.clear=function(e){var t=this;e=o(e);t._getObjectStore(function(t,n){if(t)return e(t);try{var r=n.clear()}catch(t){return e(t)}r.onerror=f.bind(this,e);r.onsuccess=function(){e(null)}});return e.promise};l.prototype.count=function(e,t){var n=this;if(typeof e==="function")return n.count(null,e);t=o(t);n._getObjectStore(function(n,r){if(n)return t(n);try{var i=e==null?r.count():r.count(e)}catch(e){return t(e)}i.onerror=f.bind(this,t);i.onsuccess=function(e){t(null,e.target.result)}});return t.promise};l.prototype.iterator=function(e,t){var n=this;if(typeof e==="function")return n.iterator(null,e);if(typeof t!=="function")throw new Error("A function must be given");n._getObjectStore(function(n,r){if(n)return t(n);try{var i=e==null?r.openCursor():r.openCursor(e)}catch(e){return t(e)}i.onerror=f.bind(this,t);i.onsuccess=function(e){var n=e.target.result;t(null,n)}})};l.prototype.abort=function(){if(this.finished)throw new Error("Transaction is finished");if(this._objectStore)this._objectStore.transaction.abort();this._close(new Error("Transaction aborted"))};l.prototype._close=function(e){if(this.finished)return;this.finished=true;this._kvStore=null;this._objectStore=null;for(var t in this._waiters)this._waiters[t](e||new Error("Transaction is finished"));if(this.onfinish)this.onfinish(e);this.onfinish=null;this._waiters=null};function f(e,t){if(t==null)return f(null,e);t.preventDefault();t.stopPropagation();if(e)e(t.target.error)}},{events:1,inherits:2,promisize:3}]},{},[])("/")}); |
@@ -241,3 +241,3 @@ /* eslint-env browser */ | ||
if (value == null && key != null) return self.add(undefined, key, cb) | ||
if (typeof value === 'function' || value == null && cb == null) return self.add(undefined, key, value) | ||
if (typeof value === 'function' || (value == null && cb == null)) return self.add(undefined, key, value) | ||
if (value == null) throw new Error('A value must be provided as an argument') | ||
@@ -244,0 +244,0 @@ cb = promisize(cb) |
{ | ||
"name": "idb-kv-store", | ||
"version": "4.3.0", | ||
"version": "4.3.1", | ||
"description": "Persistent key-value store for web browsers backed by IndexedDB", | ||
@@ -15,3 +15,3 @@ "main": "index.js", | ||
"scripts": { | ||
"build": "browserify -r . -s IdbKvStore | uglifyjs -m > idbkvstore.min.js", | ||
"bundle": "browserify -r . -s IdbKvStore | uglifyjs -m > idbkvstore.min.js", | ||
"standard": "standard", | ||
@@ -33,19 +33,19 @@ "karma": "karma start", | ||
"devDependencies": { | ||
"browserify": "^13.3.0", | ||
"karma": "^1.4.0", | ||
"karma-browserify": "^5.1.0", | ||
"browserify": "^14.3.0", | ||
"karma": "^1.6.0", | ||
"karma-browserify": "^5.1.1", | ||
"karma-chrome-launcher": "^2.0.0", | ||
"karma-firefox-launcher": "^1.0.0", | ||
"karma-firefox-launcher": "^1.0.1", | ||
"karma-sauce-launcher": "^1.1.0", | ||
"karma-tap": "^3.1.1", | ||
"run-parallel-limit": "^1.0.3", | ||
"standard": "^8.6.0", | ||
"standard": "^10.0.2", | ||
"tape": "^4.6.3", | ||
"uglify-js": "^2.7.4", | ||
"watchify": "^3.8.0" | ||
"uglify-js": "^2.8.22", | ||
"watchify": "^3.9.0" | ||
}, | ||
"dependencies": { | ||
"inherits": "^2.0.3", | ||
"promisize": "^1.1.1" | ||
"promisize": "^1.1.2" | ||
} | ||
} |
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
55540
Updatedpromisize@^1.1.2