https://github.com/jibrelnetwork/jwallet-web-storage
Web Storage (API) polyfill
https://github.com/jibrelnetwork/jwallet-web-storage
Last synced: over 1 year ago
JSON representation
Web Storage (API) polyfill
- Host: GitHub
- URL: https://github.com/jibrelnetwork/jwallet-web-storage
- Owner: jibrelnetwork
- License: mit
- Created: 2017-10-01T12:54:59.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2022-02-28T08:38:25.000Z (over 4 years ago)
- Last Synced: 2025-03-15T07:37:43.015Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 74.2 KB
- Stars: 5
- Watchers: 9
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jwallet-web-storage
Web Storage (API) polyfill. Using following storages in order of priority: localStorage -> cookie -> memory
## Get Started
```
npm install jwallet-web-storage
```
```javascript
const storage = require('jwallet-web-storage')
```
## API
The (Web Storage API)[https://html.spec.whatwg.org/multipage/webstorage.html] provides mechanisms by which browsers can store key/value pairs.
### setItem(key, value)
Adds `key` to the storage, or updates that `key`'s `value` if it already exists.
#### Examples
```javascript
storage.setItem('Key', 'Value')
const objectStorageValue = { foo: 'bar' }
storage.setItem('AnotherKey', JSON.stringify(objectStorageValue))
```
### getItem(key)
Returns that `key`'s value.
#### Examples
```javascript
storage.getItem('Key') //> Value
JSON.parse(storage.getItem('AnotherKey')) //> { foo: 'bar' }
```
### removeItem(key)
Removes `key` from the storage.
```javascript
storage.removeItem('Key')
storage.removeItem('AnotherKey')
```