MCPcopy
hub / github.com/sunnylqm/react-native-storage / _loadMapItem

Method _loadMapItem

storage.js:228–256  ·  view source on GitHub ↗
(params)

Source from the content-addressed store, hash-verified

226 return Promise.reject(new NotFoundError(JSON.stringify(params)));
227 }
228 _loadMapItem(params) {
229 let { ret, key, id, autoSync, batched, syncInBackground, syncParams } = params;
230 if(ret === null || ret === undefined) {
231 return this._noItemFound(params);
232 }
233 if(typeof ret === 'string'){
234 ret = JSON.parse(ret);
235 const { key, id } = params;
236 const newId = this._getId(key, id);
237 if (this.enableCache) {
238 this.cache[newId] = ret;
239 }
240 }
241 let now = new Date().getTime();
242 if(ret.expires < now) {
243 if(autoSync && this.sync[key]) {
244 if(syncInBackground) {
245 this.sync[key]({ id, syncParams });
246 return Promise.resolve(ret.rawData);
247 }
248 return new Promise((resolve, reject) => this.sync[key]({ id, resolve, reject, syncParams }));
249 }
250 if(batched) {
251 return Promise.resolve({ syncId: id });
252 }
253 return Promise.reject(new ExpiredError(JSON.stringify(params)));
254 }
255 return Promise.resolve(ret.rawData);
256 }
257 _lookUpInMap(params) {
258 let m = this._m,
259 ret;

Callers 1

_lookUpInMapMethod · 0.95

Calls 2

_noItemFoundMethod · 0.95
_getIdMethod · 0.95

Tested by

no test coverage detected