Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tableflip/mem-storage-area
A WebExtension like StorageArea in memory
https://github.com/tableflip/mem-storage-area
memory persistence storage webextension webextension-api
Last synced: about 8 hours ago
JSON representation
A WebExtension like StorageArea in memory
- Host: GitHub
- URL: https://github.com/tableflip/mem-storage-area
- Owner: tableflip
- License: mit
- Created: 2018-01-22T22:25:09.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-25T11:02:24.000Z (almost 7 years ago)
- Last Synced: 2024-12-21T12:36:46.080Z (2 days ago)
- Topics: memory, persistence, storage, webextension, webextension-api
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/mem-storage-area
- Size: 211 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mem-storage-area
[![Build Status](https://travis-ci.org/tableflip/mem-storage-area.svg?branch=master)](https://travis-ci.org/tableflip/mem-storage-area)
[![dependencies Status](https://david-dm.org/tableflip/mem-storage-area/status.svg)](https://david-dm.org/tableflip/mem-storage-area)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)> A WebExtension like StorageArea in memory
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/storage
For testing and whatever.
## Install
```sh
npm install mem-storage-area
```## Usage
```js
const storage = require('mem-storage-area')storage.onChanged.addListener((changes, areaName) => {
console.log(`storage.${areaName} changed: ${changes}`)
})await storage.local.set({ foo: 'bar' })
console.log(await storage.local.get('foo')) // { foo: 'bar' }
// also storage.sync and read-only storage.managed
```### Advanced
You can access the Storage, StorageArea and Emitter objects:
```js
// If you need another storage - { local, sync, managed, onChanged }
const Storage = require('mem-storage-area/Storage')
const storage = new Storage()// If you need an emitter
const Emitter = require('mem-storage-area/Emitter')
const onChanged = new Emitter()
// onChanged.addListener, onChanged.removeListener, onChanged.hasListener etc.
// To emit, call onChanged(arg0, arg1...)// If you need a storage area (with optional emitter)
const StorageArea = require('mem-storage-area/StorageArea')
const area = new StorageArea({ name: 'myArea', onChanged, readOnly: false })
```## API
See [MDN storage API docs](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/storage)
## Contribute
Feel free to dive in! [Open an issue](https://github.com/tableflip/mem-storage-area/issues/new) or submit PRs.
## License
[MIT](LICENSE) © Alan Shaw