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

idb-wrapper

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

idb-wrapper - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

.idea/codeStyleSettings.xml

2

component.json

@@ -5,4 +5,4 @@ {

"main": "idbstore.js",
"version": "1.2.0",
"version": "1.3.0",
"dependencies": {}
}

@@ -1,3 +0,2 @@

/*jshint expr:true */
/*global window:false, console:false, define:false, module:false */
/*global window:false, self:false, define:false, module:false */

@@ -22,4 +21,8 @@ /**

"use strict";
'use strict';
var defaultErrorHandler = function (error) {
throw error;
};
var defaults = {

@@ -33,5 +36,3 @@ storeName: 'Store',

},
onError: function(error){
throw error;
},
onError: defaultErrorHandler,
indexes: []

@@ -110,5 +111,10 @@ };

this.idb = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB;
this.keyRange = window.IDBKeyRange || window.webkitIDBKeyRange || window.mozIDBKeyRange;
var env = typeof window == 'object' ? window : self;
this.idb = env.indexedDB || env.webkitIndexedDB || env.mozIndexedDB;
this.keyRange = env.IDBKeyRange || env.webkitIDBKeyRange || env.mozIDBKeyRange;
this.features = {
hasAutoIncrement: !env.mozIndexedDB
};
this.consts = {

@@ -134,3 +140,3 @@ 'READ_ONLY': 'readonly',

*/
version: '1.2.0',
version: '1.3.0',

@@ -240,5 +246,2 @@ /**

var features = this.features = {};
features.hasAutoIncrement = !window.mozIndexedDB;
var openRequest = this.idb.open(this.dbName, this.dbVersion);

@@ -251,3 +254,3 @@ var preventSuccessCallback = false;

if ('error' in error.target) {
gotVersionErr = error.target.error.name == "VersionError";
gotVersionErr = error.target.error.name == 'VersionError';
} else if ('errorCode' in error.target) {

@@ -411,5 +414,3 @@ gotVersionErr = error.target.errorCode == 12;

}
onError || (onError = function (error) {
console.error('Could not write data.', error);
});
onError || (onError = defaultErrorHandler);
onSuccess || (onSuccess = noop);

@@ -453,5 +454,3 @@

get: function (key, onSuccess, onError) {
onError || (onError = function (error) {
console.error('Could not read data.', error);
});
onError || (onError = defaultErrorHandler);
onSuccess || (onSuccess = noop);

@@ -487,5 +486,3 @@

remove: function (key, onSuccess, onError) {
onError || (onError = function (error) {
console.error('Could not remove data.', error);
});
onError || (onError = defaultErrorHandler);
onSuccess || (onSuccess = noop);

@@ -523,5 +520,3 @@

batch: function (dataArray, onSuccess, onError) {
onError || (onError = function (error) {
console.error('Could not apply batch.', error);
});
onError || (onError = defaultErrorHandler);
onSuccess || (onSuccess = noop);

@@ -565,7 +560,7 @@

if (type == "remove") {
if (type == 'remove') {
var deleteRequest = batchTransaction.objectStore(this.storeName)['delete'](key);
deleteRequest.onsuccess = onItemSuccess;
deleteRequest.onerror = onItemError;
} else if (type == "put") {
} else if (type == 'put') {
var putRequest;

@@ -585,2 +580,37 @@ if (this.keyPath !== null) { // in-line keys

/**
* Takes an array of objects and stores them in a single transaction.
*
* @param {Array} dataArray An array of objects to store
* @param {Function} [onSuccess] A callback that is called if all operations
* were successful.
* @param {Function} [onError] A callback that is called if an error
* occurred during one of the operations.
*/
putBatch: function (dataArray, onSuccess, onError) {
var batchData = dataArray.map(function(item){
return { type: 'put', value: item };
});
this.batch(batchData, onSuccess, onError);
},
/**
* Takes an array of keys and removes matching objects in a single
* transaction.
*
* @param {Array} keyArray An array of keys to remove
* @param {Function} [onSuccess] A callback that is called if all operations
* were successful.
* @param {Function} [onError] A callback that is called if an error
* occurred during one of the operations.
*/
removeBatch: function (keyArray, onSuccess, onError) {
var batchData = keyArray.map(function(key){
return { type: 'remove', key: key };
});
this.batch(batchData, onSuccess, onError);
},
/**
* Fetches all entries in the store.

@@ -594,5 +624,3 @@ *

getAll: function (onSuccess, onError) {
onError || (onError = function (error) {
console.error('Could not read data.', error);
});
onError || (onError = defaultErrorHandler);
onSuccess || (onSuccess = noop);

@@ -687,5 +715,3 @@ var getAllTransaction = this.db.transaction([this.storeName], this.consts.READ_ONLY);

clear: function (onSuccess, onError) {
onError || (onError = function (error) {
console.error('Could not clear store.', error);
});
onError || (onError = defaultErrorHandler);
onSuccess || (onSuccess = noop);

@@ -804,3 +830,3 @@

* iteration has ended
* @param {Function} [options.onError=console.error] A callback to be called
* @param {Function} [options.onError=throw] A callback to be called
* if an error occurred during the operation.

@@ -817,5 +843,3 @@ */

onEnd: null,
onError: function (error) {
console.error('Could not open cursor.', error);
}
onError: defaultErrorHandler
}, options || {});

@@ -877,3 +901,3 @@

* @param {Object} [options.keyRange=null] An IDBKeyRange to use
* @param {Function} [options.onError=console.error] A callback to be called if an error
* @param {Function} [options.onError=throw] A callback to be called if an error
* occurred during the operation.

@@ -902,3 +926,3 @@ */

* @param {Object} [options.keyRange=null] An IDBKeyRange to use
* @param {Function} [options.onError=console.error] A callback to be called if an error
* @param {Function} [options.onError=throw] A callback to be called if an error
* occurred during the operation.

@@ -913,5 +937,3 @@ */

var onError = options.onError || function (error) {
console.error('Could not open cursor.', error);
};
var onError = options.onError || defaultErrorHandler;

@@ -918,0 +940,0 @@ var hasSuccess = false,

@@ -8,18 +8,18 @@ /*

*/
(function(j,h,i){"function"===typeof define?define(h):"undefined"!==typeof module&&module.exports?module.exports=h():i[j]=h()})("IDBStore",function(){var j={storeName:"Store",storePrefix:"IDBWrapper-",dbVersion:1,keyPath:"id",autoIncrement:!0,onStoreReady:function(){},onError:function(a){throw a;},indexes:[]},h=function(a,c){for(var b in j)this[b]="undefined"!=typeof a[b]?a[b]:j[b];this.dbName=this.storePrefix+this.storeName;this.dbVersion=parseInt(this.dbVersion,10);c&&(this.onStoreReady=c);this.idb=
window.indexedDB||window.webkitIndexedDB||window.mozIndexedDB;this.keyRange=window.IDBKeyRange||window.webkitIDBKeyRange||window.mozIDBKeyRange;this.consts={READ_ONLY:"readonly",READ_WRITE:"readwrite",VERSION_CHANGE:"versionchange",NEXT:"next",NEXT_NO_DUPLICATE:"nextunique",PREV:"prev",PREV_NO_DUPLICATE:"prevunique"};this.openDB()};h.prototype={version:"1.2.0",db:null,dbName:null,dbVersion:null,store:null,storeName:null,keyPath:null,autoIncrement:null,indexes:null,features:null,onStoreReady:null,
onError:null,_insertIdCount:0,openDB:function(){(this.features={}).hasAutoIncrement=!window.mozIndexedDB;var a=this.idb.open(this.dbName,this.dbVersion),c=!1;a.onerror=function(a){var c=!1;"error"in a.target?c="VersionError"==a.target.error.name:"errorCode"in a.target&&(c=12==a.target.errorCode);if(c)this.onError(Error("The version number provided is lower than the existing one."));else this.onError(a)}.bind(this);a.onsuccess=function(a){if(!c)if(this.db)this.onStoreReady();else if(this.db=a.target.result,
"string"==typeof this.db.version)this.onError(Error("The IndexedDB implementation in this browser is outdated. Please upgrade your browser."));else if(this.db.objectStoreNames.contains(this.storeName))this.store=this.db.transaction([this.storeName],this.consts.READ_ONLY).objectStore(this.storeName),this.indexes.forEach(function(a){var b=a.name;b?(this.normalizeIndexData(a),this.hasIndex(b)?this.indexComplies(this.store.index(b),a)||(c=!0,this.onError(Error('Cannot modify index "'+b+'" for current version. Please bump version number to '+
(this.dbVersion+1)+"."))):(c=!0,this.onError(Error('Cannot create new index "'+b+'" for current version. Please bump version number to '+(this.dbVersion+1)+".")))):(c=!0,this.onError(Error("Cannot create index: No index name given.")))},this),c||this.onStoreReady();else this.onError(Error("Something is wrong with the IndexedDB implementation in this browser. Please upgrade your browser."))}.bind(this);a.onupgradeneeded=function(a){this.db=a.target.result;this.store=this.db.objectStoreNames.contains(this.storeName)?
a.target.transaction.objectStore(this.storeName):this.db.createObjectStore(this.storeName,{keyPath:this.keyPath,autoIncrement:this.autoIncrement});this.indexes.forEach(function(a){var b=a.name;b||(c=!0,this.onError(Error("Cannot create index: No index name given.")));this.normalizeIndexData(a);this.hasIndex(b)?this.indexComplies(this.store.index(b),a)||(this.store.deleteIndex(b),this.store.createIndex(b,a.keyPath,{unique:a.unique,multiEntry:a.multiEntry})):this.store.createIndex(b,a.keyPath,{unique:a.unique,
multiEntry:a.multiEntry})},this)}.bind(this)},deleteDatabase:function(){this.idb.deleteDatabase&&this.idb.deleteDatabase(this.dbName)},put:function(a,c,b,d){null!==this.keyPath&&(d=b,b=c,c=a);d||(d=function(a){console.error("Could not write data.",a)});b||(b=i);var f=!1,e=null,g=this.db.transaction([this.storeName],this.consts.READ_WRITE);g.oncomplete=function(){(f?b:d)(e)};g.onabort=d;g.onerror=d;null!==this.keyPath?(this._addIdPropertyIfNeeded(c),a=g.objectStore(this.storeName).put(c)):a=g.objectStore(this.storeName).put(c,
a);a.onsuccess=function(a){f=!0;e=a.target.result};a.onerror=d},get:function(a,c,b){b||(b=function(a){console.error("Could not read data.",a)});c||(c=i);var d=!1,f=null,e=this.db.transaction([this.storeName],this.consts.READ_ONLY);e.oncomplete=function(){(d?c:b)(f)};e.onabort=b;e.onerror=b;a=e.objectStore(this.storeName).get(a);a.onsuccess=function(a){d=!0;f=a.target.result};a.onerror=b},remove:function(a,c,b){b||(b=function(a){console.error("Could not remove data.",a)});c||(c=i);var d=!1,f=null,
e=this.db.transaction([this.storeName],this.consts.READ_WRITE);e.oncomplete=function(){(d?c:b)(f)};e.onabort=b;e.onerror=b;a=e.objectStore(this.storeName)["delete"](a);a.onsuccess=function(a){d=!0;f=a.target.result};a.onerror=b},batch:function(a,c,b){b||(b=function(a){console.error("Could not apply batch.",a)});c||(c=i);"[object Array]"!=Object.prototype.toString.call(a)&&b(Error("dataArray argument must be of type Array."));var d=this.db.transaction([this.storeName],this.consts.READ_WRITE);d.oncomplete=
function(){(g?c:b)(g)};d.onabort=b;d.onerror=b;var f=a.length,e=!1,g=!1,h=function(){f--;0===f&&!e&&(g=e=!0)};a.forEach(function(a){var c=a.type,f=a.key,g=a.value,a=function(a){d.abort();e||(e=!0,b(a,c,f))};if("remove"==c)g=d.objectStore(this.storeName)["delete"](f),g.onsuccess=h,g.onerror=a;else if("put"==c)null!==this.keyPath?(this._addIdPropertyIfNeeded(g),g=d.objectStore(this.storeName).put(g)):g=d.objectStore(this.storeName).put(g,f),g.onsuccess=h,g.onerror=a},this)},getAll:function(a,c){c||
(c=function(a){console.error("Could not read data.",a)});a||(a=i);var b=this.db.transaction([this.storeName],this.consts.READ_ONLY),d=b.objectStore(this.storeName);d.getAll?this._getAllNative(b,d,a,c):this._getAllCursor(b,d,a,c)},_getAllNative:function(a,c,b,d){var f=!1,e=null;a.oncomplete=function(){(f?b:d)(e)};a.onabort=d;a.onerror=d;a=c.getAll();a.onsuccess=function(a){f=!0;e=a.target.result};a.onerror=d},_getAllCursor:function(a,c,b,d){var f=[],e=!1,g=null;a.oncomplete=function(){(e?b:d)(g)};
a.onabort=d;a.onerror=d;a=c.openCursor();a.onsuccess=function(a){(a=a.target.result)?(f.push(a.value),a["continue"]()):(e=!0,g=f)};a.onError=d},clear:function(a,c){c||(c=function(a){console.error("Could not clear store.",a)});a||(a=i);var b=!1,d=null,f=this.db.transaction([this.storeName],this.consts.READ_WRITE);f.oncomplete=function(){(b?a:c)(d)};f.onabort=c;f.onerror=c;f=f.objectStore(this.storeName).clear();f.onsuccess=function(a){b=!0;d=a.target.result};f.onerror=c},_addIdPropertyIfNeeded:function(a){!this.features.hasAutoIncrement&&
"undefined"==typeof a[this.keyPath]&&(a[this.keyPath]=this._insertIdCount++ +Date.now())},getIndexList:function(){return this.store.indexNames},hasIndex:function(a){return this.store.indexNames.contains(a)},normalizeIndexData:function(a){a.keyPath=a.keyPath||a.name;a.unique=!!a.unique;a.multiEntry=!!a.multiEntry},indexComplies:function(a,c){return["keyPath","unique","multiEntry"].every(function(b){return"multiEntry"==b&&void 0===a[b]&&!1===c[b]?!0:c[b]==a[b]})},iterate:function(a,c){var c=k({index:null,
order:"ASC",autoContinue:!0,filterDuplicates:!1,keyRange:null,writeAccess:!1,onEnd:null,onError:function(a){console.error("Could not open cursor.",a)}},c||{}),b="desc"==c.order.toLowerCase()?"PREV":"NEXT";c.filterDuplicates&&(b+="_NO_DUPLICATE");var d=!1,f=this.db.transaction([this.storeName],this.consts[c.writeAccess?"READ_WRITE":"READ_ONLY"]),e=f.objectStore(this.storeName);c.index&&(e=e.index(c.index));f.oncomplete=function(){if(d)if(c.onEnd)c.onEnd();else a(null);else c.onError(null)};f.onabort=
c.onError;f.onerror=c.onError;b=e.openCursor(c.keyRange,this.consts[b]);b.onerror=c.onError;b.onsuccess=function(b){if(b=b.target.result){if(a(b.value,b,f),c.autoContinue)b["continue"]()}else d=!0}},query:function(a,c){var b=[],c=c||{};c.onEnd=function(){a(b)};this.iterate(function(a){b.push(a)},c)},count:function(a,c){var c=k({index:null,keyRange:null},c||{}),b=c.onError||function(a){console.error("Could not open cursor.",a)},d=!1,f=null,e=this.db.transaction([this.storeName],this.consts.READ_ONLY);
e.oncomplete=function(){(d?a:b)(f)};e.onabort=b;e.onerror=b;e=e.objectStore(this.storeName);c.index&&(e=e.index(c.index));e=e.count(c.keyRange);e.onsuccess=function(a){d=!0;f=a.target.result};e.onError=b},makeKeyRange:function(a){var c="undefined"!=typeof a.lower,b="undefined"!=typeof a.upper;switch(!0){case c&&b:a=this.keyRange.bound(a.lower,a.upper,a.excludeLower,a.excludeUpper);break;case c:a=this.keyRange.lowerBound(a.lower,a.excludeLower);break;case b:a=this.keyRange.upperBound(a.upper,a.excludeUpper);
break;default:throw Error('Cannot create KeyRange. Provide one or both of "lower" or "upper" value.');}return a}};var i=function(){},l={},k=function(a,c){var b,d;for(b in c)d=c[b],d!==l[b]&&d!==a[b]&&(a[b]=d);return a};h.version=h.prototype.version;return h},this);
(function(h,i,j){"function"===typeof define?define(i):"undefined"!==typeof module&&module.exports?module.exports=i():j[h]=i()})("IDBStore",function(){var h=function(a){throw a;},i={storeName:"Store",storePrefix:"IDBWrapper-",dbVersion:1,keyPath:"id",autoIncrement:!0,onStoreReady:function(){},onError:h,indexes:[]},j=function(a,c){for(var b in i)this[b]="undefined"!=typeof a[b]?a[b]:i[b];this.dbName=this.storePrefix+this.storeName;this.dbVersion=parseInt(this.dbVersion,10);c&&(this.onStoreReady=c);
b="object"==typeof window?window:self;this.idb=b.indexedDB||b.webkitIndexedDB||b.mozIndexedDB;this.keyRange=b.IDBKeyRange||b.webkitIDBKeyRange||b.mozIDBKeyRange;this.features={hasAutoIncrement:!b.mozIndexedDB};this.consts={READ_ONLY:"readonly",READ_WRITE:"readwrite",VERSION_CHANGE:"versionchange",NEXT:"next",NEXT_NO_DUPLICATE:"nextunique",PREV:"prev",PREV_NO_DUPLICATE:"prevunique"};this.openDB()};j.prototype={version:"1.3.0",db:null,dbName:null,dbVersion:null,store:null,storeName:null,keyPath:null,
autoIncrement:null,indexes:null,features:null,onStoreReady:null,onError:null,_insertIdCount:0,openDB:function(){var a=this.idb.open(this.dbName,this.dbVersion),c=!1;a.onerror=function(a){var c=!1;"error"in a.target?c="VersionError"==a.target.error.name:"errorCode"in a.target&&(c=12==a.target.errorCode);if(c)this.onError(Error("The version number provided is lower than the existing one."));else this.onError(a)}.bind(this);a.onsuccess=function(a){if(!c)if(this.db)this.onStoreReady();else if(this.db=
a.target.result,"string"==typeof this.db.version)this.onError(Error("The IndexedDB implementation in this browser is outdated. Please upgrade your browser."));else if(this.db.objectStoreNames.contains(this.storeName))this.store=this.db.transaction([this.storeName],this.consts.READ_ONLY).objectStore(this.storeName),this.indexes.forEach(function(a){var b=a.name;b?(this.normalizeIndexData(a),this.hasIndex(b)?this.indexComplies(this.store.index(b),a)||(c=!0,this.onError(Error('Cannot modify index "'+
b+'" for current version. Please bump version number to '+(this.dbVersion+1)+"."))):(c=!0,this.onError(Error('Cannot create new index "'+b+'" for current version. Please bump version number to '+(this.dbVersion+1)+".")))):(c=!0,this.onError(Error("Cannot create index: No index name given.")))},this),c||this.onStoreReady();else this.onError(Error("Something is wrong with the IndexedDB implementation in this browser. Please upgrade your browser."))}.bind(this);a.onupgradeneeded=function(a){this.db=
a.target.result;this.store=this.db.objectStoreNames.contains(this.storeName)?a.target.transaction.objectStore(this.storeName):this.db.createObjectStore(this.storeName,{keyPath:this.keyPath,autoIncrement:this.autoIncrement});this.indexes.forEach(function(a){var b=a.name;b||(c=!0,this.onError(Error("Cannot create index: No index name given.")));this.normalizeIndexData(a);this.hasIndex(b)?this.indexComplies(this.store.index(b),a)||(this.store.deleteIndex(b),this.store.createIndex(b,a.keyPath,{unique:a.unique,
multiEntry:a.multiEntry})):this.store.createIndex(b,a.keyPath,{unique:a.unique,multiEntry:a.multiEntry})},this)}.bind(this)},deleteDatabase:function(){this.idb.deleteDatabase&&this.idb.deleteDatabase(this.dbName)},put:function(a,c,b,d){null!==this.keyPath&&(d=b,b=c,c=a);d||(d=h);b||(b=k);var f=!1,e=null,g=this.db.transaction([this.storeName],this.consts.READ_WRITE);g.oncomplete=function(){(f?b:d)(e)};g.onabort=d;g.onerror=d;null!==this.keyPath?(this._addIdPropertyIfNeeded(c),a=g.objectStore(this.storeName).put(c)):
a=g.objectStore(this.storeName).put(c,a);a.onsuccess=function(a){f=!0;e=a.target.result};a.onerror=d},get:function(a,c,b){b||(b=h);c||(c=k);var d=!1,f=null,e=this.db.transaction([this.storeName],this.consts.READ_ONLY);e.oncomplete=function(){(d?c:b)(f)};e.onabort=b;e.onerror=b;a=e.objectStore(this.storeName).get(a);a.onsuccess=function(a){d=!0;f=a.target.result};a.onerror=b},remove:function(a,c,b){b||(b=h);c||(c=k);var d=!1,f=null,e=this.db.transaction([this.storeName],this.consts.READ_WRITE);e.oncomplete=
function(){(d?c:b)(f)};e.onabort=b;e.onerror=b;a=e.objectStore(this.storeName)["delete"](a);a.onsuccess=function(a){d=!0;f=a.target.result};a.onerror=b},batch:function(a,c,b){b||(b=h);c||(c=k);"[object Array]"!=Object.prototype.toString.call(a)&&b(Error("dataArray argument must be of type Array."));var d=this.db.transaction([this.storeName],this.consts.READ_WRITE);d.oncomplete=function(){(g?c:b)(g)};d.onabort=b;d.onerror=b;var f=a.length,e=!1,g=!1,l=function(){f--;0===f&&!e&&(g=e=!0)};a.forEach(function(a){var c=
a.type,f=a.key,g=a.value,a=function(a){d.abort();e||(e=!0,b(a,c,f))};if("remove"==c)g=d.objectStore(this.storeName)["delete"](f),g.onsuccess=l,g.onerror=a;else if("put"==c)null!==this.keyPath?(this._addIdPropertyIfNeeded(g),g=d.objectStore(this.storeName).put(g)):g=d.objectStore(this.storeName).put(g,f),g.onsuccess=l,g.onerror=a},this)},putBatch:function(a,c,b){this.batch(a.map(function(a){return{type:"put",value:a}}),c,b)},removeBatch:function(a,c,b){this.batch(a.map(function(a){return{type:"remove",
key:a}}),c,b)},getAll:function(a,c){c||(c=h);a||(a=k);var b=this.db.transaction([this.storeName],this.consts.READ_ONLY),d=b.objectStore(this.storeName);d.getAll?this._getAllNative(b,d,a,c):this._getAllCursor(b,d,a,c)},_getAllNative:function(a,c,b,d){var f=!1,e=null;a.oncomplete=function(){(f?b:d)(e)};a.onabort=d;a.onerror=d;a=c.getAll();a.onsuccess=function(a){f=!0;e=a.target.result};a.onerror=d},_getAllCursor:function(a,c,b,d){var f=[],e=!1,g=null;a.oncomplete=function(){(e?b:d)(g)};a.onabort=d;
a.onerror=d;a=c.openCursor();a.onsuccess=function(a){(a=a.target.result)?(f.push(a.value),a["continue"]()):(e=!0,g=f)};a.onError=d},clear:function(a,c){c||(c=h);a||(a=k);var b=!1,d=null,f=this.db.transaction([this.storeName],this.consts.READ_WRITE);f.oncomplete=function(){(b?a:c)(d)};f.onabort=c;f.onerror=c;f=f.objectStore(this.storeName).clear();f.onsuccess=function(a){b=!0;d=a.target.result};f.onerror=c},_addIdPropertyIfNeeded:function(a){!this.features.hasAutoIncrement&&"undefined"==typeof a[this.keyPath]&&
(a[this.keyPath]=this._insertIdCount++ +Date.now())},getIndexList:function(){return this.store.indexNames},hasIndex:function(a){return this.store.indexNames.contains(a)},normalizeIndexData:function(a){a.keyPath=a.keyPath||a.name;a.unique=!!a.unique;a.multiEntry=!!a.multiEntry},indexComplies:function(a,c){return["keyPath","unique","multiEntry"].every(function(b){return"multiEntry"==b&&void 0===a[b]&&!1===c[b]?!0:c[b]==a[b]})},iterate:function(a,c){var c=m({index:null,order:"ASC",autoContinue:!0,filterDuplicates:!1,
keyRange:null,writeAccess:!1,onEnd:null,onError:h},c||{}),b="desc"==c.order.toLowerCase()?"PREV":"NEXT";c.filterDuplicates&&(b+="_NO_DUPLICATE");var d=!1,f=this.db.transaction([this.storeName],this.consts[c.writeAccess?"READ_WRITE":"READ_ONLY"]),e=f.objectStore(this.storeName);c.index&&(e=e.index(c.index));f.oncomplete=function(){if(d)if(c.onEnd)c.onEnd();else a(null);else c.onError(null)};f.onabort=c.onError;f.onerror=c.onError;b=e.openCursor(c.keyRange,this.consts[b]);b.onerror=c.onError;b.onsuccess=
function(b){if(b=b.target.result){if(a(b.value,b,f),c.autoContinue)b["continue"]()}else d=!0}},query:function(a,c){var b=[],c=c||{};c.onEnd=function(){a(b)};this.iterate(function(a){b.push(a)},c)},count:function(a,c){var c=m({index:null,keyRange:null},c||{}),b=c.onError||h,d=!1,f=null,e=this.db.transaction([this.storeName],this.consts.READ_ONLY);e.oncomplete=function(){(d?a:b)(f)};e.onabort=b;e.onerror=b;e=e.objectStore(this.storeName);c.index&&(e=e.index(c.index));e=e.count(c.keyRange);e.onsuccess=
function(a){d=!0;f=a.target.result};e.onError=b},makeKeyRange:function(a){var c="undefined"!=typeof a.lower,b="undefined"!=typeof a.upper;switch(!0){case c&&b:a=this.keyRange.bound(a.lower,a.upper,a.excludeLower,a.excludeUpper);break;case c:a=this.keyRange.lowerBound(a.lower,a.excludeLower);break;case b:a=this.keyRange.upperBound(a.upper,a.excludeUpper);break;default:throw Error('Cannot create KeyRange. Provide one or both of "lower" or "upper" value.');}return a}};var k=function(){},n={},m=function(a,
c){var b,d;for(b in c)d=c[b],d!==n[b]&&d!==a[b]&&(a[b]=d);return a};j.version=j.prototype.version;return j},this);
{
"name": "idb-wrapper",
"version": "1.2.0",
"version": "1.3.0",
"description": "A cross-browser wrapper for IndexedDB",

@@ -5,0 +5,0 @@ "keywords": [],

@@ -7,3 +7,3 @@ About

a) ease the use of indexedDB and abstract away the differences between the
existing impls in Chrome, Firefox and IE10 (yes, it works in all three), and
existing impls in Chrome, Firefox, IE10 and Opera 15 (yes, it works in all four), and

@@ -49,7 +49,7 @@ b) show how IDB works. The code is split up into short methods, so that it's

IDBWrapper is also available on cdnjs, so you can directly point a script tag
there, or require() it from there. The URL is:
IDBWrapper is also available on [cdnjs](http://cdnjs.com/), so you can directly point a script tag there, or require()
it from there. cdnjs supports http, https and spdy, so you can just leave the protocol off. The URL is:
```
//cdnjs.cloudflare.com/ajax/libs/idbwrapper/1.1.0/idbstore.min.js
//cdnjs.cloudflare.com/ajax/libs/idbwrapper/1.2.0/idbstore.min.js
```

@@ -292,3 +292,27 @@

___
7) The putBatch method.
```javascript
putBatch: function (/*Array*/dataArray, /*Function?*/onSuccess, /*Function?*/onError)
```
`putBatch` takes an array of objects and stores them in a single transaction.
___
8) The removeBatch method.
```javascript
removeBatch: function (/*Array*/keyArray, /*Function?*/onSuccess, /*Function?*/onError)
```
`removeBatch` takes an array of keys and removes matching objects in a single transaction.
Index Operations

@@ -295,0 +319,0 @@ ----------------

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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