Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

idb-kv-store

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

idb-kv-store - npm Package Compare versions

Comparing version 3.2.1 to 3.3.0

2

idbkvstore.min.js

@@ -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 s(o,u){if(!r[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=r[o]={exports:{}};t[o][0].call(c.exports,function(e){var r=t[o][1][e];return s(r?r:e)},c,c.exports,e,t,r,n)}return r[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<n.length;o++)s(n[o]);return s}({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(!i(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,i,a,l;if(!this._events)this._events={};if(e==="error"){if(!this._events.error||o(this._events.error)&&!this._events.error.length){t=arguments[1];if(t instanceof Error){throw t}else{var c=new Error('Uncaught, unspecified "error" event. ('+t+")");c.context=t;throw c}}}r=this._events[e];if(u(r))return false;if(s(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:i=Array.prototype.slice.call(arguments,1);r.apply(this,i)}}else if(o(r)){i=Array.prototype.slice.call(arguments,1);l=r.slice();n=l.length;for(a=0;a<n;a++)l[a].apply(this,i)}return true};n.prototype.addListener=function(e,t){var r;if(!s(t))throw TypeError("listener must be a function");if(!this._events)this._events={};if(this._events.newListener)this.emit("newListener",e,s(t.listener)?t.listener:t);if(!this._events[e])this._events[e]=t;else if(o(this._events[e]))this._events[e].push(t);else this._events[e]=[this._events[e],t];if(o(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(!s(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,i,u;if(!s(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;r=this._events[e];i=r.length;n=-1;if(r===t||s(r.listener)&&r.listener===t){delete this._events[e];if(this._events.removeListener)this.emit("removeListener",e,t)}else if(o(r)){for(u=i;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(s(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(s(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(s(t))return 1;else if(t)return t.length}return 0};n.listenerCount=function(e,t){return e.listenerCount(t)};function s(e){return typeof e==="function"}function i(e){return typeof e==="number"}function o(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 s=e("inherits");var i=typeof window==="undefined"?self:window;var o=i.indexedDB||i.mozIndexedDB||i.webkitIndexedDB||i.msIndexedDB;u.INDEXEDDB_SUPPORT=o!=null;u.BROADCAST_SUPPORT=i.BroadcastChannel!=null;s(u,n);function u(e,t,r){var s=this;if(typeof e!=="string")throw new Error("A name must be supplied of type string");if(!o)throw new Error("IndexedDB not supported");if(typeof t==="function")return new u(e,null,t);if(!(this instanceof u))return new u(e,t,r);if(!t)t={};n.call(s);s._name=e;s._db=null;s._closed=false;s._queue=[];s._Channel=t.channel||i.BroadcastChannel;s._channel=null;var a=o.open(e);a.onerror=l;a.onsuccess=c;a.onupgradeneeded=f;s.on("newListener",v);function l(e){s.close();s._handleError(e,r)}function c(e){if(s._closed){e.target.result.close()}else{s._db=e.target.result;s._db.onclose=h;s._drainQueue();if(r)r(null);s.emit("open")}}function f(e){if(s._closed)return;var t=e.target.result;t.createObjectStore("kv")}function h(){s.close()}function v(e){if(e!=="change")return;if(!s._Channel)return s.emit("error",new Error("No BroadcastChannel support"));s._channel=new s._Channel(s._name);s._channel.onmessage=d;s.removeListener("newListener",v)}function d(e){s.emit("change",e.data)}}u.prototype.get=function(e,t){var r=this;if(r._closed)throw new Error("Database is closed");var n=a(t);if(!r._db){r._queue.push([r.get,e,n.cb])}else if(Array.isArray(e)){var s=[];var i=false;var o=0;e.forEach(function(t,u){r.get(e[u],function(t,r){if(i)return;if(t){i=true;n.cb(t)}s[u]=r;o++;if(o===e.length)n.cb(null,s)})})}else{var u=r._db.transaction("kv","readonly");var l=u.objectStore("kv").get(e);l.onsuccess=function(e){n.cb(null,e.target.result)};u.onerror=function(e){r._handleError(e,n.cb)}}return n.promise};u.prototype.set=function(e,t,r){var n=this;if(n._closed)throw new Error("Database is closed");var s=a(r);if(!n._db){n._queue.push([n.set,e,t,s.cb])}else{var i=n._db.transaction("kv","readwrite");var o=i.objectStore("kv").put(t,e);o.onsuccess=function(){if(n._channel){n._channel.postMessage({method:"set",key:e,value:t})}s.cb(null)};i.onerror=function(e){n._handleError(e,s.cb)}}return s.promise};u.prototype.json=function(e){var t=this;if(t._closed)throw new Error("Database is closed");var r=a(e);if(!t._db){t._queue.push([t.json,r.cb])}else{var n=t._db.transaction("kv","readonly");var s=n.objectStore("kv").openCursor();var i={};s.onsuccess=function(e){var t=e.target.result;if(t){i[t.key]=t.value;t.continue()}else{r.cb(null,i)}};n.onerror=function(e){t._handleError(e,r.cb)}}return r.promise};u.prototype.keys=function(e){var t=this;if(t._closed)throw new Error("Database is closed");var r=a(e);if(!t._db){t._queue.push([t.keys,r.cb])}else{var n=t._db.transaction("kv","readonly");var s=n.objectStore("kv").openCursor();var i=[];s.onsuccess=function(e){var t=e.target.result;if(t){i.push(t.key);t.continue()}else{r.cb(null,i)}};n.onerror=function(e){t._handleError(e,r.cb)}}return r.promise};u.prototype.remove=function(e,t){var r=this;if(r._closed)throw new Error("Database is closed");var n=a(t);if(!r._db){r._queue.push([r.remove,e,n.cb])}else{var s=r._db.transaction("kv","readwrite");var i=s.objectStore("kv").delete(e);i.onsuccess=function(t){if(r._channel){r._channel.postMessage({method:"remove",key:e})}n.cb(null)};s.onerror=function(e){r._handleError(e,n.cb)}}return n.promise};u.prototype.clear=function(e){var t=this;if(t._closed)throw new Error("Database is closed");var r=a(e);if(!t._db){t._queue.push([t.clear,r.cb])}else{var n=t._db.transaction("kv","readwrite");var s=n.objectStore("kv").clear();s.onsuccess=function(e){r.cb(null)};n.onerror=function(e){t._handleError(e,r.cb)}}return r.promise};u.prototype.count=function(e){var t=this;if(t._closed)throw new Error("Database is closed");var r=a(e);if(!t._db){t._queue.push([t.count,r.cb])}else{var n=t._db.transaction("kv","readonly");var s=n.objectStore("kv").count();s.onsuccess=function(e){r.cb(null,e.target.result)};n.onerror=function(e){t._handleError(e,r.cb)}}return r.promise};u.prototype.add=function(e,t,r){var n=this;if(n._closed)throw new Error("Database is closed");var s=a(r);if(!n._db){n._queue.push([n.add,e,t,s.cb])}else{var i=n._db.transaction("kv","readwrite");var o=i.objectStore("kv").add(t,e);o.onsuccess=function(r){if(n._channel){n._channel.postMessage({method:"add",key:e,value:t})}s.cb(null)};i.onerror=function(e){n._handleError(e,s.cb)}}return s.promise};u.prototype.close=function(){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;this._queue=null;this.emit("close");this.removeAllListeners()};u.prototype._drainQueue=function(){var e=this;for(var t=0;t<e._queue.length;t++){var r=e._queue[t];var n=r.splice(1);r[0].apply(e,n)}e._queue=null};u.prototype._handleError=function(e,t){var r=e.target.error;if(t){t(r)}else{this.emit("error",r)}};function a(e){var t={cb:e};if(typeof Promise==="function"&&e==null){t.promise=new Promise(function(e,r){t.cb=function(t,n){if(t)return r(t);else return e(n)}})}if(!t.cb)t.cb=function e(){};return t}},{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,r;return function e(t,r,n){function s(o,u){if(!r[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=r[o]={exports:{}};t[o][0].call(c.exports,function(e){var r=t[o][1][e];return s(r?r:e)},c,c.exports,e,t,r,n)}return r[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<n.length;o++)s(n[o]);return s}({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(!i(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,i,a,l;if(!this._events)this._events={};if(e==="error"){if(!this._events.error||o(this._events.error)&&!this._events.error.length){t=arguments[1];if(t instanceof Error){throw t}else{var c=new Error('Uncaught, unspecified "error" event. ('+t+")");c.context=t;throw c}}}r=this._events[e];if(u(r))return false;if(s(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:i=Array.prototype.slice.call(arguments,1);r.apply(this,i)}}else if(o(r)){i=Array.prototype.slice.call(arguments,1);l=r.slice();n=l.length;for(a=0;a<n;a++)l[a].apply(this,i)}return true};n.prototype.addListener=function(e,t){var r;if(!s(t))throw TypeError("listener must be a function");if(!this._events)this._events={};if(this._events.newListener)this.emit("newListener",e,s(t.listener)?t.listener:t);if(!this._events[e])this._events[e]=t;else if(o(this._events[e]))this._events[e].push(t);else this._events[e]=[this._events[e],t];if(o(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(!s(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,i,u;if(!s(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;r=this._events[e];i=r.length;n=-1;if(r===t||s(r.listener)&&r.listener===t){delete this._events[e];if(this._events.removeListener)this.emit("removeListener",e,t)}else if(o(r)){for(u=i;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(s(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(s(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(s(t))return 1;else if(t)return t.length}return 0};n.listenerCount=function(e,t){return e.listenerCount(t)};function s(e){return typeof e==="function"}function i(e){return typeof e==="number"}function o(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 s=e("inherits");var i=typeof window==="undefined"?self:window;var o=i.indexedDB||i.mozIndexedDB||i.webkitIndexedDB||i.msIndexedDB;u.INDEXEDDB_SUPPORT=o!=null;u.BROADCAST_SUPPORT=i.BroadcastChannel!=null;s(u,n);function u(e,t,r){var s=this;if(typeof e!=="string")throw new Error("A name must be supplied of type string");if(!o)throw new Error("IndexedDB not supported");if(typeof t==="function")return new u(e,null,t);if(!(this instanceof u))return new u(e,t,r);if(!t)t={};n.call(s);s._name=e;s._db=null;s._closed=false;s._queue=[];s._Channel=t.channel||i.BroadcastChannel;s._channel=null;var a=o.open(e);a.onerror=l;a.onsuccess=c;a.onupgradeneeded=f;s.on("newListener",v);function l(e){s.close();s._handleError(e,r)}function c(e){if(s._closed){e.target.result.close()}else{s._db=e.target.result;s._db.onclose=h;s._drainQueue();if(r)r(null);s.emit("open")}}function f(e){if(s._closed)return;var t=e.target.result;t.createObjectStore("kv",{autoIncrement:true})}function h(){s.close()}function v(e){if(e!=="change")return;if(!s._Channel)return s.emit("error",new Error("No BroadcastChannel support"));s._channel=new s._Channel(s._name);s._channel.onmessage=d;s.removeListener("newListener",v)}function d(e){s.emit("change",e.data)}}u.prototype.get=function(e,t){var r=this;if(r._closed)throw new Error("Database is closed");var n=a(t);if(!r._db){r._queue.push([r.get,e,n.cb])}else if(Array.isArray(e)){var s=[];var i=false;var o=0;e.forEach(function(t,u){r.get(e[u],function(t,r){if(i)return;if(t){i=true;n.cb(t)}s[u]=r;o++;if(o===e.length)n.cb(null,s)})})}else{var u=r._db.transaction("kv","readonly");var l=u.objectStore("kv").get(e);l.onsuccess=function(e){n.cb(null,e.target.result)};u.onerror=function(e){r._handleError(e,n.cb)}}return n.promise};u.prototype.set=function(e,t,r){var n=this;if(n._closed)throw new Error("Database is closed");var s=a(r);if(!n._db){n._queue.push([n.set,e,t,s.cb])}else{var i=n._db.transaction("kv","readwrite");var o=i.objectStore("kv").put(t,e);o.onsuccess=function(){if(n._channel){n._channel.postMessage({method:"set",key:e,value:t})}s.cb(null)};i.onerror=function(e){n._handleError(e,s.cb)}}return s.promise};u.prototype.json=function(e){var t=this;if(t._closed)throw new Error("Database is closed");var r=a(e);if(!t._db){t._queue.push([t.json,r.cb])}else{var n=t._db.transaction("kv","readonly");var s=n.objectStore("kv").openCursor();var i={};s.onsuccess=function(e){var t=e.target.result;if(t){i[t.key]=t.value;t.continue()}else{r.cb(null,i)}};n.onerror=function(e){t._handleError(e,r.cb)}}return r.promise};u.prototype.keys=function(e){var t=this;if(t._closed)throw new Error("Database is closed");var r=a(e);if(!t._db){t._queue.push([t.keys,r.cb])}else{var n=t._db.transaction("kv","readonly");var s=n.objectStore("kv").openCursor();var i=[];s.onsuccess=function(e){var t=e.target.result;if(t){i.push(t.key);t.continue()}else{r.cb(null,i)}};n.onerror=function(e){t._handleError(e,r.cb)}}return r.promise};u.prototype.remove=function(e,t){var r=this;if(r._closed)throw new Error("Database is closed");var n=a(t);if(!r._db){r._queue.push([r.remove,e,n.cb])}else{var s=r._db.transaction("kv","readwrite");var i=s.objectStore("kv").delete(e);i.onsuccess=function(t){if(r._channel){r._channel.postMessage({method:"remove",key:e})}n.cb(null)};s.onerror=function(e){r._handleError(e,n.cb)}}return n.promise};u.prototype.clear=function(e){var t=this;if(t._closed)throw new Error("Database is closed");var r=a(e);if(!t._db){t._queue.push([t.clear,r.cb])}else{var n=t._db.transaction("kv","readwrite");var s=n.objectStore("kv").clear();s.onsuccess=function(e){r.cb(null)};n.onerror=function(e){t._handleError(e,r.cb)}}return r.promise};u.prototype.count=function(e){var t=this;if(t._closed)throw new Error("Database is closed");var r=a(e);if(!t._db){t._queue.push([t.count,r.cb])}else{var n=t._db.transaction("kv","readonly");var s=n.objectStore("kv").count();s.onsuccess=function(e){r.cb(null,e.target.result)};n.onerror=function(e){t._handleError(e,r.cb)}}return r.promise};u.prototype.add=function(e,t,r){var n=this;if(n._closed)throw new Error("Database is closed");if(typeof t==="function"||arguments.length===1)return n.add(undefined,e,t);var s=a(r);if(!n._db){n._queue.push([n.add,e,t,s.cb])}else{var i=n._db.transaction("kv","readwrite");var o=e==null?i.objectStore("kv").add(t):i.objectStore("kv").add(t,e);o.onsuccess=function(r){if(n._channel){n._channel.postMessage({method:"add",key:e,value:t})}s.cb(null)};i.onerror=function(e){n._handleError(e,s.cb)}}return s.promise};u.prototype.close=function(){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;this._queue=null;this.emit("close");this.removeAllListeners()};u.prototype._drainQueue=function(){var e=this;for(var t=0;t<e._queue.length;t++){var r=e._queue[t];var n=r.splice(1);r[0].apply(e,n)}e._queue=null};u.prototype._handleError=function(e,t){var r=e.target.error;e.preventDefault();if(t){t(r)}else{this.emit("error",r)}};function a(e){var t={cb:e};if(typeof Promise==="function"&&e==null){t.promise=new Promise(function(e,r){t.cb=function(t,n){if(t)return r(t);else return e(n)}})}if(!t.cb)t.cb=function e(){};return t}},{events:1,inherits:2}]},{},[])("/")});

@@ -57,3 +57,3 @@ module.exports = IdbKvStore

var db = event.target.result
db.createObjectStore('kv')
db.createObjectStore('kv', {autoIncrement: true})
}

@@ -285,2 +285,3 @@

if (self._closed) throw new Error('Database is closed')
if (typeof value === 'function' || arguments.length === 1) return self.add(undefined, key, value)
var defer = promisify(cb)

@@ -292,3 +293,5 @@

var transaction = self._db.transaction('kv', 'readwrite')
var request = transaction.objectStore('kv').add(value, key)
var request = key == null
? transaction.objectStore('kv').add(value)
: transaction.objectStore('kv').add(value, key)

@@ -342,2 +345,3 @@ request.onsuccess = function (event) {

var err = event.target.error
event.preventDefault()

@@ -344,0 +348,0 @@ if (cb) {

{
"name": "idb-kv-store",
"version": "3.2.1",
"version": "3.3.0",
"description": "Persistent key-value store for web browsers backed by IndexedDB",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -52,6 +52,8 @@ # idb-kv-store [![Build Status](https://travis-ci.org/xuset/idb-kv-store.svg?branch=master)](https://travis-ci.org/xuset/idb-kv-store) [![npm](https://img.shields.io/npm/v/idb-kv-store.svg)](https://npmjs.org/package/idb-kv-store)

### `store.add(key, value, [cb])`
### `store.add([key], value, [cb])`
The same as `store.set(...)` except if the key already exists, an error is returned in the callback.
Additionally, the key is optional. If left empty then an integer key will be automatically generated. Example: `store.add('value')`
### `store.get(key, [cb])`

@@ -58,0 +60,0 @@

@@ -323,2 +323,18 @@ var IdbKvStore = require('.')

test('add() - autoIncremement key', function (t) {
t.timeoutAfter(3000)
var store = createStore()
store.set('foo', 'bar', function (err) {
t.equal(err, null)
store.add('foobar', function (err) {
t.equal(err, null)
store.json(function (err, json) {
t.equal(err, null)
t.deepEqual(json, {1: 'foobar', 'foo': 'bar'})
t.end()
})
})
})
})
function createStore (cb) {

@@ -325,0 +341,0 @@ var name = '' + (Math.round(9e16 * Math.random()))

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc