Skip to content

Aims at (naïvely) exporting a consistent API between Web Extensions and localStorage

License

Notifications You must be signed in to change notification settings

HitFox/check-storage

Repository files navigation

check-storage

This is a tiny module that tries to figure out what storage adaptor it should use, sorting between localStorage and chrome.storage.sync (the equivalent WebExtension API).

Usage

import { storage } from 'check-storage';

console.log(storage.type);
try {
  storage.add(key, value);
  storage.get(key);
  storage.remove(key);
} catch {
  console.log('storage not initialised. Maybe the env has neither API?')
}

About

Aims at (naïvely) exporting a consistent API between Web Extensions and localStorage

Resources

License

Stars

Watchers

Forks

Packages

No packages published