MCPcopy Create free account
hub / github.com/violentmonkey/violentmonkey / set

Function set

src/background/utils/storage-cache.js:75–105  ·  view source on GitHub ↗
(data, flushNow)

Source from the content-addressed store, hash-verified

73 },
74
75 async set(data, flushNow) {
76 const toWrite = {};
77 const keys = [];
78 cache.batch(true);
79 data::forEachEntry(([key, val]) => {
80 const copy = deepCopyDiff(val, cache.get(key));
81 if (copy !== undefined) {
82 cache.put(key, copy);
83 dbKeys.set(key, 1);
84 keys.push(key);
85 if (undoing) {
86 toWrite[key] = val;
87 return;
88 }
89 if (!flushNow && key.startsWith(S_VALUE_PRE)) {
90 valuesToFlush[key] = copy;
91 } else {
92 toWrite[key] = val;
93 if (key.startsWith(S_SCRIPT_PRE) && updateScriptMap(key, val) && val[INFERRED]) {
94 delete (toWrite[key] = { ...val })[INFERRED];
95 }
96 updateScriptSizeContributor(key, val);
97 }
98 }
99 });
100 cache.batch(false);
101 if (!isEmpty(toWrite)) await api.set(toWrite);
102 if (undoing) return;
103 if (keys.length) fire(keys, data);
104 flushLater();
105 },
106
107 async remove(keys) {
108 const toDelete = keys.filter(key => {

Callers

nothing calls this directly

Calls 8

deepCopyDiffFunction · 0.90
updateScriptMapFunction · 0.90
isEmptyFunction · 0.90
flushLaterFunction · 0.85
setMethod · 0.80
fireFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected