{"name":"idb-keyval","version":"6.2.0","description":"A super-simple-small keyval store built on top of IndexedDB","main":"./dist/compat.cjs","module":"./dist/compat.js","unpkg":"./dist/iife-compat.js","exports":{".":{"types":"./dist/index.d.ts","module":"./dist/index.js","import":"./dist/index.js","default":"./dist/index.cjs"},"./dist/*":"./dist/*","./package.json":"./package.json"},"type":"module","types":"./dist/index.d.ts","sideEffects":false,"scripts":{"build":"rollup -c && node lib/size-report.js","dev":"rollup -cw & serve","prepack":"npm run build"},"repository":{"type":"git","url":"git+https://github.com/jakearchibald/idb-keyval.git"},"keywords":["idb","indexeddb","store","keyval","localstorage","storage","promise"],"author":{"name":"Jake Archibald"},"license":"Apache-2.0","bugs":{"url":"https://github.com/jakearchibald/idb-keyval/issues"},"homepage":"https://github.com/jakearchibald/idb-keyval#readme","devDependencies":{"@babel/core":"^7.18.5","@babel/plugin-external-helpers":"^7.17.12","@babel/plugin-transform-runtime":"^7.18.5","@babel/preset-env":"^7.18.2","@babel/runtime":"^7.18.3","@rollup/plugin-babel":"^5.3.1","@rollup/plugin-commonjs":"^22.0.0","@rollup/plugin-node-resolve":"^13.3.0","@types/chai":"^4.3.1","@types/mocha":"^9.1.1","chai":"^4.3.6","conditional-type-checks":"^1.0.6","del":"^6.1.1","filesize":"^9.0.9","glob":"^8.0.3","husky":"^8.0.1","lint-staged":"^13.0.2","mocha":"^10.0.0","prettier":"^2.7.1","rollup":"^2.75.7","rollup-plugin-terser":"^7.0.2","serve":"^13.0.2","typescript":"^4.7.4"},"husky":{"hooks":{"pre-commit":"lint-staged"}},"lint-staged":{"*.{js,css,md,ts,html}":"prettier --write"},"dependencies":{"safari-14-idb-fix":"^3.0.0"},"gitHead":"a7225849d1d9a57ac6615b3fd0aadd07178f6a08","_id":"idb-keyval@6.2.0","_nodeVersion":"16.15.0","_npmVersion":"8.9.0","dist":{"integrity":"sha512-uw+MIyQn2jl3+hroD7hF8J7PUviBU7BPKWw4f/ISf32D4LoGu98yHjrzWWJDASu9QNrX10tCJqk9YY0ClWm8Ng==","shasum":"3af94a3cc0689d6ee0bc9e045d2a3340ea897173","tarball":"http://registry-npm.ywwl.com/idb-keyval/download/idb-keyval-6.2.0.tgz","fileCount":12,"unpackedSize":53864,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFd1kSFyc7bgn5PhzX0akSU5mbWEbukaMRYzq3vFInWlAiApbeDTpRJwrf5JiLrKnfC+/tpevOh6oOJUdV+9zKPcNQ=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJisFieACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpBLRAAoslH0Db51SoNBdDt2ZsVB8LKok9uX9ZiVRgbYpmF3CcIMoZJ\r\nUPS4cFYrfiNHTXr9nY7mxQk3o0vFSzaxS7lz3cEjQ0hmWfXEb9w+FUp3Hy1T\r\nffEB1JmuXro8C9eauo5znIxQtXpaCszEtAnUr0+lZoDBcT47aWM3ooCpKyyY\r\nCHpDGA8tkeS3ZEwACTalr86c+SbwauN9i1PzuUaIq6fQXYuoc0W4kVaONz4+\r\ngYqpU4TxKRf33Vq03tysao6CkLb+tNpim9/8WgPsq9YZF946062hzGMITzys\r\n0XSBreiQaG6O0i+D/Nn3BxaH7xxmkx3+4d/MQUigwgdof1H9ZtFdgSEYUOUw\r\nh7m4z2uVPUmGFcUS9ueI2+4REY+3PMz6nqktFaSNt7xiQhWmCGw1HKxAb6Vx\r\nVfASC/U9Tq3Tee4E7yHFhUlmRgJJWkMPpDXrbNBxb5t9ydX1vuQaI71PuFyn\r\nznHbvEWcE3mvLnSlRldld1ZLMlxjVPD1/sgmfS5w8kXUxDMkOsY3fAeub+wE\r\n8Ym4g10TvUjqGaRmqfkP4RC1th5pNqfYMgbAQhsv+BnDVo6Zyz94na3x8GAO\r\nZqRfubEmmPKTpP8qBC//d5syP09ySBPRt2aYlKi7KhNJcgjyiVPKunpHNlNx\r\nvLwj4nnt78uY82Rs7bo3C6JpN4e1Mt4lJJo=\r\n=6Y5a\r\n-----END PGP SIGNATURE-----\r\n","size":8005,"noattachment":false,"key":"/idb-keyval/-/idb-keyval-6.2.0.tgz"},"_npmUser":{"name":"jaffathecake","email":"jaffathecake@gmail.com"},"directories":{},"maintainers":[{"name":"jaffathecake","email":"jaffathecake@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/idb-keyval_6.2.0_1655724190325_0.3311220032572042"},"_hasShrinkwrap":false,"readme":"# IDB-Keyval\n\n[![npm](https://img.shields.io/npm/v/idb-keyval.svg)](https://www.npmjs.com/package/idb-keyval)\n\nThis is a super-simple promise-based keyval store implemented with IndexedDB, originally based on [async-storage by Mozilla](https://github.com/mozilla-b2g/gaia/blob/master/shared/js/async_storage.js).\n\nIt's small and tree-shakeable. If you only use get/set, the library is ~250 bytes (brotli'd), if you use all methods it's ~534 bytes.\n\n[localForage](https://github.com/localForage/localForage) offers similar functionality, but supports older browsers with broken/absent IDB implementations. Because of that, it's orders of magnitude bigger (~7k).\n\nThis is only a keyval store. If you need to do more complex things like iteration & indexing, check out [IDB on NPM](https://www.npmjs.com/package/idb) (a little heavier at 1k). The first example in its README is how to create a keyval store.\n\n## Installing\n\n### Recommended: Via npm + webpack/rollup/parcel/etc\n\n```sh\nnpm install idb-keyval\n```\n\nNow you can require/import `idb-keyval`:\n\n```js\nimport { get, set } from 'idb-keyval';\n```\n\nIf you're targeting IE10/11, use the compat version, and import a `Promise` polyfill.\n\n```js\n// Import a Promise polyfill\nimport 'es6-promise/auto';\nimport { get, set } from 'idb-keyval/dist/esm-compat';\n```\n\n### All bundles\n\nA 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:\n\n- `idb-keyval/dist/index.js` EcmaScript module.\n- `idb-keyval/dist/index.cjs` CommonJS module.\n\nLegacy builds:\n\n- `idb-keyval/dist/compat.js` EcmaScript module, transpiled for older browsers.\n- `idb-keyval/dist/compat.cjs` CommonJS module, transpiled for older browsers.\n- `idb-keyval/dist/umd.js` UMD module, also transpiled for older browsers.\n\nThese built versions are also available on jsDelivr, e.g.:\n\n```html\n<script src=\"https://cdn.jsdelivr.net/npm/idb-keyval@6/dist/umd.js\"></script>\n<!-- Or in modern browsers: -->\n<script type=\"module\">\n  import { get, set } from 'https://cdn.jsdelivr.net/npm/idb-keyval@6/+esm';\n</script>\n```\n\n## Usage\n\n### set:\n\n```js\nimport { set } from 'idb-keyval';\n\nset('hello', 'world');\n```\n\nSince this is IDB-backed, you can store anything structured-clonable (numbers, arrays, objects, dates, blobs etc), although old Edge doesn't support `null`. Keys can be numbers, strings, `Date`s, (IDB also allows arrays of those values, but IE doesn't support it).\n\nAll methods return promises:\n\n```js\nimport { set } from 'idb-keyval';\n\nset('hello', 'world')\n  .then(() => console.log('It worked!'))\n  .catch((err) => console.log('It failed!', err));\n```\n\n### get:\n\n```js\nimport { get } from 'idb-keyval';\n\n// logs: \"world\"\nget('hello').then((val) => console.log(val));\n```\n\nIf there is no 'hello' key, then `val` will be `undefined`.\n\n### setMany:\n\nSet many keyval pairs at once. This is faster than calling `set` multiple times.\n\n```js\nimport { set, setMany } from 'idb-keyval';\n\n// Instead of:\nPromise.all([set(123, 456), set('hello', 'world')])\n  .then(() => console.log('It worked!'))\n  .catch((err) => console.log('It failed!', err));\n\n// It's faster to do:\nsetMany([\n  [123, 456],\n  ['hello', 'world'],\n])\n  .then(() => console.log('It worked!'))\n  .catch((err) => console.log('It failed!', err));\n```\n\nThis operation is also atomic – if one of the pairs can't be added, none will be added.\n\n### getMany:\n\nGet many keys at once. This is faster than calling `get` multiple times. Resolves with an array of values.\n\n```js\nimport { get, getMany } from 'idb-keyval';\n\n// Instead of:\nPromise.all([get(123), get('hello')]).then(([firstVal, secondVal]) =>\n  console.log(firstVal, secondVal),\n);\n\n// It's faster to do:\ngetMany([123, 'hello']).then(([firstVal, secondVal]) =>\n  console.log(firstVal, secondVal),\n);\n```\n\n### update:\n\nTransforming a value (eg incrementing a number) using `get` and `set` is risky, as both `get` and `set` are async and non-atomic:\n\n```js\n// Don't do this:\nimport { get, set } from 'idb-keyval';\n\nget('counter').then((val) =>\n  set('counter', (val || 0) + 1);\n);\n\nget('counter').then((val) =>\n  set('counter', (val || 0) + 1);\n);\n```\n\nWith the above, both `get` operations will complete first, each returning `undefined`, then each set operation will be setting `1`. You could fix the above by queuing the second `get` on the first `set`, but that isn't always feasible across multiple pieces of code. Instead:\n\n```js\n// Instead:\nimport { update } from 'idb-keyval';\n\nupdate('counter', (val) => (val || 0) + 1);\nupdate('counter', (val) => (val || 0) + 1);\n```\n\nThis will queue the updates automatically, so the first `update` set the `counter` to `1`, and the second `update` sets it to `2`.\n\n### del:\n\nDelete a particular key from the store.\n\n```js\nimport { del } from 'idb-keyval';\n\ndel('hello');\n```\n\n### delMany:\n\nDelete many keys at once. This is faster than calling `del` multiple times.\n\n```js\nimport { del, delMany } from 'idb-keyval';\n\n// Instead of:\nPromise.all([del(123), del('hello')])\n  .then(() => console.log('It worked!'))\n  .catch((err) => console.log('It failed!', err));\n\n// It's faster to do:\ndelMany([123, 'hello'])\n  .then(() => console.log('It worked!'))\n  .catch((err) => console.log('It failed!', err));\n```\n\n### clear:\n\nClear all values in the store.\n\n```js\nimport { clear } from 'idb-keyval';\n\nclear();\n```\n\n### entries:\n\nGet all entries in the store. Each entry is an array of `[key, value]`.\n\n```js\nimport { entries } from 'idb-keyval';\n\n// logs: [[123, 456], ['hello', 'world']]\nentries().then((entries) => console.log(entries));\n```\n\n### keys:\n\nGet all keys in the store.\n\n```js\nimport { keys } from 'idb-keyval';\n\n// logs: [123, 'hello']\nkeys().then((keys) => console.log(keys));\n```\n\n### values:\n\nGet all values in the store.\n\n```js\nimport { values } from 'idb-keyval';\n\n// logs: [456, 'world']\nvalues().then((values) => console.log(values));\n```\n\n### Custom stores:\n\nBy 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).\n","publish_time":1655724190496,"_cnpm_publish_time":1655724190496,"dist-tags":{"latest":"6.3.0","next":"6.0.0"}}