diff --git a/lib/file.js b/lib/file.js index 0ee6a169..36459601 100644 --- a/lib/file.js +++ b/lib/file.js @@ -7,10 +7,20 @@ var Gun = require('../gun'), file = {}; function isUsingFileJS (context) { - var gun = context.gun; - var opt = context.opt || gun.Back('opt') || {}; - return opt.file !== false; + // Options passed via .get or .put. + var methodOptions = context.opt || {}; + + // Options set on the gun chain. + var chainOptions = context.gun.Back('opt') || {}; + + // Favor method options over chain options. + var file = methodOptions.hasOwnProperty('file') + ? methodOptions.file + : chainOptions.file; + + // Return whether the module is disabled. + return file !== false; } // queue writes, adapted from https://github.com/toolness/jsondown/blob/master/jsondown.js