MCPcopy Create free account
hub / github.com/PaulleDemon/PyUIBuilder / removeKeyFromObject

Function removeKeyFromObject

src/utils/common.js:32–53  ·  view source on GitHub ↗
(path, _object)

Source from the content-addressed store, hash-verified

30* @param {{}} _object - object with key and value
31*/
32export function removeKeyFromObject(path, _object) {
33 const keys = path.split('.')
34 const lastKey = keys.pop()
35
36 // Traverse the state and find the nested object up to the second last key
37 let newAttrs = { ..._object }
38 let nestedObject = newAttrs
39
40 for (const key of keys) {
41 if (nestedObject[key] !== undefined) {
42 nestedObject[key] = { ...nestedObject[key] } // Ensure immutability
43 nestedObject = nestedObject[key]
44 } else {
45 return // Key doesn't exist, so nothing to remove
46 }
47 }
48
49 // Remove the attribute
50 delete nestedObject[lastKey]
51
52 return newAttrs
53}
54
55
56export function isNumeric(str) {

Callers 15

base.jsFile · 0.90
constructorFunction · 0.90
constructorFunction · 0.90
base.jsFile · 0.90
constructorMethod · 0.90
constructorMethod · 0.90
constructorMethod · 0.90
constructorMethod · 0.90
constructorMethod · 0.90
constructorFunction · 0.90
constructorFunction · 0.90
base.jsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected