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

ng7-storage

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng7-storage - npm Package Compare versions

Comparing version 1.1.4 to 1.1.5

ng7-storage-1.1.5.tgz

8

package.json
{
"name": "ng7-storage",
"version": "1.1.4",
"description": "Store data in browser in more secure way using browser Session",
"version": "1.1.5",
"description": "Share Data among multiple components in angular using browser session storage",
"keywords": [
"Angular",
"Library",
"ng-storage",
"ng7-storage",
"cookielss",
"Storage",

@@ -9,0 +11,0 @@ "browser Storage",

# ng-storage
![Build](https://github.com/edisonaugusthy/ng-storage/workflows/Node.js%20CI/badge.svg)![Publish](https://github.com/edisonaugusthy/ng-storage/workflows/NPM%20Publish/badge.svg)
A better way to store data in browser without cookies,
Share Data among multiple components in angular using browser session storage
NB:we relies on session and data wont get cleared on refresh but tab close will clear all data
see [Stackblitz Demo](https://stackblitz.com/edit/ng-storage-sample) here
Angular compatibility
| Angular Version | package version
| ------------- |:-------------:|
| angular 8 and below | 1.1.4 and below |
| angular 9 and above(ivy version)| 1.1.5 and above|
## Usage
- Run `npm i ng-storage --save` to add module to project
- Add `import { StorageModule } from 'ng7-storage';` in App Module
- Add to imports
```
imports: [
## Usage steps
- Run `npm i ng-storage --save` in command prompt from root of your project folder
- Add import to App Module like this `import { StorageModule } from 'ng7-storage';`
- Add to imports array in app module
```imports: [
BrowserModule,

@@ -19,15 +25,18 @@ StorageModule

- Then import service `import { NgStorageService } from 'ng7-storage';`
- Then Initialize in constructor
- Then import NgStorageService service `import { NgStorageService } from 'ng7-storage';` in the components that you would like to use
- Then Initialize StorageService in the component constructor
```
constructor(private StorageService: NgStorageService) {
}
```
follow below methods to set and retrieve data to storage
##### Setting Data
Please note that we have to pass key value pairs to service , and key should be string and do not pass value as json string
`this.StorageService.setData({ key: 'key_of_data', value: res ,encrypt:optional|boolean})`
Pass key value pairs to store data , and key should be valid string
NB: data format that accepted by `setData` method is

@@ -42,10 +51,15 @@

NB:`encrypt` is a development onprogress feature and may have issues when setting data that has special characters
#### Getting Data
Use `getData` method to retrieve data, and it intake key as argument
eg:`this.StorageService.getData({key: 'key_of_data',decrypt:optional|boolean})`
Use `getData` method to retrieve data, pass `key` of the item
#### Remove Data
For removing data, we can either remove by a single key or we can remove all data at once
- `removeData` method is used remove single item based on key

@@ -60,7 +74,7 @@ - `removeAll` method remove all data stored

#### Available methods
setData()
getData()
removeData()
removeAll()
#### All Available methods
- `setData()`
- `getData()`
- `removeData()`
- `removeAll()`

@@ -71,3 +85,3 @@ ## Browsers support

| --------- | --------- | --------- | --------- |
| IE11, Edge| last 8 versions| last 8 versions| last 2 versions
| IE11, Edge| last 8 versions| last 8 versions| last 5 versions

@@ -77,9 +91,4 @@

* Angular
* HTML - For the web framework
* CSS - For styling components
* JavaScript - For magic!
* Angular - To add to the JavaScript magic!
## Developing 👷

@@ -86,0 +95,0 @@

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