Ctrl + k

or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/lodash.unescape@4.0.x
tile.json

tessl/npm-lodash-unescape

tessl install tessl/npm-lodash-unescape@4.0.0

Converts HTML entities to their corresponding characters in a string

Agent Success

Agent success rate when using this tile

85%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.39x

Baseline

Agent success rate without this tile

61%

task.mdevals/scenario-2/

Configuration Manager

Build a configuration management system that safely handles deeply nested configuration objects with default values and validation.

Requirements

Implement a configuration manager that:

  1. Retrieves configuration values from nested objects using string paths (e.g., "database.host" or "api.endpoints.users")
  2. Sets configuration values at nested paths, creating intermediate objects as needed
  3. Checks for configuration existence before attempting operations
  4. Provides safe defaults when values don't exist

The system should handle cases where intermediate paths don't exist and provide graceful fallbacks.

API

/**
 * Gets a configuration value at the specified path.
 * Returns the default value if the path doesn't exist.
 *
 * @param {Object} config - The configuration object
 * @param {string} path - The path to the value (e.g., "database.host")
 * @param {*} defaultValue - Value to return if path doesn't exist
 * @returns {*} The value at the path or the default value
 */
function getConfig(config, path, defaultValue) {}

/**
 * Sets a configuration value at the specified path.
 * Creates intermediate objects as needed.
 * Returns the modified configuration object.
 *
 * @param {Object} config - The configuration object
 * @param {string} path - The path where to set the value
 * @param {*} value - The value to set
 * @returns {Object} The modified configuration object
 */
function setConfig(config, path, value) {}

/**
 * Checks if a configuration value exists at the specified path.
 *
 * @param {Object} config - The configuration object
 * @param {string} path - The path to check
 * @returns {boolean} True if the path exists, false otherwise
 */
function hasConfig(config, path) {}

module.exports = { getConfig, setConfig, hasConfig };

Test Cases

  • Given config {database: {host: "localhost"}}, getConfig(config, "database.host", "default") returns "localhost" @test
  • Given config {database: {}}, getConfig(config, "database.port", 5432) returns 5432 @test
  • Given config {}, setConfig(config, "api.timeout", 3000) creates the nested structure and sets the value @test
  • Given config {api: {url: "http://api.com"}}, hasConfig(config, "api.url") returns true @test
  • Given config {api: {}}, hasConfig(config, "api.key") returns false @test

Implementation

@generates

Dependencies { .dependencies }

lodash { .dependency }

Provides utility functions for safe object property access and manipulation.