MCPcopy
hub / github.com/OpenBMB/AgentVerse / SetValue

Function SetValue

ui/src/phaser3-rex-plugins/plugins/utils/object/SetValue.js:39–70  ·  view source on GitHub ↗
(target, keys, value, delimiter)

Source from the content-addressed store, hash-verified

37};
38
39var SetValue = function (target, keys, value, delimiter) {
40 if (delimiter === undefined) {
41 delimiter = '.';
42 }
43
44 // no object
45 if (typeof (target) !== 'object') {
46 return;
47 }
48
49 // invalid key
50 else if (IsInValidKey(keys)) {
51 // don't erase target
52 if (value == null) {
53 return;
54 }
55 // set target to another object
56 else if (typeof (value) === 'object') {
57 target = value;
58 }
59 } else {
60 if (typeof (keys) === 'string') {
61 keys = keys.split(delimiter);
62 }
63
64 var lastKey = keys.pop();
65 var entry = GetEntry(target, keys);
66 entry[lastKey] = value;
67 }
68
69 return target;
70};
71
72export default SetValue;

Callers 15

Factory.jsFile · 0.85
Factory.jsFile · 0.85
Factory.jsFile · 0.85
Factory.jsFile · 0.85
constructorMethod · 0.85
Factory.jsFile · 0.85
Factory.jsFile · 0.85
Factory.jsFile · 0.85
Factory.jsFile · 0.85
Factory.jsFile · 0.85
Factory.jsFile · 0.85
Factory.jsFile · 0.85

Calls 3

IsInValidKeyFunction · 0.85
GetEntryFunction · 0.70
popMethod · 0.45

Tested by

no test coverage detected