Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/colomfernando/browser-localstorage-expire
- Owner: colomfernando
- Created: 2020-05-02T15:10:58.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-07-18T21:59:50.000Z (over 1 year ago)
- Last Synced: 2024-09-28T14:04:30.182Z (about 2 months ago)
- Topics: browser, javascript, localstorage, npm, npm-package, yarn
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/browser-localstorage-expire
- Size: 1.14 MB
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
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);
```