1.x.x
:
const config = require('electron-json-config');
2.x.x
:
factory()
is now responsible of the instanciation.
CommonJS
const config = require('electron-json-config').factory();
ES Modules
import { factory } from 'electron-json-config';
const config = factory();
The library keeps its default file functionality but will not check if the electron app is read.
1.x.x
:
Returned the default configuration from the default file.
const config = require('electron-json-config');
2.x.x
:
Returns the default configuration from the default file
CommonJS
const config = require('electron-json-config').factory();
ES Modules
import { factory } from 'electron-json-config';
const config = factory();
See factory section of README.
2.x.x introduce the ability to have multiple configurations (and associated files) at the same time.
2.x.x
:
CommonJS
const factory = require('electron-json-config').factory;
const defaultConf = factory();
const testConf = factory('/data/test.json');
ES Modules
import { factory } from 'electron-json-config';
const config = factory();
const defaultConf = factory();
const testConf = factory('/data/test.json');
Keys can now be:
- a classic string key
eg:'foo'
- a dotted string multi level key
eg:'foo.bar'
- an array of string representing a multi level key
eg:['foo', 'bar']
2.x.x:
require
syntax
// A simple key => ['foo']
config.get('foo');
// These are equivalent => ['foo', 'bar']
config.get('foo.bar');
config.get(['foo', 'bar']);