Socket
Socket
Sign inDemoInstall

idb-keyval

Package Overview
Dependencies
1
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.1.5 to 6.0.0

dist/compat.cjs

29

package.json
{
"name": "idb-keyval",
"version": "5.1.5",
"version": "6.0.0",
"description": "A super-simple-small keyval store built on top of IndexedDB",
"main": "./dist/cjs-compat/index.js",
"module": "./dist/esm/index.js",
"main": "./dist/compat.cjs",
"module": "./dist/compat.js",
"unpkg": "./dist/iife-compat.js",
"exports": {
".": {
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js"
"module": "./dist/index.js",
"import": "./dist/index.js",
"default": "./dist/index.cjs"
},
"./dist/*": "./dist/*/index.js",
"./dist/*": "./dist/*",
"./package.json": "./package.json"
},
"types": "./dist/esm/index.d.ts",
"files": [
"dist/**"
],
"type": "module",
"types": "./dist/index.d.ts",
"sideEffects": false,
"scripts": {
"build": "rollup -c && node --experimental-modules lib/size-report.mjs",
"dev": "rollup -cw & serve"
"build": "rollup -c && node lib/size-report.js",
"dev": "rollup -cw & serve",
"prepack": "npm run build"
},

@@ -63,3 +70,3 @@ "repository": {

"serve": "^12.0.0",
"typescript": "^4.4.2"
"typescript": "4.3.5"
},

@@ -75,4 +82,4 @@ "husky": {

"dependencies": {
"safari-14-idb-fix": "^1.0.6"
"safari-14-idb-fix": "^2.0.2"
}
}

@@ -7,3 +7,3 @@ # IDB-Keyval

It's small and tree-shakeable. If you only use get/set, the library is ~370 bytes (brotli'd), if you use all methods it's ~560 bytes.
It's small and tree-shakeable. If you only use get/set, the library is ~370 bytes (brotli'd), if you use all methods it's ~570 bytes.

@@ -40,16 +40,20 @@ Although this is tiny, it's a little larger than previous versions due to a [massive bug in Safari](https://bugs.webkit.org/show_bug.cgi?id=226547). Hopefully this fix can be removed in the not-too-distant future, when a version of Safari without the bug reaches enough users.

- `dist/cjs/index.js` CommonJS module.
- `dist/cjs-compat/index.js` CommonJS module, transpiled for older browsers.
- `dist/esm/index.js` EcmaScript module.
- `dist/esm-compat/index.js` EcmaScript module, transpiled for older browsers.
- `dist/iife/index-min.js` Minified plain JS, which creates an `idbKeyval` global containing all methods.
- `dist/iife-compat/index-min.js` As above, but transpiled for older browsers.
A well-behaved bundler should automatically pick the ES module or the CJS module depending on what it supports, but if you need to force it either way:
- `idb-keyval/dist/index.js` EcmaScript module.
- `idb-keyval/dist/index.cjs` CommonJS module.
Legacy builds:
- `idb-keyval/dist/compat.js` EcmaScript module, transpiled for older browsers.
- `idb-keyval/dist/compat.cjs` CommonJS module, transpiled for older browsers.
- `idb-keyval/dist/umd.cjs` UMD module, also transpiled for older browsers.
These built versions are also available on jsDelivr, e.g.:
```html
<script src="https://cdn.jsdelivr.net/npm/idb-keyval@5/dist/iife/index-min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/idb-keyval@6/dist/umd.cjs"></script>
<!-- Or in modern browsers: -->
<script type="module">
import { get, set } from 'https://cdn.jsdelivr.net/npm/idb-keyval@5/+esm';
import { get, set } from 'https://cdn.jsdelivr.net/npm/idb-keyval@6/+esm';
</script>

@@ -171,2 +175,20 @@ ```

### delMany:
Delete many keys at once. This is faster than calling `del` multiple times.
```js
import { del, delMany } from 'idb-keyval';
// Instead of:
Promise.all([del(123), del('hello')])
.then(() => console.log('It worked!'))
.catch((err) => console.log('It failed!', err));
// It's faster to do:
delMany([123, 'hello'])
.then(() => console.log('It worked!'))
.catch((err) => console.log('It failed!', err));
```
### clear:

@@ -218,51 +240,1 @@

By default, the methods above use an IndexedDB database named `keyval-store` and an object store named `keyval`. If you want to use something different, see [custom stores](./custom-stores.md).
## Updating
### Updating from 3.x
The changes between 3.x and 5.x related to custom stores.
(4.x was abandoned due to a Safari bug)
Old way:
```js
// This no longer works in 4.x
import { Store, set } from 'idb-keyval';
const customStore = new Store('custom-db-name', 'custom-store-name');
set('foo', 'bar', customStore);
```
New way:
```js
import { createStore, set } from 'idb-keyval';
const customStore = createStore('custom-db-name', 'custom-store-name');
set('foo', 'bar', customStore);
```
For more details, see [custom stores](./custom-stores.md).
### Updating from 2.x
2.x exported an object with methods:
```js
// This no longer works in 3.x
import idbKeyval from 'idb-keyval';
idbKeyval.set('foo', 'bar');
```
Whereas in 3.x you import the methods directly:
```js
import { set } from 'idb-keyval';
set('foo', 'bar');
```
This is better for minification, and allows tree shaking.
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc