Skip to content

Commit

Permalink
add .init() method to initialize the local store (#23)
Browse files Browse the repository at this point in the history
* add .init() method to initialize the local store

* fix .travis.yml to meet latest dependency requirements
  • Loading branch information
marcuspoehls authored and bukinoshita committed Oct 7, 2019
1 parent d221448 commit 40a195e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: node_js
node_js:
- '8'
- '9'
- '10'
- '12'
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ const { encrypt, decrypt } = require('caesar-encrypt')

class SaveLocal {
constructor(store = 'storage') {
const s = `.${store}`
this.store = `.${store}`
}

storage.init({
dir: join(homedir(), s)
async init() {
await storage.init({
dir: join(homedir(), this.store)
})
}

Expand Down
9 changes: 9 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const SaveLocal = require('save-local')

const saveLocal = new SaveLocal('store')

// you must call saveLocal.init() to initialize the instance
await saveLocal.init()

saveLocal.set({ name: 'token', value: 'my-token' })
saveLocal.get('token').then(value => console.log(value))
// => my-token
Expand All @@ -38,6 +41,12 @@ store name

### methods

#### .init()

Returns a `promise`

Initializes the local store

#### .set([options])

Returns a `promise`
Expand Down

0 comments on commit 40a195e

Please sign in to comment.