Merge pull request #270 from PsychoLlama/allow-file-json-opt-out

Reliably check file.js options
This commit is contained in:
Jesse Gibson 2016-11-15 17:24:34 -07:00 committed by GitHub
commit 2317a54d45

View File

@ -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 chainOption = context.gun.Back('opt.file');
// Favor method options over chain options.
var file = methodOptions.hasOwnProperty('file')
? methodOptions.file
: chainOption;
// Return whether the module is disabled.
return file !== false;
}
// queue writes, adapted from https://github.com/toolness/jsondown/blob/master/jsondown.js