@jedmao/storage
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

@jedmao/storage

GitHub Actions NPM version npm license codecov BundlePhobia Minified BundlePhobia Minified + gzip code style: prettier Unicorn Approved

npm

A Storage class that implements the Storage interface of the Web Storage API.

This class comes out-of-the-box with TypeScript type annotations and TSDoc comments.

Installation

$ npm install [--save[-dev]] @jedmao/storage

Usage

import { Storage } from '@jedmao/storage'

const data = { bar: 42 }
const storage = new Storage()

storage.setItem('foo', data)
storage.getItem('foo') // "[object Object]"
storage.setItem('foo', JSON.stringify(data))
storage.getItem('foo') // "{"bar":42}"

storage.setItem('baz', 42)
storage.getItem('baz') // '42'
storage.key(1) // 'baz'
storage.length // 2

storage.removeItem('foo')
storage.length // 1

storage.clear()
storage.length // 0

Package Sidebar

Install

npm i @jedmao/storage

Weekly Downloads

382

Version

3.0.0

License

MIT

Unpacked Size

13.2 kB

Total Files

8

Last publish

Collaborators

  • jedmao