Skip to content

Commit

Permalink
Update import-state's _getChunk to be async generator
Browse files Browse the repository at this point in the history
- I don't think it really make a diff, but seems much more natural to use generators all the way down here, rather than yielding resolved Promises
  • Loading branch information
poltak committed Mar 16, 2018
1 parent d625800 commit e11a964
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/imports/background/import-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,9 @@ export class ImportStateManager {
})
}

async _getChunk(chunkKey) {
async *_getChunk(chunkKey) {
const storage = await browser.storage.local.get(chunkKey)
return { chunk: storage[chunkKey], chunkKey }
yield { chunk: storage[chunkKey], chunkKey }
}

/**
Expand Down Expand Up @@ -410,7 +410,7 @@ export class ImportStateManager {
*/
async *getItems(includeErrs = false) {
for (const chunkKey of this.storageKeyStack) {
yield await this._getChunk(chunkKey)
yield* this._getChunk(chunkKey)
}

if (includeErrs) {
Expand All @@ -420,7 +420,7 @@ export class ImportStateManager {

async *getErrItems() {
for (const chunkKey of this.errStorageKeyStack) {
yield await this._getChunk(chunkKey)
yield* this._getChunk(chunkKey)
}
}

Expand Down

0 comments on commit e11a964

Please sign in to comment.