0.0.4 • Published 5 years ago

lokale v0.0.4

Weekly downloads
6
License
ISC
Repository
github
Last release
5 years ago

Lokale - Simple API for localStorage Management

Lokale is a simple yet reliable api for browser localStorage or sessionStorage management.

Install

Make sure you have the following installed

Run the folling command to add the package to your project dependencies

npm install lokale

How to use

Lokale also supports typescripts, types declaration are included by default.

CommonJs

const Lokale = require('lokale');

ES6

import Lokale from 'lokale';

Usage

// Initiate an instance
// You can use localStorage or sessionStorage
const lokalStorage = new Lokale(window.localStorage);

// Set item
lokalStorage.setItem('YourKey', 'YourData');

API

Available options

APIArguments TypeDescriptionReturns
lokale(storage)StorageSet the preferred storage localStorage or sessionStorage
getItem(key)StringGet item by key nameString - Value of the key
setItem(key, value)String, StringSet item value to storage
hasItem(key)StringCheck if item exists in the storageBoolean
clear()Empty all keys and values in storage
getSpaceUsage()Get detailed size/space infos about keys and remaining spaceObject - Usage per key, availableSpace, and usedSpace