https://github.com/32teeth/storage.js
JavaScript abstraction of localStorage
https://github.com/32teeth/storage.js
Last synced: about 1 year ago
JSON representation
JavaScript abstraction of localStorage
- Host: GitHub
- URL: https://github.com/32teeth/storage.js
- Owner: 32teeth
- Created: 2014-10-17T17:05:44.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2024-09-30T12:38:09.000Z (over 1 year ago)
- Last Synced: 2025-03-20T15:22:41.507Z (about 1 year ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 27
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# storage.js
> [!TIP]
> We've created a new secure [safe-encrypted-storage](https://github.com/npm-packages-collection/safe-encrypted-storage) npm package, you should migrate
**storage.js** is a simple abstraction of the browser *localStorage API*
## design pattern
**storage.js** is built on a module reveal pattern exposing three (3) core methods.
* data()
* remove()
* clear()
## usage
### data()
the *data* method can be called as a setter or getter
#### *data()* as a setter
```
/*
@param property {string} string name of property
@param value {string|number|object|function|array|json} value of named property
@description creates (if non existant property) or sets value to existing property
@description value can be anything (string, number, object, function, array)
*/
data(property, value)
```
#### *data()* as a getter
```
/*
@param property {string} string name of property to return value of
@return value of named property, false if not found
*/
data(property)
```
### remove()
```
/*
@param property {string} string name of property to remove from storage
*/
remove(property)
```
### clear()
```
/*
@description clears localStorage object completely. good for ending sessions.
*/
clear()
```