idb-keyval
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -1,1 +0,1 @@ | ||
!function(){"use strict";function e(){return t||(t=new Promise(function(e,n){var t=indexedDB.open("keyval-store",1);t.onerror=function(){n(t.error)},t.onupgradeneeded=function(){t.result.createObjectStore("keyval")},t.onsuccess=function(){e(t.result)}})),t}function n(n,t){return e().then(function(e){return new Promise(function(r,o){var u=e.transaction("keyval",n);u.oncomplete=function(){r()},u.onerror=function(){o(u.error)},t(u.objectStore("keyval"))})})}var t,r={get:function(e){var t;return n("readonly",function(n){t=n.get(e)}).then(function(){return t.result})},set:function(e,t){return n("readwrite",function(n){n.put(t,e)})},delete:function(e){return n("readwrite",function(n){n.delete(e)})},clear:function(){return n("readwrite",function(e){e.clear()})}};"undefined"!=typeof module&&module.exports?module.exports=r:self.idbKeyval=r}(); | ||
!function(){"use strict";function e(){return t||(t=new Promise(function(e,n){var t=indexedDB.open("keyval-store",1);t.onerror=function(){n(t.error)},t.onupgradeneeded=function(){t.result.createObjectStore("keyval")},t.onsuccess=function(){e(t.result)}})),t}function n(n,t){return e().then(function(e){return new Promise(function(r,o){var u=e.transaction("keyval",n);u.oncomplete=function(){r()},u.onerror=function(){o(u.error)},t(u.objectStore("keyval"))})})}var t,r={get:function(e){var t;return n("readonly",function(n){t=n.get(e)}).then(function(){return t.result})},set:function(e,t){return n("readwrite",function(n){n.put(t,e)})},delete:function(e){return n("readwrite",function(n){n.delete(e)})},clear:function(){return n("readwrite",function(e){e.clear()})},keys:function(){var e=[];return n("readonly",function(n){(n.openKeyCursor||n.openCursor).call(n).onsuccess=function(){this.result&&(e.push(this.result.key),this.result.continue())}}).then(function(){return e})}};"undefined"!=typeof module&&module.exports?module.exports=r:self.idbKeyval=r}(); |
@@ -65,2 +65,16 @@ (function() { | ||
}); | ||
}, | ||
keys: function() { | ||
var keys = []; | ||
return withStore('readonly', function(store) { | ||
// This would be store.getAllKeys(), but it isn't supported by Edge or Safari. | ||
// And openKeyCursor isn't supported by Safari. | ||
(store.openKeyCursor || store.openCursor).call(store).onsuccess = function() { | ||
if (!this.result) return; | ||
keys.push(this.result.key); | ||
this.result.continue(); | ||
}; | ||
}).then(function() { | ||
return keys; | ||
}); | ||
} | ||
@@ -67,0 +81,0 @@ }; |
{ | ||
"name": "idb-keyval", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "A super-simple-small keyval store built on top of IndexedDB", | ||
@@ -5,0 +5,0 @@ "main": "idb-keyval.js", |
@@ -9,6 +9,7 @@ # IDB-Keyval | ||
### Setting: | ||
### set: | ||
```js | ||
idbKeyval.set('hello', 'world'); | ||
idbKeyval.set('foo', 'bar'); | ||
``` | ||
@@ -24,3 +25,3 @@ | ||
### Getting: | ||
### get: | ||
@@ -32,9 +33,16 @@ ```js | ||
### Deleting: | ||
### keys: | ||
```js | ||
// logs: ["hello", "foo"] | ||
idbKeyval.get('hello').then(keys => console.log(keys)); | ||
``` | ||
### delete: | ||
```js | ||
idbKeyval.delete('hello'); | ||
``` | ||
### Clearing: | ||
### clear: | ||
@@ -41,0 +49,0 @@ ```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
5760
79
50