MCPcopy Create free account
hub / github.com/chavyleung/scripts / apiUpdate

Function apiUpdate

box/chavy.boxjs.js:739–757  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

737}
738
739async function apiUpdate() {
740 const data = $.toObj($request.body)
741 const path = data.path.split('.')
742 const val = data.val
743 const key = path.shift()
744 // 必须用 hasOwnProperty:val 为 false 时 data.val && … 会误判为跳过更新
745 if (path.join('.') && Object.prototype.hasOwnProperty.call(data, 'val')) {
746 switch (key) {
747 case 'usercfgs':
748 const usercfgs = getUserCfgs()
749 update(usercfgs, path.join('.'), val)
750 $.setjson(usercfgs, $.KEY_usercfgs)
751 break
752 default:
753 break
754 }
755 }
756 $.json = getBoxData()
757}
758
759async function apiAddAppSub() {
760 const sub = $.toObj($request.body)

Callers

nothing calls this directly

Calls 5

getUserCfgsFunction · 0.70
updateFunction · 0.70
getBoxDataFunction · 0.70
toObjMethod · 0.45
setjsonMethod · 0.45

Tested by

no test coverage detected