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

Method remove

storage.js:271–296  ·  view source on GitHub ↗
(params)

Source from the content-addressed store, hash-verified

269 return this._noItemFound( {ret, ...params } );
270 }
271 remove(params) {
272 return this._mapPromise.then(() => {
273 let m = this._m;
274 let { key, id } = params;
275
276 if(id === undefined) {
277 if(this.enableCache && this.cache[key]) {
278 delete this.cache[key];
279 }
280 return this.removeItem(key);
281 }
282 let newId = this._getId(key, id);
283
284 //remove existed data
285 if(m[newId] !== undefined) {
286 if(this.enableCache && this.cache[newId]) {
287 delete this.cache[newId];
288 }
289 this._removeIdInKey(key, id);
290 let idTobeDeleted = m[newId];
291 delete m[newId];
292 this.setItem('map', JSON.stringify(m));
293 return this.removeItem('map_' + idTobeDeleted);
294 }
295 });
296 }
297 _removeIdInKey(key, id) {
298 let indexTobeRemoved = (this._m.__keys__[key] || []).indexOf(id);
299 if (indexTobeRemoved !== -1) {

Callers 2

clearMapForKeyMethod · 0.95
taskFunction · 0.80

Calls 4

removeItemMethod · 0.95
_getIdMethod · 0.95
_removeIdInKeyMethod · 0.95
setItemMethod · 0.95

Tested by 1

taskFunction · 0.64