Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/colomfernando/browser-localstorage-expire

package localstorage
https://github.com/colomfernando/browser-localstorage-expire

browser javascript localstorage npm npm-package yarn

Last synced: about 1 month ago
JSON representation

package localstorage

Awesome Lists containing this project

README

        

# browser-localStorage

[![npm
version](https://img.shields.io/npm/v/browser-localstorage-expire.svg?style=flat-square)](https://www.npmjs.org/package/browser-localstorage-expire)

## Installation

```js
npm i -S browser-localstorage-expire
```

```js
yarn add browser-localstorage-expire
```

## Usage

module for manage cache from localstorage with expiration

**Returns**:

methods getItem and saveItem


**Example**
```js
const localCache = browserLocalstorage();
```

* [browserLocalstorage](#module_browserLocalstorage) ⇒
* [~getItem(name)](#module_browserLocalstorage..getItem) ⇒
* [~setItem(name, value, [expiry])](#module_browserLocalstorage..setItem) ⇒

### browserLocalstorage~getItem(name) ⇒

function for get data in localstorage

**Kind**: inner method of [browserLocalstorage](#module_browserLocalstorage)
**Returns**:

data from localstorage

| Param | Type | Description |
| --- | --- | --- |
| name | string |

name key for localstorage

|

**Example**
```js
const localCache = browserLocalstorage();
localCache.localGetItem('data')
```

### browserLocalstorage~setItem(name, value, [expiry]) ⇒

function for save data in localstorage

**Kind**: inner method of [browserLocalstorage](#module_browserLocalstorage)
**Returns**:

void

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| name | string | |

name key for localstorage

|
| value | \* | |

data to save in localstorage

|
| [expiry] | number | 5 |

time of expiration in minutes

|

**Example**
```js
const localCache = browserLocalstorage();
localCache.setItem('data', [{ country: 2 }], 5);
```