Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

js-storage-manager

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-storage-manager - npm Package Compare versions

Comparing version 0.0.15 to 0.0.16

6

CHANGELOG.md
# Changelog
## v0.0.15 (17/03/2019)
#### New:
* Add CHANGELOG.md to repository
---
## v0.0.1 (17/03/2019)

@@ -4,0 +10,0 @@ #### New:

2

package.json
{
"name": "js-storage-manager",
"version": "0.0.15",
"version": "0.0.16",
"description": "A library to store data within the web storage.",

@@ -5,0 +5,0 @@ "scripts": {

# Javascript Storage Manager
A library that makes the [WebStorage](https://en.wikipedia.org/wiki/Web_storage) easy to use: `localStorage` and `sessionStorage` (`sessionStorage` in progress).
A library that makes the [WebStorage](https://en.wikipedia.org/wiki/Web_storage) easy to use: `localStorage`, `sessionStorage` and `Cookies` (`sessionStorage` and `Cookies` are in progress: [#2](/../../issues/2), [#3](/../../issues/3)).

@@ -237,2 +237,142 @@ ![npm](https://img.shields.io/npm/v/js-storage-manager.svg) ![NPM](https://img.shields.io/npm/l/js-storage-manager.svg) ![npm bundle size](https://img.shields.io/bundlephobia/min/js-storage-manager.svg)

## The next steps
### How to use the StorageManager in the easiest way
```javascript
var sm = new StorageManager('namespace');
var data_initial = [{id: 1, name: 'Name 1'}, {id: 2, name: 'Name 2'}];
/* save data_initial to localStorage.storage.namespace.data */
sm.set('data', data_initial);
var data_from_web_storage = sm.get('data');
```
### How to use multiple namespaces
```javascript
var namespace_1 = 'namespace1';
var namespace_2 = 'namespace2';
var sm_1 = new StorageManager(namespace_1);
var sm_2 = new StorageManager(namespace_2);
var data_initial_1 = [{id: 1, name: 'Name 1'}, {id: 2, name: 'Name 2'}];
var data_initial_2 = [{id: 3, name: 'Name 3'}, {id: 4, name: 'Name 4'}];
/* save data_initial to localStorage.storage.namespace1.data */
sm.set('data', data_initial_1);
/* save data_initial to localStorage.storage.namespace2.data */
sm.set('data', data_initial_2);
var data_from_web_storage_1 = sm_1.get('data');
var data_from_web_storage_2 = sm_2.get('data');
```
### How to manage the storage yourself
```javascript
var sm = new StorageManager('namespace');
var data_initial = [{id: 1, name: 'Name 1'}, {id: 2, name: 'Name 2'}];
/* Get the storage data object. */
var storage = sm.getStorage();
/* Do something with the data object. */
storage.data = data_initial;
/* Manually save the data object in WebStorage. */
sm.setStorage(storage)
```
### How the StorageManager saves changes to the storage itself
```javascript
var sm = new StorageManager('namespace');
var data_initial = [{id: 1, name: 'Name 1'}, {id: 2, name: 'Name 2'}];
var observable = true; // <- important
/* The returned storage data object is now of type "Proxy". */
var storage = sm.getStorage(observable);
/* Do something with the data object. */
storage.data = data_initial;
/* sm.setStorage(storage) is no longer needed. Changes are automatically saved in WebStorage. */
```
### How to create and use a queue list
Attention: This area is under revision. See [#1](/../../issues/1)
```javascript
var sm = new StorageManager('namespace');
var queue_data_1 = {[id: 1, name: 'Name 1']};
var queue_data_2 = {[id: 2, name: 'Name 2']};
/* Initialize the queue (optionally) */
sm.initQueue();
/* Add records to the queue. The queue namespace used is 'queue'. */
sm.pushQueue(queue_data_1);
sm.pushQueue(queue_data_2);
/* Get the number of queue items. */
var number_of_queue_items = sm.getNumberOfQueuesItems();
/* Read the entire queue */
var queue = sm.getQueue();
/* Get the next queue item (FIFO) */
var next_queue_item = sm.getNextQueueItem();
/* Get the next queue entry and delete it. */
var next_queue_item = ms.deleteNextQueueItem();
```
### How to use your own queue namespace
Attention: This area is under revision. See [#1](/../../issues/1)
```javascript
var sm = new StorageManager('namespace');
var queue_data_1 = {[id: 1, name: 'Name 1']};
var queue_data_2 = {[id: 2, name: 'Name 2']};
var my_queue_namespace = 'my_queue'
/* Initialize the queue (optionally) */
sm.initQueue(my_queue_namespace);
/* Add records to the queue. The queue namespace used is now 'my_queue'. */
sm.pushQueue(queue_data_1, my_queue_namespace);
sm.pushQueue(queue_data_2, my_queue_namespace);
/* Get the number of queue items. */
var number_of_queue_items = sm.getNumberOfQueuesItems(my_queue_namespace);
/* Read the entire queue */
var queue = sm.getQueue(my_queue_namespace);
/* Get the next queue item (FIFO) */
var next_queue_item = sm.getNextQueueItem(my_queue_namespace);
/* Get the next queue entry and delete it. */
var next_queue_item = sm.deleteNextQueueItem(my_queue_namespace);
```
### How to get the LocalStorage area completely managed by the StorageManager
```javascript
var sm = new StorageManager('namespace');
/* Returns the LocalStorage area as a ready-parsed object. */
var local_storage_managed_by_sm = sm.getLocalStorage();
```
&nbsp;
&nbsp;
## Maintenance

@@ -292,3 +432,3 @@

8. Publish on npm
8. Publish to npm

@@ -299,3 +439,22 @@ ```bash

9. Create Release
```bash
$ gren release
```
Adapt the changelog text to github if necessary: [changelog](https://github.com/bjoern-hempel/js-storage-manager/releases). Show all commits:
```bash
$ git log --oneline --decorate
```
10. Update [CHANGELOG.md](/CHANGELOG.md)
```bash
$ gren changelog --override
```
&nbsp;

@@ -302,0 +461,0 @@ &nbsp;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc