Coder Social home page Coder Social logo

chaysen / chrome-storage-ts-utility Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 59 KB

A TypeScript utility for interacting with Chrome's local storage.

Home Page: https://www.npmjs.com/package/chrome-storegae-ts

License: MIT License

JavaScript 0.90% TypeScript 99.10%
chrome-extension chrome-storage chrome-storage-api local-storage typescript

chrome-storage-ts-utility's Introduction

ChromeStorageTS

Node.js CI npm version

A TypeScript utility for interacting with Chrome's local storage in a type-safe manner.

Table of Contents

Installation

npm install chrome-storage-ts --save

Usage

import { ChromeStorageTS } from 'chrome-storage-ts';

const initialStorage = {
  key1: 'value1',
  key2: 'value2',
};

const storageInstance = new ChromeStorageTS(initialStorage, 'local'); // 'local' is the default storage type

// Update a key in the storage
storageInstance.updateStorageKeyValue('key1', 'newValue');

// ... other operations

API

ChromeStorageTS

  • constructor(storage: ChromeStorageObject, storageType: StorageTypes = 'local') Initializes the storage instance with the provided storage object and specifies the type of

  • resetChromeStorage(): Promise Resets the Chrome storage to its initial state by setting all keys to undefined.

  • updateStorageKeyValue(setting: string, value: any): Promise Updates a specific key in the Chrome storage with the provided value.

  • getStorageKeyValue(key: string, cb: Function): Promise Retrieves the value associated with a specific key from the Chrome storage.

  • getStorageKeysValue(keys: Array, cb: Function): Promise Retrieves the values associated with multiple keys from the Chrome storage.

  • addListenerChromeStorageValue(key: string, cb: Function): Promise Adds a listener to detect changes to a specific key in the Chrome storage.

  • addListenerChromeStorageValues(keys: Array, cb: Function): Promise Adds a listener to detect changes to multiple keys in the Chrome storage.

Contributing

  • Fork the repository.
  • Create your feature branch (git checkout -b feature/YourFeature).
  • Commit your changes (git commit -am 'Add some feature').
  • Push to the branch (git push origin feature/YourFeature).
  • Open a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

chrome-storage-ts-utility's People

Contributors

chaysen avatar crathert avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.