1.3.4 • Published 10 months ago

@zero-dependency/storage v1.3.4

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@zero-dependency/storage

npm version npm bundle size (scoped) npm license

Installation

npm install @zero-dependency/storage
yarn add @zero-dependency/storage
pnpm add @zero-dependency/storage

Usage

import { LocalStorage } from '@zero-dependency/storage'

interface User {
  id: number
  name: string
}

const storageKey = 'users'
const storage = new LocalStorage<User[]>(storageKey, [])
console.log(storage.initialValue) // []

storage.write((prevValue) => [...prevValue, { id: 1, name: 'John' }])
console.log(storage.value) // [{ id: 1, name: 'John' }]

storage.reset()
console.log(storage.value) // []

// https://developer.mozilla.org/en-US/docs/Web/API/Window/storage_event#examples
window.addEventListener('storage', (event) => {
  if (event.key === storageKey) {
    // do something
  }
})
1.3.4

10 months ago

1.3.3

10 months ago

1.3.2

10 months ago

1.2.0

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago

1.1.2

1 year ago

0.3.0

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.0

2 years ago