CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-electron-debug

Adds useful debug features to your Electron app

86

1.19x
Overview
Eval results
Files

task.mdevals/scenario-4/

Configuration Manager

A configuration manager that handles user preferences with options override using shallow merge patterns.

Description

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.

Requirements

Implement a configuration manager with the following behavior:

  1. Accept global default options that apply to all items
  2. Support an item selector function that determines item-specific configuration
  3. The selector function receives an item and can return:
    • true: Use global options as-is
    • false: Disable configuration for this item
    • A partial options object: Shallow merge with global options (item-specific overrides take precedence)
  4. Provide a method to get the final merged configuration for any given item

Implementation

@generates

API

/**
 * 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)

Capabilities

Global Default Options

  • Creates a manager with { verbose: true, timeout: 5000 } as defaults and gets config for any item, returns the default options @test

Selector Returns True

  • When selector returns true for an item, getConfig returns the global defaults unchanged @test

Selector Returns False

  • When selector returns false for an item, getConfig returns null indicating the item is disabled @test

Shallow Merge with Partial Options

  • When selector returns { timeout: 10000 } for an item with global defaults { verbose: true, timeout: 5000, retries: 3 }, getConfig returns { verbose: true, timeout: 10000, retries: 3 } @test
  • When selector returns { verbose: false } for an item with global defaults { verbose: true, timeout: 5000 }, getConfig returns { verbose: false, timeout: 5000 } @test

No Selector Provided

  • When no itemSelector is provided in options, getConfig always returns the global defaults for any item @test

Dependencies { .dependencies }

electron-debug { .dependency }

Provides patterns for configuration management with options override.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-electron-debug

tile.json