MCPcopy
hub / github.com/nanostores/nanostores / deepMap

Function deepMap

deep-map/index.js:8–25  ·  view source on GitHub ↗
(initial = {})

Source from the content-addressed store, hash-verified

6
7/* @__NO_SIDE_EFFECTS__ */
8export const deepMap = (initial = {}) => {
9 if (process.env.NODE_ENV !== 'production') {
10 warn(
11 'Move to deepmap() from @nanostores/deepmap. ' +
12 'deepmap() will be removed in 2.0.'
13 )
14 }
15
16 let $deepMap = atom(initial)
17 $deepMap.setKey = (key, value) => {
18 if (getPath($deepMap.value, key) !== value) {
19 let oldValue = $deepMap.value
20 $deepMap.value = setPath($deepMap.value, key, value)
21 $deepMap.notify(oldValue, key)
22 }
23 }
24 return $deepMap
25}
26
27export function getKey(store, key) {
28 let value = store.get()

Callers 3

index.test.tsFile · 0.90
production.test.jsFile · 0.90
errors.tsFile · 0.90

Calls 5

warnFunction · 0.90
atomFunction · 0.90
getPathFunction · 0.90
setPathFunction · 0.90
notifyMethod · 0.65

Tested by

no test coverage detected