MCPcopy Index your code
hub / github.com/NobyDa/Script / write

Function write

JD-DailyBonus/JD_DailyBonus.js:1804–1828  ·  view source on GitHub ↗
(value, key)

Source from the content-addressed store, hash-verified

1802 })
1803 }
1804 const write = (value, key) => {
1805 if (isQuanX) return $prefs.setValueForKey(value, key)
1806 if (isSurge) return $persistentStore.write(value, key)
1807 if (isNode) {
1808 try {
1809 if (!node.fs.existsSync(node.path.resolve(__dirname, NodeSet)))
1810 node.fs.writeFileSync(node.path.resolve(__dirname, NodeSet), JSON.stringify({}));
1811 const dataValue = JSON.parse(node.fs.readFileSync(node.path.resolve(__dirname, NodeSet)));
1812 if (value) dataValue[key] = value;
1813 if (!value) delete dataValue[key];
1814 return node.fs.writeFileSync(node.path.resolve(__dirname, NodeSet), JSON.stringify(dataValue));
1815 } catch (er) {
1816 return AnError('Node.js持久化写入', null, er);
1817 }
1818 }
1819 if (isJSBox) {
1820 if (!value) return $file.delete(`shared://${key}.txt`);
1821 return $file.write({
1822 data: $data({
1823 string: value
1824 }),
1825 path: `shared://${key}.txt`
1826 })
1827 }
1828 }
1829 const read = (key) => {
1830 if (isQuanX) return $prefs.valueForKey(key)
1831 if (isSurge) return $persistentStore.read(key)

Callers

nothing calls this directly

Calls 4

AnErrorFunction · 0.85
writeMethod · 0.45
stringifyMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected