From 8d24b0adeda3a139d18f83c793ab7cd15a9fe84a Mon Sep 17 00:00:00 2001 From: RangerMauve Date: Fri, 30 Aug 2019 23:47:35 -0400 Subject: [PATCH] Fix handling options in promise API --- promise.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/promise.js b/promise.js index a7e5499..c1621f3 100644 --- a/promise.js +++ b/promise.js @@ -124,18 +124,21 @@ module.exports = function SDK (opts) { let archive = null + const localOptions = { + persist: false + } + if (key) { - if (!options.persist) { - options.persist = false - } if (isLocal(key)) { - options.persist = true + localOptions.persist = true } - archive = Hyperdrive(key, options) + const finalOptions = Object.assign(localOptions, options) + archive = Hyperdrive(key, finalOptions) } else { - archive = Hyperdrive(null, { - persist: true - }) + localOptions.persist = true + const finalOptions = Object.assign(localOptions, options) + + archive = Hyperdrive(null, finalOptions) addLocal(archive.metadata.key.toString('hex')) } @@ -463,8 +466,8 @@ module.exports = function SDK (opts) { return archive } - static async load (url) { - const archive = new DatArchive(url) + static async load (url, options) { + const archive = new DatArchive(url, options) await archive._loadPromise