tessl install tessl/npm-lodash-unescape@4.0.0Converts 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%
Build a configuration query system that allows users to extract and match values from nested configuration objects using string path notation.
Implement a module that provides the following functionality:
Value Extraction: Create a function getValue(config, path) that safely extracts values from nested configuration objects using dot notation paths (e.g., "server.port" or "database.connection.host"). If the path doesn't exist, return undefined.
Property Matcher: Create a function createPropertyMatcher(path, value) that returns a predicate function. This predicate should check if objects have a property at the given path that matches the specified value. The predicate should work with arrays of objects (e.g., for filtering).
Path Normalization: Create a function normalizePath(pathString) that converts various path formats into a standardized array format. It should handle:
@test
const config = {
server: {
port: 3000,
host: 'localhost'
},
database: {
connection: {
host: 'db.example.com',
port: 5432
}
}
};
getValue(config, 'server.port'); // returns 3000
getValue(config, 'database.connection.host'); // returns 'db.example.com'
getValue(config, 'server.missing'); // returns undefined@test
const servers = [
{ name: 'web-1', status: 'active', port: 8080 },
{ name: 'web-2', status: 'inactive', port: 8081 },
{ name: 'web-3', status: 'active', port: 8082 }
];
const isActive = createPropertyMatcher('status', 'active');
servers.filter(isActive); // returns [{name: 'web-1', ...}, {name: 'web-3', ...}]
const hasPort8080 = createPropertyMatcher('port', 8080);
servers.filter(hasPort8080); // returns [{name: 'web-1', ...}]@test
normalizePath('a.b.c'); // returns ['a', 'b', 'c']
normalizePath('users[0].name'); // returns ['users', '0', 'name']
normalizePath('data.items[2].value'); // returns ['data', 'items', '2', 'value']
normalizePath('simple'); // returns ['simple']@generates
/**
* Safely extracts a value from a nested object using a path string
* @param {Object} config - The configuration object to query
* @param {string} path - The path to the desired value (e.g., 'server.port')
* @returns {*} The value at the path, or undefined if not found
*/
function getValue(config, path) {
// Implementation here
}
/**
* Creates a predicate function that checks if objects have a property matching a value
* @param {string} path - The path to the property to check
* @param {*} value - The value to match against
* @returns {Function} A predicate function that takes an object and returns true/false
*/
function createPropertyMatcher(path, value) {
// Implementation here
}
/**
* Converts a path string into an array of path segments
* @param {string} pathString - The path string to normalize
* @returns {Array<string>} An array of path segments
*/
function normalizePath(pathString) {
// Implementation here
}
module.exports = {
getValue,
createPropertyMatcher,
normalizePath
};Provides utility functions for working with objects and property paths.