diff --git a/src/api-addr.js b/src/api-addr.js index 333d93bc..8b85a0d6 100644 --- a/src/api-addr.js +++ b/src/api-addr.js @@ -22,7 +22,7 @@ module.exports = (store) => { * @param {Object} value - the api address to be written * @returns {Promise} */ - set (value) { + async set (value) { return store.put(apiFile, Buffer.from(value.toString())) }, /** @@ -30,7 +30,7 @@ module.exports = (store) => { * * @returns {Promise} */ - delete () { + async delete () { return store.delete(apiFile) } } diff --git a/src/config.js b/src/config.js index ce9541a2..a6ad51f8 100644 --- a/src/config.js +++ b/src/config.js @@ -20,7 +20,7 @@ module.exports = (store) => { * @param {String} key - the config key to get * @returns {Promise} */ - get (key) { + async get (key) { if (!key) { key = undefined } @@ -61,7 +61,7 @@ module.exports = (store) => { * * @returns {Promise} */ - exists () { + async exists () { return store.has(configKey) } } diff --git a/src/index.js b/src/index.js index 27d93d9d..ac255172 100644 --- a/src/index.js +++ b/src/index.js @@ -147,7 +147,7 @@ class IpfsRepo { * * @returns {Promise} */ - _closeLock () { + async _closeLock () { if (this.lockfile) { return this.lockfile.close() } diff --git a/src/lock-memory.js b/src/lock-memory.js index 3e13aa26..2f4a059a 100644 --- a/src/lock-memory.js +++ b/src/lock-memory.js @@ -14,7 +14,7 @@ const LOCKS = {} * @param {string} dir * @returns {Promise} */ -exports.lock = (dir) => { +exports.lock = async (dir) => { const file = dir + '/' + lockFile log('locking %s', file) LOCKS[file] = true diff --git a/src/lock.js b/src/lock.js index 0e7a26de..c3a7e3dd 100644 --- a/src/lock.js +++ b/src/lock.js @@ -22,7 +22,7 @@ const STALE_TIME = 20000 * Lock the repo in the given dir. * * @param {string} dir - * @returns {Object} + * @returns {Promise} */ exports.lock = async (dir) => { const file = path.join(dir, lockFile) diff --git a/src/spec.js b/src/spec.js index 26cf880e..6bf6522a 100644 --- a/src/spec.js +++ b/src/spec.js @@ -12,7 +12,7 @@ module.exports = (store) => { * * @returns {Promise} */ - exists () { + async exists () { return store.has(specKey) }, /** @@ -20,9 +20,9 @@ module.exports = (store) => { * * @returns {Promise} */ - get () { - return store.get() - .then(buf => JSON.parse(buf.toString())) + async get () { + const buf = await store.get() + return JSON.parse(buf.toString()) }, /** * Set the datastore spec of the repo, writing it to the underlying store. @@ -30,7 +30,7 @@ module.exports = (store) => { * @param {number} spec * @returns {Promise} */ - set (spec) { + async set (spec) { return store.put(specKey, Buffer.from(JSON.stringify(sortKeys(spec, { deep: true })))) } } diff --git a/src/version.js b/src/version.js index 1385bdea..49b7dc73 100644 --- a/src/version.js +++ b/src/version.js @@ -13,7 +13,7 @@ module.exports = (store) => { * * @returns {Promise} */ - exists () { + async exists () { return store.has(versionKey) }, /** @@ -21,17 +21,17 @@ module.exports = (store) => { * * @returns {Promise} */ - get () { - return this.get(versionKey) - .then(buf => parseInt(buf.toString().trim(), 10)) + async get () { + const buf =await this.get(versionKey) + return parseInt(buf.toString().trim(), 10) }, /** * Set the version of the repo, writing it to the underlying store. * * @param {number} version - * @returns {void} + * @returns {Promise} */ - set (version) { + async set (version) { return store.put(versionKey, Buffer.from(String(version))) }, /**