-
Notifications
You must be signed in to change notification settings - Fork 73
/
NoopProvider.ts
97 lines (83 loc) · 2.09 KB
/
NoopProvider.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import type {OnyxValue} from '../../types';
import type StorageProvider from './types';
const provider: StorageProvider = {
/**
* The name of the provider that can be printed to the logs
*/
name: 'NoopProvider',
/**
* Initializes the storage provider
*/
init() {
// do nothing
},
/**
* Get the value of a given key or return `null` if it's not available in memory
*/
getItem(key) {
return Promise.resolve(null as OnyxValue<typeof key>);
},
/**
* Get multiple key-value pairs for the give array of keys in a batch.
*/
multiGet() {
return Promise.resolve([]);
},
/**
* Sets the value for a given key. The only requirement is that the value should be serializable to JSON string
*/
setItem() {
return Promise.resolve();
},
/**
* Stores multiple key-value pairs in a batch
*/
multiSet() {
return Promise.resolve();
},
/**
* Merging an existing value with a new one
*/
mergeItem() {
return Promise.resolve();
},
/**
* Multiple merging of existing and new values in a batch
* This function also removes all nested null values from an object.
*/
multiMerge() {
return Promise.resolve([]);
},
/**
* Remove given key and it's value from memory
*/
removeItem() {
return Promise.resolve();
},
/**
* Remove given keys and their values from memory
*/
removeItems() {
return Promise.resolve();
},
/**
* Clear everything from memory
*/
clear() {
return Promise.resolve();
},
/**
* Returns all keys available in memory
*/
getAllKeys() {
return Promise.resolve([]);
},
/**
* Gets the total bytes of the store.
* `bytesRemaining` will always be `Number.POSITIVE_INFINITY` since we don't have a hard limit on memory.
*/
getDatabaseSize() {
return Promise.resolve({bytesRemaining: Number.POSITIVE_INFINITY, bytesUsed: 0});
},
};
export default provider;