JSPM

@analytics/session-storage-utils

0.0.9
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 194874
  • Score
    100M100P100Q172174F
  • License MIT

Tiny SessionStorage utility library

Package Exports

  • @analytics/session-storage-utils
  • @analytics/session-storage-utils/dist/analytics-util-session-storage.js
  • @analytics/session-storage-utils/dist/analytics-util-session-storage.module.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@analytics/session-storage-utils) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

SessionStorage Utilities

A tiny sessionStorage utility library with fallbacks in 239 bytes.

This module will automatically fail back to global window storage if sessionStorage is not available.

Exposes hasSessionStorage, getItem, setItem, & removeItem functions.

See live demo.

How to install

Install @analytics/session-storage-utils from npm.

npm install @analytics/session-storage-utils

API

Below is the api for @analytics/session-storage-utils. These utilities are tree-shakable.

hasSessionStorage

Check if sessionStorage is supported

import { hasSessionStorage } from '@analytics/session-storage-utils'

if (hasSessionStorage()) {
  // Use session storage 
}

getSessionItem

Get a sessionStorage value.

import { getSessionItem } from '@analytics/session-storage-utils'

const value = getItem('item-key')

setSessionItem

Set a sessionStorage value.

import { setSessionItem } from '@analytics/session-storage-utils'

setSessionItem('item-key', 'a')

removeSessionItem

Delete a sessionStorage value.

import { removeSessionItem } from '@analytics/session-storage-utils'

removeSessionItem('item-key')