Gathering detailed insights and metrics for @plq/use-persisted-state
Gathering detailed insights and metrics for @plq/use-persisted-state
Gathering detailed insights and metrics for @plq/use-persisted-state
Gathering detailed insights and metrics for @plq/use-persisted-state
npm install @plq/use-persisted-state
Typescript
Module System
Min. Node Version
Node Version
NPM Version
68.4
Supply Chain
93.9
Quality
76.2
Maintenance
100
Vulnerability
100
License
TypeScript (91.92%)
JavaScript (8.08%)
Total Downloads
83,844
Last Day
56
Last Week
466
Last Month
1,838
Last Year
23,048
20 Stars
623 Commits
6 Forks
5 Watching
14 Branches
2 Contributors
Minified
Minified + Gzipped
Latest Version
1.2.0
Package Id
@plq/use-persisted-state@1.2.0
Unpacked Size
65.16 kB
Size
14.72 kB
File Count
86
NPM Version
10.1.0
Node Version
20.8.0
Publised On
09 Oct 2023
Cumulative downloads
Total Downloads
Last day
-73.5%
56
Compared to previous day
Last week
-37.4%
466
Compared to previous week
Last month
4.7%
1,838
Compared to previous month
Last year
55.4%
23,048
Compared to previous year
1
25
Persists the state to localStorage, sessionStorage or any custom storage
localStorage
, sessionStorage
or almost anything else implements storage API1import createPersistedState from '@plq/use-persisted-state' 2import storage from '@plq/use-persisted-state/lib/storages/local-storage' 3 4const [usePersistedState] = createPersistedState('example', storage) 5 6export default function App() { 7 const [count, setCount] = usePersistedState('count', 0) 8 const handleIncrement = () => setCount(prevCount => prevCount + 1) 9 10 return ( 11 <div> 12 {count} 13 <button onClick={handleIncrement}>+</button> 14 </div> 15 ) 16}
To use @plq/use-persisted-state
, you must use react@16.8.0
or greater which includes Hooks.
1import createPersistedState from '@plq/use-persisted-state' 2import storage from '@plq/use-persisted-state/lib/storages/local-storage' 3 4const [usePersistedState, clear] = createPersistedState('example', storage) 5 6export default function App() { 7 const [count, setCount] = usePersistedState('count', 0) 8 const increment = () => setCount(prevCount => prevCount + 1) 9 10 return ( 11 <div> 12 {count} 13 <button onClick={increment}>+</button> 14 <button onClick={clear}>Clear</button> 15 </div> 16 ) 17}
1import createPersistedState from '@plq/use-persisted-state' 2import storage from '@plq/use-persisted-state/lib/storages/session-storage' 3 4const [usePersistedState, clear] = createPersistedState('example', storage)
1import createPersistedState from '@plq/use-persisted-state' 2// or 3import { createAsyncPersistedState } from '@plq/use-persisted-state' 4import { local } from '@plq/use-persisted-state/lib/storages/browser-storage' 5 6const [usePersistedState, clear] = createPersistedState('example', local)
The storage API is similar to the browser.storage but with a few differences
1import createPersistedState from '@plq/use-persisted-state'
2
3const storageListeners = new Set()
4
5onChangeSomeStorage(event => {
6 const changes = {
7 [event.key]: {
8 newValue: event.newValue,
9 oldValue: event.oldValue,
10 },
11 }
12
13 listeners.forEach(listener => {
14 listener(changes)
15 })
16})
17
18const myStorage = {
19 get: keys => getItemsFromSomeStorage(keys),
20 set: items => setItemsToSomeStorage(items),
21 remove: keys => removeItemsFromSomeStorage(keys),
22 onChanged: {
23 addListener: listener => storageListeners.add(listener),
24 removeListener: listener => storageListeners.delete(listener),
25 hasListener: listener => storageListeners.has(listener),
26 }
27}
28
29const [usePersistedState, clear] = createPersistedState('example', myStorage)
@plq/use-persisted-state/lib/storages/local-storage
@plq/use-persisted-state/lib/storages/session-storage
@plq/use-persisted-state/lib/storages/browser-storage
manifest.json
file@plq/use-persisted-state/lib/storages/chrome-storage
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
Reason
8 existing vulnerabilities detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More