Socket
Socket
Sign inDemoInstall

@acctglobal/session-storage-client

Package Overview
Dependencies
1
Maintainers
6
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @acctglobal/session-storage-client

Manages the session Storage


Version published
Maintainers
6
Created

Readme

Source

Session Storage Client

This package has the purpose of be a easy way to manage the sessionStorage from the browser considering typings and other validation.

🚀 Getting Started

These instructions will allow you to get a copy of the project running on your local machine for the purposes of Managing the Session Storage Browser with an specific package.

🔧 Installation

To install the @acctglobal/session-storage-client you must run the following command in your project:

 npm i @acctglobal/session-storage-client

🖱️ Usage

in order yo use this package you can follow the example bellow

First you need to instantiate the SessionStorageClient
//Here you import the package and its functionalities
import { SessionStorageClient } from '@acctglobal/session-storage-client'

//Here you define the interface with the data for typing which SessionStorageClient will accept
interface InferfaceExample {
  prop1: string
  prop2: number
}

/*
 * Here we create an instance of the SessionStorageClient sending the interface as class typing
 * and, as parameter, the name of the sessionStorage item you want to deal with;.
 */
const sessionStorageExample = new SessionStorageClient<InferfaceExample>('example')

/*
 * It is possible to create other instances of SessionStorageClient with different typings
 * and attach them with other variables
 */
Here it is the main functions being used
/*
 * "setProperty" - This function sets the value of a property in the sessionStorage
 * according to the key defined when we instantiate the SessionStorageClient.
 * It is important paying attention to the function parameters, 
 * because the first must be a property of the previouly defined interface 
 * and the second must be a type of the property.
 */
sessionStorageExample.setProperty('prop1', 'this is an example')
sessionStorageExample.setProperty('prop2', 2)

/*
 * "getProperty" - This function gets the data from sessionStorage 
 * through the sessionStorageClient.
 * The parameter must be a property of the interface type defined 
 * when instantiating the SessionStorageClient
 * In this case, the parameters could only be "prop1" or "prop2".
 */
    
const variable = sessionStorageExample.getProperty('prop1')
//returns 'this is an example' (setted previously)

/*
 * "resetStorage" - This function resets the item in the sessionStorage Browser
 * and in the instance of the SessionStorageClient.
 */
    
sessionStorageExample.resetStorage()
Parameters
Param nameTypeDescriptionDefault value
sessionStorageKeystringDefines the item in the browser sessionStorage that will be read and changed.none
resetStoragebooleanDefines whether the current sessionStorage item in the browser will be reseted.false
isReadonlybooleanDefines whether the instance of the SessionStorageClient will be able to change the sessionStorage item in the browser or not.false

🛠️ Built with

Mention the tools you used to create your project

  • Typescript

📌 Versioning

We use SemVer for version control. For available versions, note the tags in this repository.

✒️ Authors

Mention all those who helped lift the project from its inception


⌨️ By João Castro 😊

FAQs

Last updated on 10 Feb 2022

Did you know?

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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc