Add type annotations to export
This commit is contained in:
parent
2eea5d5ab8
commit
64b767e7eb
1 changed files with 4 additions and 4 deletions
|
@ -17,14 +17,14 @@ limitations under the License.
|
|||
import { iterateCursor, txnAsPromise } from "./utils";
|
||||
import { STORE_NAMES } from "../common";
|
||||
|
||||
export async function exportSession(db) {
|
||||
export async function exportSession(db: IDBDatabase): Promise<{ [storeName : string] : any }> {
|
||||
const NOT_DONE = {done: false};
|
||||
const txn = db.transaction(STORE_NAMES, "readonly");
|
||||
const data = {};
|
||||
await Promise.all(STORE_NAMES.map(async name => {
|
||||
const results = data[name] = []; // initialize in deterministic order
|
||||
const results: any[] = data[name] = []; // initialize in deterministic order
|
||||
const store = txn.objectStore(name);
|
||||
await iterateCursor(store.openCursor(), (value) => {
|
||||
await iterateCursor<any>(store.openCursor(), (value) => {
|
||||
results.push(value);
|
||||
return NOT_DONE;
|
||||
});
|
||||
|
@ -32,7 +32,7 @@ export async function exportSession(db) {
|
|||
return data;
|
||||
}
|
||||
|
||||
export async function importSession(db, data) {
|
||||
export async function importSession(db: IDBDatabase, data: { [storeName: string]: any }): Promise<void> {
|
||||
const txn = db.transaction(STORE_NAMES, "readwrite");
|
||||
for (const name of STORE_NAMES) {
|
||||
const store = txn.objectStore(name);
|
||||
|
|
Reference in a new issue