1.1.20 • Published 2 years ago
@itshkins/dom-utils v1.1.20
DOM utils
This package provides a set of DOM utilities.
- One of them is a local state manager that simplifies the usage of Storage API:
const KEY = `my-key`
const storage = localStorage // or sessionStorage
const state = JSON.parse(storage.getItem(KEY))
storage.setItem(KEY, JSON.stringify({value: []}))Installation
npm i @itshkins/dom-utils@latestUsage
Node
import {newLocalState} from '@itshkins/dom-utils'
const DEFAULT_STATE = Object.freeze({})
const localState = newLocalState(`my-key`)
console.log(localState.getState(DEFAULT_STATE)) // {}
console.log(localState.setState({value: []})) // true
console.log(localState.getState(DEFAULT_STATE)) // {value: Array(0)}Browser
<script src="./node_modules/@itshkins/dom-utils/dist/dom-utils.js"></script>
<script>
const DEFAULT_STATE = Object.freeze({})
const localState = domUtils.newLocalState(`my-key`)
console.log(localState.getState(DEFAULT_STATE)) // {}
console.log(localState.setState({value: []})) // true
console.log(localState.getState(DEFAULT_STATE)) // {value: Array(0)}
</script>1.1.20
2 years ago
1.1.19
2 years ago
1.1.18
3 years ago
1.1.17
3 years ago
1.1.16
3 years ago
1.1.15
3 years ago
1.1.14
3 years ago
1.1.13
3 years ago
1.1.12
3 years ago
1.1.11
3 years ago
1.1.10
3 years ago
1.1.9
3 years ago
1.1.8
3 years ago
1.1.7
3 years ago
1.1.5
3 years ago
1.1.4
3 years ago
1.1.3
3 years ago
1.1.2
3 years ago
1.1.1
3 years ago
1.1.0
3 years ago
1.0.6
3 years ago
1.0.5
3 years ago
1.0.4
3 years ago
1.0.3
3 years ago
1.0.2
3 years ago
1.0.1
3 years ago
1.0.0
3 years ago