Skip to content

Commit 18bbbe9

Browse files
author
Zane Starr
committed
Label async functions
1 parent f90aef7 commit 18bbbe9

File tree

7 files changed

+18
-18
lines changed

7 files changed

+18
-18
lines changed

src/api-addr.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ module.exports = (store) => {
2222
* @param {Object} value - the api address to be written
2323
* @returns {Promise<void>}
2424
*/
25-
set (value) {
25+
async set (value) {
2626
return store.put(apiFile, Buffer.from(value.toString()))
2727
},
2828
/**
2929
* Deletes api file
3030
*
3131
* @returns {Promise<void>}
3232
*/
33-
delete () {
33+
async delete () {
3434
return store.delete(apiFile)
3535
}
3636
}

src/config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = (store) => {
2020
* @param {String} key - the config key to get
2121
* @returns {Promise<Object>}
2222
*/
23-
get (key) {
23+
async get (key) {
2424
if (!key) {
2525
key = undefined
2626
}
@@ -61,7 +61,7 @@ module.exports = (store) => {
6161
*
6262
* @returns {Promise<bool>}
6363
*/
64-
exists () {
64+
async exists () {
6565
return store.has(configKey)
6666
}
6767
}

src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class IpfsRepo {
147147
*
148148
* @returns {Promise<void>}
149149
*/
150-
_closeLock () {
150+
async _closeLock () {
151151
if (this.lockfile) {
152152
return this.lockfile.close()
153153
}

src/lock-memory.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const LOCKS = {}
1414
* @param {string} dir
1515
* @returns {Promise<Object>}
1616
*/
17-
exports.lock = (dir) => {
17+
exports.lock = async (dir) => {
1818
const file = dir + '/' + lockFile
1919
log('locking %s', file)
2020
LOCKS[file] = true

src/lock.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const STALE_TIME = 20000
2222
* Lock the repo in the given dir.
2323
*
2424
* @param {string} dir
25-
* @returns {Object}
25+
* @returns {Promise<Object>}
2626
*/
2727
exports.lock = async (dir) => {
2828
const file = path.join(dir, lockFile)

src/spec.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@ module.exports = (store) => {
1212
*
1313
* @returns {Promise<bool>}
1414
*/
15-
exists () {
15+
async exists () {
1616
return store.has(specKey)
1717
},
1818
/**
1919
* Get the current datastore spec.
2020
*
2121
* @returns {Promise<Buffer>}
2222
*/
23-
get () {
24-
return store.get()
25-
.then(buf => JSON.parse(buf.toString()))
23+
async get () {
24+
const buf = await store.get()
25+
return JSON.parse(buf.toString())
2626
},
2727
/**
2828
* Set the datastore spec of the repo, writing it to the underlying store.
2929
* TODO unclear on what the type should be or if it's required
3030
* @param {number} spec
3131
* @returns {Promise<void>}
3232
*/
33-
set (spec) {
33+
async set (spec) {
3434
return store.put(specKey, Buffer.from(JSON.stringify(sortKeys(spec, { deep: true }))))
3535
}
3636
}

src/version.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,25 @@ module.exports = (store) => {
1313
*
1414
* @returns {Promise<bool>}
1515
*/
16-
exists () {
16+
async exists () {
1717
return store.has(versionKey)
1818
},
1919
/**
2020
* Get the current version.
2121
*
2222
* @returns {Promise<Integer>}
2323
*/
24-
get () {
25-
return this.get(versionKey)
26-
.then(buf => parseInt(buf.toString().trim(), 10))
24+
async get () {
25+
const buf =await this.get(versionKey)
26+
return parseInt(buf.toString().trim(), 10)
2727
},
2828
/**
2929
* Set the version of the repo, writing it to the underlying store.
3030
*
3131
* @param {number} version
32-
* @returns {void}
32+
* @returns {Promise<void>}
3333
*/
34-
set (version) {
34+
async set (version) {
3535
return store.put(versionKey, Buffer.from(String(version)))
3636
},
3737
/**

0 commit comments

Comments
 (0)