MCPcopy
hub / github.com/iChochy/NCE / getStorageJSON

Function getStorageJSON

js/utils/storage.js:30–38  ·  view source on GitHub ↗
(key, defaultValue = null)

Source from the content-addressed store, hash-verified

28 * @returns {*} 解析后的值或默认值
29 */
30export function getStorageJSON(key, defaultValue = null) {
31 try {
32 const item = getStorage(key);
33 return item ? JSON.parse(item) : defaultValue;
34 } catch (error) {
35 console.error(`Failed to parse JSON from storage (${key}):`, error);
36 return defaultValue;
37 }
38}
39
40/**
41 * 安全地向 localStorage 写入数据

Callers

nothing calls this directly

Calls 2

getStorageFunction · 0.85
parseMethod · 0.80

Tested by

no test coverage detected