Using nconf in a browser?

I'm looking to use https://github.com/flatiron/nconf in a browser. I tried using it with the browser, but since nconf calls fs.readdirSync when it needs to scan directories for configuration, it doesn't work in the browser.

// config.js
'use strict';

var nconf = require('nconf'); // this triggers the fs.readdirSync

var globalConfig = { my: { global: 1 }};
nconf.use('global', { type: 'literal', store: globalConfig });

var envConfig = { my: { env: 2 }};
nconf.use('env', { type: 'literal', store: envConfig });

module.exports = nconf;

      

Is it possible to use some kind of browser transform (I haven't seen a way to get it to use BRFS in nconf) or a way to use nconf (or some other similar library) to manage configuration on the client side

If not nconf, then just something that would allow me to do something similar to this:

config.load('user-settings', { my : { user: 1 } });
config.load('global-settings', { my: { global: 2 } } );

config.get('my.user'); // 1
config.get('my.global'); // 2

config.unload('global-settings');

config.get('my.global'); // undefined

      

+3


source to share





All Articles