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.6 to 1.1.9

esm2022/lib/storage.service.mjs

4

lib/storage.service.d.ts

@@ -0,1 +1,2 @@

import * as i0 from "@angular/core";
export interface dataFormat {

@@ -8,2 +9,3 @@ key?: string;

export declare class NgStorageService {
private message;
constructor();

@@ -14,2 +16,4 @@ setData(data: dataFormat): boolean;

removeAll(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<NgStorageService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<NgStorageService>;
}

24

package.json
{
"name": "ng7-storage",
"version": "1.1.6",
"version": "1.1.9",
"description": "Share Data among multiple components in angular using browser session storage",

@@ -25,10 +25,16 @@ "keywords": [

},
"main": "bundles/ng7-storage.umd.js",
"module": "fesm2015/ng7-storage.js",
"es2015": "fesm2015/ng7-storage.js",
"esm2015": "esm2015/ng7-storage.js",
"fesm2015": "fesm2015/ng7-storage.js",
"typings": "ng7-storage.d.ts",
"metadata": "ng7-storage.metadata.json",
"module": "fesm2022/ng7-storage.mjs",
"typings": "index.d.ts",
"exports": {
"./package.json": {
"default": "./package.json"
},
".": {
"types": "./index.d.ts",
"esm2022": "./esm2022/ng7-storage.mjs",
"esm": "./esm2022/ng7-storage.mjs",
"default": "./fesm2022/ng7-storage.mjs"
}
},
"sideEffects": false
}
}

@@ -1,3 +0,1 @@

export * from './lib/storage.service';
export * from './lib/storage.component';
export * from './lib/storage.module';
export * from "./lib/storage.service";

@@ -1,54 +0,59 @@

# ng-storage
# ng7-storage
Share Data among multiple components in angular using browser session storage
see [Stackblitz Demo](https://stackblitz.com/edit/ng-storage-sample) here
see [Stackblitz Demo](https://stackblitz.com/edit/ng-storage-sample) here
More on [Github](https://github.com/edisonaugusthy/ng-storage)
Angular compatibility
| Angular Version | package version |
| Angular Version | package version |
| -------------------------------- | :-------------: |
| angular 8 and below | 1.1.4 and below |
| angular 8 and below | 1.1.4 and below |
| angular 9 and above(ivy version) | 1.1.5 and above |
| angular 10 and above|1.1.8 and above |
| angular 14 and above|1.1.9 and above |
## 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
```ts
imports: [
BrowserModule,
StorageModule
],
```
- Run `npm i ng7-storage --save`
- Add to providers array in app module
```ts
providers: [
NgStorageService
],
```
- 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
```ts
constructor(private StorageService: NgStorageService) {
- Then Initialize `NgStorageService` in the component constructor
}
```
```ts
constructor(private ngStorage: NgStorageService) {
}
```
follow below methods to set and retrieve data to storage
##### Setting Data
```ts
this.StorageService.setData({ key: 'key_of_data', value: res ,encrypt:optional|boolean})
```
this.ngStorage.setData({ key: "key", value: "data", encrypt: boolean });
```
>Pass key value pairs to store data , and key should be valid string
> Pass key value pairs to store data , and key should be valid string
NB: data format that accepted by `setData` method is
NB: data format that accepted by `setData` method is
```ts
export interface dataFormat {
key: string;
value?: any;
encrypt?: Boolean;
decrypt?: Boolean;
}
```
export interface IsetData {
key: string;
value?: any;
encrypt?: Boolean;
decrypt?: Boolean;
}
```
NB:`encrypt` is a development onprogress feature and may have issues when setting data that has special characters
NB:_`encrypt` is a development onprogress feature and may have issues when setting data that has special characters_

@@ -58,48 +63,31 @@ #### Getting Data

eg:
```js
this.StorageService.getData({key: 'key_of_data',decrypt:optional|boolean})
```
>Use `getData` method to retrieve data, pass `key` of the item
```js
this.ngStorage.getData({ key: "key", decrypt?: boolean });
```
> Use `getData` method to retrieve data, pass `key` of the item. pass `decrypt` as `true` if you have encrypted the data
#### Remove Data
For removing data, we can either remove by a single key or we can remove all data at once
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
- `removeAll` method remove all data stored
- `removeData` method is used remove single item based on key
- `removeAll` method remove all data stored
Examples :
Examples :
removeData : `this.StorageService.removeData('key_of_data')`
removeData : `this.ngStorage.removeData('key')`
removeAll : `this.StorageService.removeAll()`
removeAll : `this.ngStorage.removeAll()`
#### All Available methods
```ts
setData()
getData()
removeData()
removeAll()
```
setData();
getData();
removeData();
removeAll();
```
## Browsers support
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/vivaldi/vivaldi_48x48.png" alt="Vivaldi" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Vivaldi |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| IE11, Edge | last 8 versions | last 8 versions | last 5 versions |
## Built with 🔧
* Angular
## Developing 👷
1. [Clone this repo](https://github.com/edisonaugusthy/ng-storage.git) with git.
1. Install dependencies by running `npm install` within the directory that you cloned (probably `ng-storage`).
1. Start the development server with `ng serve --o`.
1. Open development site by going to [http://localhost:4200](http://localhost:4200) in your browser.
## Author 🔮

@@ -106,0 +94,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