Socket
Socket
Sign inDemoInstall

idbkeyvalue

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    idbkeyvalue

This npm package provides a simple and efficient key-value storage solution using the IndexedDB API. IndexedDB is a low-level API for client-side storage of significant amounts of structured data. With this package, you can easily open or create an Indexe


Version published
Weekly downloads
8
increased by300%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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';

// Open or create a default database
openDB();

Setting a Key-Value Pair

import { insert } from 'idbkeyvalue';

// Set a key-value pair
insert('exampleKey', 'exampleValue');

Getting a Value by Key

import { get } from 'idbkeyvalue';

// Get the value by key
(async () => {
  const retrievedValue = await get('exampleKey');
  console.log(retrievedValue);
})();

Updating a Value by Key

import { update } from 'idbkeyvalue';

// Update the value by key
update('exampleKey', 'newValue');

Deleting a Key-Value Pair

import { deleteKeyValue } from 'idbkeyvalue';

// Delete the key-value pair
deleteKeyValue('exampleKey');

Set or Update a Key-Value Pair

import { set } from 'idbkeyvalue';

// Set or update a key-value pair
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.

Keywords

FAQs

Last updated on 21 Nov 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc