idbkeyvalue
idbkeyvalue is a lightweight npm package that simplifies key-value storage using the IndexedDB API. It provides an easy-to-use interface for common operations like setting, getting, updating, and deleting key-value pairs, making it a convenient solution for client-side storage in web applications.
Installation
To install the package, use npm:
npm install idbkeyvalue
Usage
Using the CDN
You can include the idbkeyvalue library directly in your HTML file using the following CDN URL:
<!-- Include the idbkeyvalue library from jsDelivr CDN -->
<script src="https://cdn.jsdelivr.net/npm/idbkeyvalue@1.0.2/keyvalue.js"></script>
Opening or Creating a Database
import { openDB } from 'idbkeyvalue';
openDB();
Setting a Key-Value Pair
import { insert } from 'idbkeyvalue';
insert('exampleKey', 'exampleValue');
Getting a Value by Key
import { get } from 'idbkeyvalue';
(async () => {
const retrievedValue = await get('exampleKey');
console.log(retrievedValue);
})();
Updating a Value by Key
import { update } from 'idbkeyvalue';
update('exampleKey', 'newValue');
Deleting a Key-Value Pair
import { deleteKeyValue } from 'idbkeyvalue';
deleteKeyValue('exampleKey');
Set or Update a Key-Value Pair
import { set } from 'idbkeyvalue';
set('exampleKey', 'exampleValue');
Contributing
We welcome contributions! Feel free to open an issue or submit a pull request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Feel free to customize the README file based on your specific needs and additional information you'd like to include.