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 utility that normalizes field names in API responses to different naming conventions based on configuration.
You need to create a field name normalizer that can transform object keys in API response data according to specified naming conventions. The normalizer should support converting between different case styles commonly used in APIs (e.g., converting database snake_case to JavaScript camelCase, or vice versa).
Your solution should:
camel: camelCase (e.g., firstName)snake: snake_case (e.g., first_name)kebab: kebab-case (e.g., first-name)@generates
/**
* Normalizes field names in an object to a specified naming convention.
*
* @param {Object} data - The object whose keys should be normalized
* @param {string} convention - The target naming convention ('camel', 'snake', or 'kebab')
* @returns {Object} A new object with normalized keys
*/
function normalizeFields(data, convention) {
// Implementation here
}
module.exports = { normalizeFields };{ first_name: "John", last_name: "Doe" } with convention camel, it returns { firstName: "John", lastName: "Doe" } @test{ firstName: "Jane", lastName: "Smith" } with convention snake, it returns { first_name: "Jane", last_name: "Smith" } @test{ user_id: 123, is-active: true } with convention kebab, it returns { "user-id": 123, "is-active": true } @test{ user_data: { first_name: "Bob" } } with convention camel, it returns { userData: { firstName: "Bob" } } @testProvides utility functions for data transformation.