mirror of
https://github.com/amark/gun.git
synced 2025-06-07 14:46:44 +00:00
Merge pull request #270 from PsychoLlama/allow-file-json-opt-out
Reliably check file.js options
This commit is contained in:
commit
2317a54d45
16
lib/file.js
16
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 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user