Skip to content

Commit

Permalink
add list method (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
bukinoshita committed Oct 9, 2017
1 parent cd36298 commit 3724f18
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ class SaveLocal {
remove(name) {
return storage.removeItem(name)
}

list() {
return new Promise(resolve => {
const packages = storage.keys()
const list = []
packages.forEach(async name => {
const value = await this.get(name)
list.push({ name, value })
resolve(list)
})
})
}
}

module.exports = SaveLocal
6 changes: 6 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ Required

name of the item saved

#### .list()

Returns a `promise`

Get an array with all `names` and `values`


## Related

Expand Down

0 comments on commit 3724f18

Please sign in to comment.