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 4.2.0 to 4.3.0

57

index.js

@@ -7,2 +7,3 @@ /* eslint-env browser */

var inherits = require('inherits')
var promisize = require('promisize')

@@ -118,4 +119,4 @@ var global = typeof window === 'undefined' ? self : window

IdbKvStore.prototype.count = function (cb) {
return this.transaction('readonly').count(cb)
IdbKvStore.prototype.count = function (range, cb) {
return this.transaction('readonly').count(range, cb)
}

@@ -212,3 +213,3 @@

if (key == null || value == null) throw new Error('A key and value must be given')
cb = promisify(cb)
cb = promisize(cb)

@@ -245,3 +246,3 @@ self._getObjectStore(function (err, objectStore) {

if (value == null) throw new Error('A value must be provided as an argument')
cb = promisify(cb)
cb = promisize(cb)

@@ -276,3 +277,3 @@ self._getObjectStore(function (err, objectStore) {

if (key == null) throw new Error('A key must be given as an argument')
cb = promisify(cb)
cb = promisize(cb)

@@ -300,3 +301,3 @@ self._getObjectStore(function (err, objectStore) {

if (typeof range === 'function') return self.json(null, range)
cb = promisify(cb)
cb = promisize(cb)

@@ -320,3 +321,3 @@ var json = {}

if (typeof range === 'function') return self.keys(null, range)
cb = promisify(cb)
cb = promisize(cb)

@@ -340,3 +341,3 @@ var keys = []

if (typeof range === 'function') return self.values(null, range)
cb = promisify(cb)
cb = promisize(cb)

@@ -360,3 +361,3 @@ var values = []

if (key == null) throw new Error('A key must be given as an argument')
cb = promisify(cb)
cb = promisize(cb)

@@ -389,3 +390,3 @@ self._getObjectStore(function (err, objectStore) {

var self = this
cb = promisify(cb)
cb = promisize(cb)

@@ -410,5 +411,6 @@ self._getObjectStore(function (err, objectStore) {

Transaction.prototype.count = function (cb) {
Transaction.prototype.count = function (range, cb) {
var self = this
cb = promisify(cb)
if (typeof range === 'function') return self.count(null, range)
cb = promisize(cb)

@@ -419,3 +421,3 @@ self._getObjectStore(function (err, objectStore) {

try {
var request = objectStore.count()
var request = range == null ? objectStore.count() : objectStore.count(range)
} catch (e) {

@@ -481,30 +483,1 @@ return cb(e)

}
function promisify (cb) {
var promise
var res
var rej
if (cb != null && typeof cb !== 'function') throw new Error('cb must be a function')
if (cb == null && typeof Promise !== 'undefined') {
promise = new Promise(function (resolve, reject) {
res = resolve
rej = reject
})
}
function intercept (err, result) {
if (promise) {
if (err) rej(err)
else res(result)
} else {
if (cb) cb(err, result)
else if (err) throw err
}
}
intercept.promise = promise
return intercept
}
{
"name": "idb-kv-store",
"version": "4.2.0",
"version": "4.3.0",
"description": "Persistent key-value store for web browsers backed by IndexedDB",

@@ -46,4 +46,5 @@ "main": "index.js",

"dependencies": {
"inherits": "^2.0.3"
"inherits": "^2.0.3",
"promisize": "^1.1.1"
}
}

@@ -113,6 +113,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.count([cb])`
### `store.count([range], [cb])`
Retrieves the number of entries in the store, and calls `cb(err, count)` upon retrieval. `err` is null if the count was successful, in which case `count` will hold the value. If `cb` is undefined, then a promise is returned.
To only count the number of entries in a specific range, an [IDBKeyRange](https://developer.mozilla.org/en-US/docs/Web/API/IDBKeyRange) can be passed into `range`
### `store.iterator([range], function (err, cursor) {})`

@@ -119,0 +121,0 @@

@@ -608,3 +608,3 @@ /* eslint-env browser */

test('ranged keys(), values(), and json()', function (t) {
test('ranged keys(), values(), json(), and count()', function (t) {
t.timeoutAfter(3000)

@@ -630,3 +630,7 @@

t.deepEqual(keys, [1, 2])
t.end()
store.count(IDBKeyRange.only(2), function (err, count) {
t.equal(err, null)
t.equal(count, 1)
t.end()
})
})

@@ -633,0 +637,0 @@ })

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