Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@neoprospecta/angular-local-database

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@neoprospecta/angular-local-database

Angular local database

latest
Source
npmnpm
Version
4.0.0
Version published
Weekly downloads
3
50%
Maintainers
1
Weekly downloads
 
Created
Source

Angular Local DataBase for Angular 2+

A service to store content and information into browser's localStorage and/or sessionStorage

How to install:

Have two ways to install angular-local-database inside your project:

  • First way:

    • Install dependence directly from NPM, running this command on terminal in the project' root folder.

      npm install @neoprospecta/angular-local-database --save

  • Second way:

    • Declare angular-local-database as dependence into package.json file.

      "@neoprospecta/angular-local-database":"^4.0.0"

    • Install dependence, running this command on terminal in the project's root folder.

      npm install

How to use:

  • Import LocalDataBaseModule in the project's root module.
import { LocalDataBaseModule } from '@neoprospecta/angular-local-database';

@NgModule({
    ...
  imports: [
    LocalDataBaseModule
  ],
    ...
})
export class AppModule { }
  • Import LocalDataBaseService in project's component that needs to use.
import { LocalDataBaseService } from '@neoprospecta/angular-local-database';

@Component(...)
export class AppComponent {
    ...
  constructor(
    private localDataBaseService: LocalDataBaseService
  ){ }
  ...
}
  • Done, now can use a function from LocalDataBaseService. For example:
this.localDataBaseService.set('key', 'value');

Features

Set data into LocalStorage or SessionStorage

  • Persist into LocalStorage and SessionStorage
/* First way: Omittng 3th parameter */
this.localDataBaseService.set('key', 'value');
/* Second way: Passing 3th parameter */
this.localDataBaseService.set('key', 'value', true);
  • Persist only into SessionStorage. (In this way when the user closes the browser the memory is cleaned).
this.localDataBaseService.set('key', 'value', false);

Get data from SessionStorage or LocalStorage

  • Try to return data from SessionStorage, if hasn't, try to return from LocalStorage, if hasn't return undefined.
this.localDataBaseService.get('key');

Remove data from SessionStorage and/or LocalStorage

  • Try to remove in both SessionStorage and LocalStorage.
this.localDataBaseService.remove('key');

Features Table

FeatureFunction
set(key: string, value: any, persist: boolean = true): boolean
get(key: string): void
remove(key: string): boolean

License

© Neoprospecta | MIT LICENSE

N|Solid

Keywords

Angular

FAQs

Package last updated on 26 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts