-
-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
172 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* @flow | ||
*/ | ||
|
||
import { createStore, del, set, get, clear, keys } from 'idb-keyval'; | ||
|
||
try { | ||
const ParseStore = createStore('parseDB', 'parseStore'); | ||
|
||
const IndexedDBStorageController = { | ||
async: 1, | ||
getItemAsync(path: string) { | ||
return get(path, ParseStore); | ||
}, | ||
setItemAsync(path: string, value: string) { | ||
return set(path, value, ParseStore); | ||
}, | ||
removeItemAsync(path: string) { | ||
return del(path, ParseStore); | ||
}, | ||
getAllKeysAsync() { | ||
return keys(ParseStore); | ||
}, | ||
clear() { | ||
return clear(ParseStore); | ||
}, | ||
}; | ||
|
||
module.exports = IndexedDBStorageController; | ||
} catch (e) { | ||
// IndexedDB not supported | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Copyright (c) 2015-present, Parse, LLC. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
let mockStorage = {}; | ||
const mockStorageInterface = { | ||
createStore() {}, | ||
|
||
async get(path) { | ||
return mockStorage[path] || null; | ||
}, | ||
|
||
async set(path, value) { | ||
mockStorage[path] = value; | ||
}, | ||
|
||
async del(path) { | ||
delete mockStorage[path]; | ||
}, | ||
|
||
async keys() { | ||
return Object.keys(mockStorage); | ||
}, | ||
|
||
async clear() { | ||
mockStorage = {}; | ||
}, | ||
}; | ||
|
||
module.exports = mockStorageInterface; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Copyright (c) 2015-present, Parse, LLC. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
let mockStorage = {}; | ||
const mockStorageInterface = { | ||
getItem(path) { | ||
return mockStorage[path] || null; | ||
}, | ||
|
||
getItemAsync(path) { | ||
return Promise.resolve(mockStorageInterface.getItem(path)); | ||
}, | ||
|
||
setItem(path, value) { | ||
mockStorage[path] = value; | ||
}, | ||
|
||
setItemAsync(path, value) { | ||
return Promise.resolve(mockStorageInterface.setItem(path, value)); | ||
}, | ||
|
||
removeItem(path) { | ||
delete mockStorage[path]; | ||
}, | ||
|
||
removeItemAsync(path) { | ||
return Promise.resolve(mockStorageInterface.removeItem(path)); | ||
}, | ||
|
||
clear() { | ||
mockStorage = {}; | ||
}, | ||
}; | ||
module.exports = mockStorageInterface; |