Adds useful debug features to your Electron app
86
A configuration manager that handles user preferences with options override using shallow merge patterns.
Create a configuration manager that accepts global default options and allows per-item customization through a selector function. The selector function can return boolean values or partial option objects that should be shallow merged with the global defaults.
Implement a configuration manager with the following behavior:
true: Use global options as-isfalse: Disable configuration for this item@generates
/**
* Creates a configuration manager with global defaults and optional item selector.
*
* @param {Object} options - Configuration options
* @param {Object} options.defaults - Global default configuration values
* @param {Function} [options.itemSelector] - Optional function to customize per-item config
* @returns {Object} Configuration manager instance
*/
function createConfigManager(options) {
// Returns object with getConfig method
}
/**
* Gets the merged configuration for a specific item.
*
* @param {Object} item - The item to get configuration for
* @returns {Object|null} Merged configuration or null if disabled for this item
*/
// Available as: configManager.getConfig(item){ verbose: true, timeout: 5000 } as defaults and gets config for any item, returns the default options @testtrue for an item, getConfig returns the global defaults unchanged @testfalse for an item, getConfig returns null indicating the item is disabled @test{ timeout: 10000 } for an item with global defaults { verbose: true, timeout: 5000, retries: 3 }, getConfig returns { verbose: true, timeout: 10000, retries: 3 } @test{ verbose: false } for an item with global defaults { verbose: true, timeout: 5000 }, getConfig returns { verbose: false, timeout: 5000 } @testitemSelector is provided in options, getConfig always returns the global defaults for any item @testProvides patterns for configuration management with options override.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-electron-debugdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10