MCPcopy Create free account
hub / github.com/thetarnav/solid-devtools / updateStore

Function updateStore

packages/frontend/src/inspector.tsx:105–127  ·  view source on GitHub ↗
(
    [storeProperty, newRawValue]: debug.InspectorUpdateMap['store'],
    storeNodeMap: decode.StoreNodeMap,
)

Source from the content-addressed store, hash-verified

103}
104
105function updateStore(
106 [storeProperty, newRawValue]: debug.InspectorUpdateMap['store'],
107 storeNodeMap: decode.StoreNodeMap,
108): void {
109 const [storeNodeId, property] = splitOnColon(storeProperty)
110 const store = storeNodeMap.get(storeNodeId)
111 if (!store) throw `updateStore: store node (${storeNodeId}) not found`
112
113 const value = store.value
114 if (!value) throw `updateStore: store node (${storeNodeId}) has no value`
115
116 const newValue = (Array.isArray(value) ? value.slice() : {...value}) as {[key: string]: any}
117
118 if (newRawValue === null) {
119 delete newValue[property]
120 } else if (typeof newRawValue === 'number') {
121 if (Array.isArray(value)) value.length = newRawValue
122 else throw `updateStore: store node (${storeNodeId}) is not an array`
123 } else {
124 newValue[property] = decode.decodeValue(newRawValue, newValue[property], storeNodeMap)
125 }
126 store.setValue(newValue)
127}
128
129const NULL_STATE = {
130 name: null,

Callers 1

createInspectorFunction · 0.85

Calls 2

splitOnColonFunction · 0.90
getMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…