MCPcopy Create free account
hub / github.com/scriptscat/scriptcat / _get

Method _get

src/pkg/config/config.ts:147–168  ·  view source on GitHub ↗
(
    key: SystemConfigKey,
    defaultValue: WithAsyncValue<Exclude<T, undefined>>
  )

Source from the content-addressed store, hash-verified

145 }
146
147 private _get<T extends string | number | boolean | object>(
148 key: SystemConfigKey,
149 defaultValue: WithAsyncValue<Exclude<T, undefined>>
150 ): Promise<T> {
151 if (this.cache.has(key)) {
152 const val = this.cache.get(key);
153 return Promise.resolve(val === undefined ? this.resolveDefault<T>(defaultValue) : (val as T));
154 }
155 const storage = this.getStorage(key);
156 return storage.get(key).then((val) => {
157 if (val !== undefined) {
158 this.cache.set(key, val);
159 return val as T;
160 }
161 // 对 local key,回退读取 sync storage(兼容旧版本数据迁移)
162 if (this.isLocalKey(key)) {
163 return this.transferSyncToLocal<T>(key, defaultValue);
164 }
165 this.cache.set(key, val);
166 return this.resolveDefault<T>(defaultValue);
167 });
168 }
169
170 public get<T extends SystemConfigKey>(key: T): Promise<SystemConfigValueType<T>> {
171 const funcName = `get${toCamelCase(key)}`;

Callers 15

getEnableAutoSyncMethod · 0.95
getVscodeUrlMethod · 0.95
getVscodeReconnectMethod · 0.95
getBackupMethod · 0.95
getCloudSyncMethod · 0.95
getCatFileStorageMethod · 0.95
getEnableEslintMethod · 0.95
getEslintConfigMethod · 0.95
getEditorConfigMethod · 0.95

Calls 7

resolveDefaultMethod · 0.95
getStorageMethod · 0.95
isLocalKeyMethod · 0.95
transferSyncToLocalMethod · 0.95
hasMethod · 0.65
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected