Socket
Socket
Sign inDemoInstall

webext-storage

Package Overview
Dependencies
1
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    webext-storage

A more usable typed storage API for Web Extensions


Version published
Weekly downloads
340
decreased by-19.24%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

webext-storage

A more usable typed storage API for Web Extensions

  • Browsers: Chrome, Firefox, and Safari
  • Manifest: v2 and v3
  • Permissions: storage or unlimitedStorage
  • Context: They can be called from any context

Sponsored by PixieBrix :tada:

Install

npm install webext-storage

Or download the standalone bundle to include in your manifest.json.

Usage

import {StorageItem} from "webext-storage";

const username = new StorageItem<string>('username')
// Or
const username = new StorageItem('username', {defaultValue: 'admin'})

await username.set('Ugo');
// Promise<void>

await username.get();
// Promise<string>

await username.remove();
// Promise<void>

await username.set({name: 'Ugo'});
// TypeScript Error: Argument of type '{ name: string; }' is not assignable to parameter of type 'string'.

username.onChange(newName => {
	console.log('The user’s new name is', newName);
});

License

MIT © Federico Brigante

Keywords

FAQs

Last updated on 28 Oct 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