MCPcopy Index your code
hub / github.com/callstack/async-storage / createLocalStorage

Function createLocalStorage

jest/setup.js:11–39  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9 */
10
11const createLocalStorage = () => {
12 const store = {};
13
14 // $FlowFixMe https://github.com/facebook/flow/issues/285
15 Object.defineProperties(store, {
16 getItem: {
17 get: () => (key: string) => store[key] || null,
18 },
19 setItem: {
20 get: () => (key: string, value: string) => {
21 store[key] = value;
22 },
23 },
24 removeItem: {
25 get: () => (key: string) => {
26 delete store[key];
27 },
28 },
29 clear: {
30 get: () => () => {
31 Object.keys(store).forEach((key: string) => {
32 store.removeItem(key);
33 });
34 },
35 },
36 });
37
38 return store;
39};
40
41window.localStorage = createLocalStorage();

Callers 1

setup.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…